今天我遇到了这段代码(在 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;
有人能解释一下这是什么意思吗?我以前从未见过像“==,!=,&lt;,...”
这样的东西答案 0 :(得分:32)
你会注意到这些是写在:
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
...
#endif
这只是让doxygen在文档中使用这些“简化”声明的黑客攻击。这段代码永远不会被编译。