【发布时间】:2021-08-24 15:37:29
【问题描述】:
考虑以下无用的概念C:
template<class T>
concept C = static_cast<T>(true);
如果我们在未评估的上下文中将任意类型传递给C,那么all three compilers 将成功编译:
struct S {};
decltype(C<S>) x = 0;
但如果我们在未评估的上下文中将int 传递给C:
decltype(C<int>) y = 0;
GCC 仍然接受它,while Clang and MSVC reject it with the same error message:
<source>:2:13: error: atomic constraint must be of type 'bool' (found 'int')
上面的代码仍然格式正确吗?我应该信任哪个编译器?
【问题讨论】:
-
这当然很有创意。
标签: c++ language-lawyer c++20 c++-concepts