如何使用 GCC 6.1 检测 Concepts TS 的存在?
This page建议在概念 TS 支持实现中预定义宏 __cpp_experimental_concepts
。但是,以下测试程序在带有 -fconcepts
标志的 GCC 6.1 上编译时没有错误:
#ifdef __cpp_experimental_concepts
static_assert(false, "Concepts TS found");
#endif
template <typename T>
concept bool Identity = true;
int main() {}
(我希望 static_assert
触发,或者 concept
关键字无法识别。)
有谁知道根据概念是否可用有条件地编译代码的任何其他方法?
最佳答案
对于 GCC,正确的宏是 __cpp_concepts
:
#ifdef __cpp_concepts
static_assert(false, "Concepts TS found");
#endif
根据 this , 在最近的草稿中更改了宏的名称。
正确的名字来自GCC support page (感谢 Jonathan Wakely ),但是 linked draft (2015-02-09) 仍然需要 __cpp_experimental_concepts
(这很奇怪...)。然而,在这个more recent draft (2015-09-25),名称实际上已经更改为__cpp_concepts
。
关于c++ - 使用 GCC 6.1 检测概念 TS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38479713/