1 // { dg-do compile { target c++2a } }
2 
3 // Test deduction requirements.
4 
5 // req12.C
6 
7 template <typename T, typename U>
8 concept SameAs = __is_same_as(T, U);
9 
10 template <typename T>
requires(T t)11 concept C1 = requires(T t) { // { dg-message "in requirements" }
12   { t } -> SameAs<T>; // NOTE: t deduced as decltype((t))
13   // { dg-message "does not satisfy" "" { target *-*-* } .-1 }
14 };
15 
16 template <typename T>
17   requires C1<T>
f1()18 constexpr bool f1() { return true; }
19 
20 static_assert(f1<char>()); // { dg-error "" }
21 static_assert(f1<int>()); // { dg-error "" }
22 static_assert(f1<double>()); // { dg-error "" }
23 
24 
25 template <typename T>
requires(T t)26 concept C2 = requires(T t) {
27   { t } -> SameAs<T&>; // NOTE: t deduced as decltype((t))
28 };
29 
30 template <typename T>
31   requires C2<T>
f2()32 constexpr bool f2() { return true; }
33 
34 static_assert(f2<int>()); // OK
35