使用doxygen引用C ++运算符重载

问题描述 投票:5回答:1

我正在尝试为我编写的模块编写一些通用文档,我希望在文档中引用我的operator<<方法。

我已将问题归结为几个示例文件。

C ++源码

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

}
}

降价文件:

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.

当我运行doxygen 1.8.4时,@ref@link无法解决,原因是:

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

自动链接到运算符工作正常,但为了使文档更容易阅读,我想使用@ref删除整个命名空间和类前缀。

起初我想也许这只是与operator<<有关,但它似乎是所有运算符重载的问题。

有没有办法实现这个目标?我究竟做错了什么?

doxygen
1个回答
0
投票

目前似乎只能通过使用完整参数列表来引用运算符。在你的情况下,这将是:

@ref outer::inner::Foo::operator<<(int) and @ref outer::inner::Foo::operator!()
© www.soinside.com 2019 - 2024. All rights reserved.