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;
};
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.