1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
5 template<typename T
, typename U
>
6 constexpr bool is_same_v
= false;
9 constexpr bool is_same_v
<T
, T
> = true;
11 template<typename T
, typename U
>
12 concept same_as
= is_same_v
<T
, U
>;
14 static_assert(requires
{ requires
true; 0; typename A
;
15 { 0 } -> same_as
<int>; });
16 static_assert(is_same_v
<bool, decltype(requires
{ requires
false; })>);
18 // Check that requires expr is an unevaluated context.
21 static constexpr bool r
= requires
{ i
; };
24 template<typename T
> requires
requires (T t
) {
25 requires
false; // expected-note{{because 'false' evaluated to false}}
34 // expected-error@-1 {{constraints not satisfied for class template 'r1' [with T = int]}}
36 template<typename T
> requires
requires (T t
) {
38 requires
false; // expected-note{{because 'false' evaluated to false}}
44 // expected-error@-1 {{constraints not satisfied for class template 'r2' [with T = int]}}
46 template<typename T
> requires
requires (T t
) {
52 requires
false; // expected-note{{because 'false' evaluated to false}}
58 // expected-error@-1 {{constraints not satisfied for class template 'r3' [with T = int]}}
61 struct S
{ static const int s
= T::value
; };
63 template<typename T
> requires requires
{ T::value
; S
<T
>::s
; }
64 // expected-note@-1 {{because 'T::value' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
68 // expected-error@-1 {{constraints not satisfied for class template 'r4' [with T = int]}}