假设我正在编写一个类模板,其中一些成员受到类型模板参数 static constexpr 数据成员的存在和值的限制:
\ntemplate<class T>\nstruct A {\n constexpr bool operator()() requires T::value { return T::value; }\n constexpr bool operator()() { return false; }\n};\n#include <type_traits>\nstatic_assert(A<std::true_type>()());\nstatic_assert(!A<std::false_type>()());\nstatic_assert(!A<void>()());\nRun Code Online (Sandbox Code Playgroud)\nMSVC 和 gcc 接受这一点,但 clang 拒绝,除非我替换 requires T::value为requires requires { requires T::value; }. 这是 clang 中的错误,还是其他编译器松懈?C++ 是否需要需要需要需要?标准怎么说?
相关(嗯,至少是\xe2\x85\x94):为什么我们需要需要需要?
\n