1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 // Examples from standard
5 template<typename T
, typename U
>
6 concept convertible_to
= requires(T t
) { U(t
); };
9 concept R
= requires (T i
) {
11 {*i
} -> convertible_to
<const typename
T::type
&>;
14 template<typename T
> requires R
<T
> struct S
{};
19 const type
&operator*() { return i
; }
25 requires
requires (T x
) { x
+ x
; } // expected-note{{because 'x + x' would be invalid: invalid operands to binary expression ('T' and 'T')}}
26 T
add(T a
, T b
) { return a
+ b
; } // expected-note{{candidate template ignored: constraints not satisfied [with T = T]}}
29 int y
= add(T
{}, T
{}); // expected-error{{no matching function for call to 'add'}}
32 concept C
= requires (T x
) { x
+ x
; }; // expected-note{{because 'x + x' would be invalid: invalid operands to binary expression ('T' and 'T')}}
33 template<typename T
> requires C
<T
> // expected-note{{because 'T' does not satisfy 'C'}}
34 T
add2(T a
, T b
) { return a
+ b
; } // expected-note{{candidate template ignored: constraints not satisfied [with T = T]}}
37 int w
= add2(T
{}, T
{}); // expected-error{{no matching function for call to 'add2'}}