如何使用 doxygen 记录函数对象?
我应该如何使用 doxygen 记录函数对象(又名函子)?仅将其记录为常规课程会让人产生误解。我发现将函数对象视为带有闭包的函数比将其视为可调用类要好得多。
有没有一种方法可以记录符合我偏好的函数对象?
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;
};
How should I document a function object (AKA functor) with doxygen? It feels misleading to just document it as a regular class. I find it much better to think of a function object as a function with a closure than a callable class.
Is there a way to document a function object that fits with my preferences?
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;
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
给它类文档,将单词 functor 放在第一句中(最好作为第一个单词),如果含义很明显,则跳过
operator()
文档。请注意:如果
operator()
重载,则含义通常不明显。Give it class documentation, put the word functor in the first sentence (preferably as the first word) and skip the
operator()
documentation if the meaning is obvious.Mind you: the meaning is often not obvious if
operator()
is overloaded.类文档应该足够了。只需描述目的和用法并澄清任何有用的内容即可。可以避免对显而易见的内容进行过于冗长的记录。
Class documentation should be sufficient. Just describe the purposes and usage and clarify anything useful. Overly verbose documentation of the obvious can be avoided.
您可以使用 doxygen 成员组 将所有函子分组在一起。也许这样的事情会起作用:
You could use doxygen member groups to group all of your functors together. Maybe something like this would work: