Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts3.C

raw
1 // { dg-do compile { target c++20 } }
2
3 template <class T, class U> concept same_as = __is_same_as(T,U);
4
5 template<typename T>
6 concept C1 = requires (T& t) { // { dg-message "in requirements" }
7 t.~T();
8 };
9
10 template<typename T>
11 concept C2 = requires (T& t) { // { dg-message "in requirements" }
12 { t.~T() } -> same_as<void>;
13 };
14
15 template<typename T>
16 concept C3 = requires { // { dg-message "in requirements" }
17 typename T::type;
18 };
19
20 class S1
21 {
22 ~S1() { }
23 using type = int;
24 };
25
26 void driver() {
27 static_assert(C1<S1>, ""); // { dg-error "static assertion failed" }
28 static_assert(C2<S1>, ""); // { dg-error "static assertion failed" }
29 static_assert(C3<S1>, ""); // { dg-error "static assertion failed" }
30 }
31
32 template<typename T>
33 requires C1<T>
34 void f1() { }
35
36 template<typename T>
37 requires C2<T>
38 void f2() { }
39
40 template<typename T>
41 requires C3<T>
42 void f3() { }
43
44 void driver2() {
45 f1<S1>(); // { dg-error "no match" }
46 f2<S1>(); // { dg-error "no match" }
47 f3<S1>(); // { dg-error "no match" }
48 }