C++中操作符之间要加逗号吗?

14

今天我遇到了这段代码(在boost/type_index/type_index_facade.hpp文件的252-259行)。

/// noexcept comparison operators for type_index_facade classes.
bool operator ==, !=, <, ... (const type_index_facade& lhs, const type_index_facade& rhs) noexcept;

/// noexcept comparison operators for type_index_facade and it's TypeInfo classes.
bool operator ==, !=, <, ... (const type_index_facade& lhs, const TypeInfo& rhs) noexcept;

/// noexcept comparison operators for type_index_facade's TypeInfo and type_index_facade classes.
bool operator ==, !=, <, ... (const TypeInfo& lhs, const type_index_facade& rhs) noexcept;

有人能解释一下这是什么意思吗?我以前从没见过像“==,!=,<”这样的东西。


5
不清楚具体情况,但 C++好像并不是最优选择。 - 101010
@101010 这是 C++11。 - Khalil Khalaf
1
@FirstStep 这不是有效的C++11代码,正如顶部答案所解释的那样。 - M.M
1
@FirstStep:当然不是。 - Lightness Races in Orbit
1个回答

31

你会注意到这些是在以下位置书写的:

#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
    ...
#endif

这只是一种hack方法,让doxygen在文档中使用这些“简化”的声明。这部分代码从未被编译。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接