// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s template requires (sizeof(T) >= 2) // expected-note{{because 'sizeof(char) >= 2' (1 >= 2) evaluated to false}} struct A { static constexpr int value = sizeof(T); }; static_assert(A::value == 4); static_assert(A::value == 1); // expected-error{{constraints not satisfied for class template 'A' [with T = char]}} template requires (sizeof(T) != sizeof(U) // expected-note{{because 'sizeof(int) != sizeof(char [4])' (4 != 4) evaluated to false}} && sizeof(T) >= 4) // expected-note{{because 'sizeof(char) >= 4' (1 >= 4) evaluated to false}} constexpr int SizeDiff = sizeof(T) > sizeof(U) ? sizeof(T) - sizeof(U) : sizeof(U) - sizeof(T); static_assert(SizeDiff == 3); static_assert(SizeDiff == 0); // expected-error{{constraints not satisfied for variable template 'SizeDiff' [with T = int, U = char [4]]}} static_assert(SizeDiff == 3); // expected-error{{constraints not satisfied for variable template 'SizeDiff' [with T = char, U = int]}} template requires ((sizeof(Ts) == 4) || ...) // expected-note{{because 'sizeof(char) == 4' (1 == 4) evaluated to false}} expected-note{{'sizeof(long long) == 4' (8 == 4) evaluated to false}} expected-note{{'sizeof(int [20]) == 4' (80 == 4) evaluated to false}} constexpr auto SumSizes = (sizeof(Ts) + ...); static_assert(SumSizes == 13); static_assert(SumSizes == 89); // expected-error{{constraints not satisfied for variable template 'SumSizes' [with Ts = ]}} template concept IsBig = sizeof(T) > 100; // expected-note{{because 'sizeof(int) > 100' (4 > 100) evaluated to false}} template requires IsBig // expected-note{{'int' does not satisfy 'IsBig'}} using BigPtr = T*; static_assert(sizeof(BigPtr)); // expected-error{{constraints not satisfied for alias template 'BigPtr' [with T = int]}}}} template requires T::value // expected-note{{because substituted constraint expression is ill-formed: type 'int' cannot be used prior to '::' because it has no members}} struct S { static constexpr bool value = true; }; struct S2 { static constexpr bool value = true; }; static_assert(S::value); // expected-error{{constraints not satisfied for class template 'S' [with T = int]}} static_assert(S::value); template struct AA { template requires (sizeof(U) == sizeof(T)) // expected-note{{because 'sizeof(int [2]) == sizeof(int)' (8 == 4) evaluated to false}} struct B { static constexpr int a = 0; }; template requires (sizeof(U) == sizeof(T)) // expected-note{{because 'sizeof(int [2]) == sizeof(int)' (8 == 4) evaluated to false}} static constexpr int b = 1; template requires (sizeof(U) == sizeof(T)) // expected-note{{because 'sizeof(int [2]) == sizeof(int)' (8 == 4) evaluated to false}} static constexpr int getB() { // expected-note{{candidate template ignored: constraints not satisfied [with U = int [2]]}} return 2; } static auto foo() { return B::a; // expected-error{{constraints not satisfied for class template 'B' [with U = int [2]]}} } static auto foo1() { return b; // expected-error{{constraints not satisfied for variable template 'b' [with U = int [2]]}} } static auto foo2() { return AA::getB(); // expected-error{{no matching function for call to 'getB'}} } }; constexpr auto x = AA::foo(); // expected-note{{in instantiation of member function 'AA::foo' requested here}} constexpr auto x1 = AA::foo1(); // expected-note{{in instantiation of member function 'AA::foo1' requested here}} constexpr auto x2 = AA::foo2(); // expected-note{{in instantiation of member function 'AA::foo2' requested here}} template struct B { using type = typename T::type; }; // expected-error{{type 'int' cannot be used prior to '::' because it has no members}} template requires B::type // expected-note{{in instantiation of template class 'B' requested here}} // expected-note@-1{{while substituting template arguments into constraint expression here}} struct C { }; template requires (T{}) // expected-error{{atomic constraint must be of type 'bool' (found 'int')}} struct D { }; static_assert(C{}); // expected-note{{while checking constraint satisfaction for template 'C' required here}} static_assert(D{}); // expected-note{{while checking constraint satisfaction for template 'D' required here}}