// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s namespace class_templates { template requires (sizeof(T) >= 4) // expected-note {{because 'sizeof(char) >= 4' (1 >= 4) evaluated to false}} struct is_same { static constexpr bool value = false; }; template requires (sizeof(T*) >= 4 && sizeof(T) >= 4) struct is_same { static constexpr bool value = true; }; static_assert(!is_same::value); static_assert(!is_same::value); static_assert(is_same::value); static_assert(is_same::value); // expected-error {{constraints not satisfied for class template 'is_same' [with T = char, U = char]}} template struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}} template struct B {}; template requires A::type // expected-note{{in instantiation of template class 'class_templates::A' requested here}} // expected-note@-1{{while substituting template arguments into constraint expression here}} struct B {}; template requires (T{}) // expected-error{{atomic constraint must be of type 'bool' (found 'int')}} struct B {}; static_assert((B{}, true)); // expected-note{{while checking constraint satisfaction for class template partial specialization 'B' required here}} // expected-note@-1{{while checking constraint satisfaction for class template partial specialization 'B' required here}} // expected-note@-2{{during template argument deduction for class template partial specialization 'B' [with T = int *]}} // expected-note@-3{{during template argument deduction for class template partial specialization 'B' [with T = int]}} // expected-note@-4 2{{in instantiation of template class 'class_templates::B' requested here}} template concept same_as = is_same::value; template T> requires A::type struct B {}; // expected-note@-1{{previous}} template T> requires A::type struct B {}; // expected-error@-1{{redefinition}} template requires A::type struct B {}; template T> requires A::type struct B {}; } namespace variable_templates { template requires (sizeof(T) >= 4) constexpr bool is_same_v = false; template requires (sizeof(T*) >= 4 && sizeof(T) >= 4) constexpr bool is_same_v = true; static_assert(!is_same_v); static_assert(!is_same_v); static_assert(is_same_v); template struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}} template constexpr bool v1 = false; template requires A::type // expected-note{{in instantiation of template class 'variable_templates::A' requested here}} // expected-note@-1{{while substituting template arguments into constraint expression here}} constexpr bool v1 = true; template requires (T{}) // expected-error{{atomic constraint must be of type 'bool' (found 'int')}} constexpr bool v1 = true; static_assert(v1); // expected-note{{while checking constraint satisfaction for variable template partial specialization 'v1' required here}} // expected-note@-1{{while checking constraint satisfaction for variable template partial specialization 'v1' required here}} // expected-note@-2{{during template argument deduction for variable template partial specialization 'v1' [with T = int *]}} // expected-note@-3{{during template argument deduction for variable template partial specialization 'v1' [with T = int]}} // expected-error@-4{{static_assert failed due to requirement 'v1'}} }