与 GCC 12.2 和 MSVC 19.33 相比,以下代码示例不能使用 Clang 15 或 Clang trunk 进行编译。嵌套required子句中的约束表达式是否无效?
struct t {
constexpr auto b() const noexcept
{ return true; }
};
template<typename T>
concept c = requires(T t) {
requires t.b();
};
static_assert(c<t>);
Run Code Online (Sandbox Code Playgroud)
Clang 产生的错误消息:
<source>:11:1: error: static assertion failed
static_assert(c<t>);
^ ~~~~
<source>:11:15: note: because 't' does not satisfy 'c'
static_assert(c<t>);
^
<source>:8:14: note: because 't.b()' would be invalid: constraint variable 't'
cannot be used in an evaluated context
requires t.b();
^ …Run Code Online (Sandbox Code Playgroud)