![](/img/trans.png)
[英]How to properly document a C++ function description in doxygen?
[英]How to document a function object with doxygen?
我应该如何使用doxygen记录函数对象(AKA仿函数)? 将其记录为普通班级会让人觉得误导。 我发现将函数对象视为具有闭包的函数比使用可调用类更好。
有没有办法记录符合我的偏好的函数对象?
class Adder
{
public:
Adder( size_t x ) :
m_x(x)
{ }
size_t operator () ( size_t y ) const
{
return m_x + y;
}
private:
const size_t m_x;
};
给它类文档,将单词functor放在第一个句子中(最好是作为第一个单词),如果含义明显,则跳过operator()
文档。
提醒你:意思是常不明显 ,如果operator()
过载。
您可以使用doxygen 成员组将所有函子组合在一起。 也许这样的事情会起作用:
/// @name Functors
/// @{
class Adder;
/// @}
/// Functor that adds a set value to its argument when called.
class Adder
{
public:
Adder( size_t x ) :
m_x(x)
{ }
size_t operator () ( size_t y ) const
{
return m_x + y;
}
private:
const size_t m_x;
};
类文档应该足够了。 只需描述目的和用法,并澄清任何有用的内容。 可以避免过于冗长的明显文档。
/*! \brief Adder functor
*
* Returns size_t sum of const member and parameter
*/
class Adder
{
public:
//! Construct with constant value for subsequent sums
Adder( size_t x ) :
m_x(x)
{ }
//! Call with value to compute with constant
size_t operator () ( size_t y ) const
{
return m_x + y;
}
private:
const size_t m_x;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.