C++ 如何记录;启用“如果”;含强氧剂的功能
在类C++ 如何记录;启用“如果”;含强氧剂的功能,c++,templates,doxygen,C++,Templates,Doxygen,在类Foo中,我有以下模板函数: class Foo { public: template <typename T> static typename boost::enable_if<boost::is_abstract<T>, T*>::type allocate(); template <typename T> static typename boost::disable_if<boost::is_ab
Foo
中,我有以下模板函数:
class Foo
{
public:
template <typename T>
static typename boost::enable_if<boost::is_abstract<T>, T*>::type allocate();
template <typename T>
static typename boost::disable_if<boost::is_abstract<T>, T*>::type allocate();
};
class-Foo
{
公众:
模板
静态typename boost::enable_if::type allocate();
模板
静态typename boost::disable_if::type allocate();
};
有两个声明,但对于用户来说,只有一个函数
用Doxygen记录此类声明的常用方法是什么?
想法#1:
class-Foo
{
公众:
/**\brief此函数引发运行时错误*/
模板
静态typename boost::enable_if::type allocate();
/**\brief此函数分配给定类型的实例*/
模板
静态typename boost::disable_if::type allocate();
};
想法2:
class-Foo
{
公众:
/**\brief此函数分配给定类型的实例,如果不是抽象的,则引发异常*/
模板
静态typename boost::enable_if::type allocate();
模板
静态typename boost::disable_if::type allocate();
};
没有机会使用doxygen记录模板内容。任何类型的专业化都不是以预期的方式处理的。您是否找到了对模板参数进行注释的方法?另请参见:@Klaus:目前,我在使用Doxygen记录模板函数方面没有其他问题。也许我在今天之前没有用模板做过复杂的事情。。。
class Foo
{
public:
/** \brief This function throws a runtime error */
template <typename T>
static typename boost::enable_if<boost::is_abstract<T>, T*>::type allocate();
/** \brief This function allocates an instance of the given type */
template <typename T>
static typename boost::disable_if<boost::is_abstract<T>, T*>::type allocate();
};
class Foo
{
public:
/** \brief This function allocates an instance of the given type if not abstract, throws an exception instead */
template <typename T>
static typename boost::enable_if<boost::is_abstract<T>, T*>::type allocate();
template <typename T>
static typename boost::disable_if<boost::is_abstract<T>, T*>::type allocate();
};