gpt4 book ai didi

c++ - 带有 Doxygen (C++) 的模板类中的 typedef

转载 作者:可可西里 更新时间:2023-11-01 17:38:18 27 4
gpt4 key购买 nike

我的问题是关于如何使用 Doxygen 在模板类中注释 typedef。我将举一个例子来说明我的问题:

 namespace fundamental
{
/**
* Basic function
*/
template <typename T>
class Base
{
public:
T x; ///< x coordinate
T y; ///< y coordinate
};
typedef Base<float> Coordinate; ///< Point coordinate class
}

使用Doxygen 处理以上代码后,我可以得到一个HTML 页面来显示类Base 的定义。但是对于typedef类Coordinate,它不会和Base出现在同一个页面中。事实上,所有 typedef 类型都列在基本命名空间页面中,连同该命名空间中的所有类。我想知道是否可以在基本 HTML 页面中显示坐标类。通过这样做,Base 和 Coordinate 之间的联系将变得更加紧密。谢谢!

最佳答案

typedef 是 namespace 的一部分,因此您必须记录 namespace 以使其出现,即​​:

/// documentation for the namespace
namespace fundamental
{
...
typedef Base<float> Coordinate; ///< Point coordinate class
}

或者你可以使用 @relates但这会将成员置于基类的相关函数下:

/// @relates Base
/// Point coordinate class
typedef Base<float> Coordinate;

您可以通过使用 doxygen -l 创建布局文件将此标题更改为例如 Related Members然后编辑两次出现的 related生成的元素 DoxygenLayout.xml如下:

<related title="Related Members"/>

关于c++ - 带有 Doxygen (C++) 的模板类中的 typedef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11849241/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com