Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing C++ operator overloads with doxygen

Tags:

doxygen

I'm trying to write some general documentation for a module I've written and I wish to reference my operator<< method from within the documentation.

I have distilled the problem down to a couple of example files.

C++ source

namespace outer {
namespace inner {

/** The example class is called Foo. */
class Foo
{
public:
    /** Stream an int pointlessly to Foo.
     * @param   i   Some integer that serves no purpose.
     * @return  The foo you invoked << upon.
     */
    Foo& operator<< (int i)
    {
        return *this;
    }    

    /** Foo always is and never is not. */
    bool operator! ()
    {
        return false;
    }
};

}
}

Markdown documentation:

Foo {#mainpage}
===
You can stream an int to @ref outer::inner::Foo "Foo" by using outer::inner::Foo::operator<<()

Did I mention you can stream an int to outer::inner::Foo by using @ref outer::inner::Foo::operator<<() "operator<<" ?

What about streaming an int with
@link outer::inner::Foo::operator<<()
operator <<
@endlink

Foo's always are, and never are not. outer::inner::Foo::operator!() tells you this.
I just said that @ref outer::inner::Foo::operator!() "operator!" tells you this.

When I run doxygen 1.8.4, the @ref and @link fail to resolve, with the reason being:

Warning: unable to resolve reference to `outer::inner::Foo::operator' for \ref command
Warning: unable to resolve link to `outer::inner::Foo::operator' for \link command

Autolinking to the operators works fine, but to make the documentation easier to read, I want to use @ref to remove the whole namespace and class prefixing.

At first I thought perhaps it was only to do with operator<< but it appears to be a problem for all operator overloads.

Is there a way to achieve this? What am I doing wrong?

like image 907
Timma Avatar asked Nov 11 '22 22:11

Timma


1 Answers

It seems one can currently only reference operators by using the full argument list. In your case this would be:

@ref outer::inner::Foo::operator<<(int) and @ref outer::inner::Foo::operator!()
like image 113
Nathan Phillips Avatar answered Jan 04 '23 03:01

Nathan Phillips