static_assert(requires{{(0).da};});// expected-error{{member reference base type 'int' is not a structure or union}}
voidfoo(){}
static_assert(requires{{foo()};});
// Substitution failure in expression
structA{};
structB{
Boperator+(constB&other)const{returnother;}
};
structC{
Coperator+(C&other)const{returnother;}
};
template<typenameT>requiresrequires(Ta,constT&b){{a+b};}// expected-note{{because 'a + b' would be invalid: invalid operands to binary expression ('A' and 'const A')}} expected-note{{because 'a + b' would be invalid: invalid operands to binary expression ('C' and 'const C')}}
structr1{};
usingr1i1=r1<int>;
usingr1i2=r1<A>;// expected-error{{constraints not satisfied for class template 'r1' [with T = A]}}
usingr1i3=r1<B>;
usingr1i4=r1<C>;// expected-error{{constraints not satisfied for class template 'r1' [with T = C]}}
structD{voidfoo(){}};
template<typenameT>requiresrequires(Ta){{a.foo()};}// expected-note{{because 'a.foo()' would be invalid: no member named 'foo' in 'A'}} expected-note{{because 'a.foo()' would be invalid: member reference base type 'int' is not a structure or union}} expected-note{{because 'a.foo()' would be invalid: 'this' argument to member function 'foo' has type 'const D', but function is not marked const}}
structr2{};
usingr2i1=r2<int>;// expected-error{{constraints not satisfied for class template 'r2' [with T = int]}}
usingr2i2=r2<A>;// expected-error{{constraints not satisfied for class template 'r2' [with T = A]}}
usingr2i3=r2<D>;
usingr2i4=r2<constD>;// expected-error{{constraints not satisfied for class template 'r2' [with T = const D]}}
template<typenameT>requiresrequires{{sizeof(T)};}// expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'void'}} expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'nonexistent'}}
structr3{};
usingr3i1=r3<int>;
usingr3i2=r3<A>;
usingr3i3=r3<A&>;
usingr3i4=r3<void>;// expected-error{{constraints not satisfied for class template 'r3' [with T = void]}}
usingr3i4=r3<classnonexistent>;// expected-error{{constraints not satisfied for class template 'r3' [with T = nonexistent]}}
template<typenameT>requiresrequires(Tt){{t}->Same<typenameT::type>;}// expected-note{{because 'Same<expr-type, typename T::type>' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
structr9{};
structM{usingtype=M;};
usingr9i1=r9<M>;
usingr9i2=r9<int>;// expected-error{{constraints not satisfied for class template 'r9' [with T = int]}}
// Substitution failure in both expression and return type requirement
template<typenameT>requiresrequires(Tt){{t.foo()}->Same<typenameT::type>;}// expected-note{{because 't.foo()' would be invalid: member reference base type 'int' is not a structure or union}}
structr10{};
usingr10i=r10<int>;// expected-error{{constraints not satisfied for class template 'r10' [with T = int]}}
// Non-type concept in type constraint
template<intT>
conceptIsEven=(T%2)==0;
template<typenameT>requiresrequires(Tt){{t}->IsEven;}// expected-error{{concept named in type constraint is not a type concept}}