I 클래스 템플릿을 작성하고 해당 클래스의 구성원을 완전히 전문화 할 필요가있을 때, Doxygen을가 전문화를 인식하지 않습니다 - 그것은 단지 일반적인 정의를 문서 또는 (단지 전문이있는 경우) 마지막 정의. 것이다) (Doxygen을 C에 대한 ++ 템플릿 클래스 멤버 전문화
=== MyClass.hpp의 ===
#ifndef MYCLASS_HPP
#define MYCLASS_HPP
template<class T> class MyClass{
public:
static void foo();
static const int INT_CONST;
static const T TTYPE_CONST;
};
/* generic definitions */
template<class T>
void MyClass<T>::foo(){
printf("Generic foo\n");
}
template<class T>
const int MyClass<T>::INT_CONST = 5;
/* specialization declarations */
template<> void MyClass<double>::foo();
template<> const int MyClass<double>::INT_CONST;
template<> const double MyClass<double>::TTYPE_CONST;
template<> const char MyClass<char>::TTYPE_CONST;
#endif
=== MyClass.cpp를 ===이 경우에 따라서
#include "MyClass.hpp"
/* specialization definitions */
template<>
void MyClass<double>::foo(){
printf("Specialized double foo\n");
}
template<> const int MyClass<double>::INT_CONST = 10;
template<> const double MyClass<double>::TTYPE_CONST = 3.141;
template<> const char MyClass<char>::TTYPE_CONST = 'a';
, foo는 : 다음은 간단한 예제 "Generic foo"로 문서화되어야하며, INT_CONST는 전문화에 대한 언급없이 5로 설정되어 문서화되며 TTYPE_CONST는 'a'로 설정된 것으로 문서화되며 3.141은 언급되지 않고 'a'는 없음 특별한 경우.
MyClass<T>
의 문서 또는 MyClass<double>
, MyClass<char>
의 새 페이지에서 전문화를 문서화 할 수 있어야합니다. 어떻게해야합니까? Doxygen도 이것을 처리 할 수 있습니까? Doxygen이 내가 원하는 것을 이해하지 못하게하는 선언/코드 구조에서 뭔가 잘못했을 수 있습니까?
내가이 관련된 경우주의해야한다 :
A) 템플릿 함수의 경우를, 전문화 이것은 foo<T>()
및 foo<double>()
모두 문서화, 예컨대 :
/* functions that are global/in a namespace */
template<class T> void foo(){ printf("Generic foo\n"); }
template<> void foo<double>(){ printf("Specialized double foo\n"); }
잘 작동합니다. 나는 전체 템플릿을 재 선언하는 경우
B), 즉 template<> class MyClass<double>{...};
, 다음 MyClass<double>
별도의 클래스로, 자신의 문서 페이지를 얻을 것이다. 그러나 이것은 실제로 완전히 새로운 클래스를 선언하는 것을 의미합니다. MyClass<double>
자체가 선언 된 경우 MyClass<T>
과 MyClass<double>
사이에는 아무런 관계가 없습니다. 그래서, MyClass<double>
에 대한 전문 클래스의 모든 멤버, 클래스 멤버의 및 반복 모든 정의를 재 선언해야 할 것 모두가 동일한 템플릿을 사용하는 것처럼 보이게 할 수 있습니다. 매우 어색하고 kludge 솔루션을 느낀다.
제안 사항? 덕분에 많이 :)
--Ziv