145
|
1 // { dg-do compile { target c++17_only } }
|
131
|
2 // { dg-options "-fconcepts" }
|
111
|
3
|
|
4 template<typename T>
|
|
5 concept bool C1()
|
|
6 {
|
145
|
7 return requires (T t) { t.f(); }; // { dg-message "in requirements" }
|
111
|
8 }
|
|
9
|
|
10 template<typename T>
|
|
11 concept bool C2()
|
|
12 {
|
145
|
13 return requires { typename T::type; }; // { dg-message "in requirements" }
|
111
|
14 }
|
|
15
|
|
16 template<typename T>
|
|
17 requires C1<T>()
|
|
18 void f1(T x) { }
|
|
19
|
|
20 template<typename T>
|
|
21 requires C2<T>()
|
|
22 void f2(T x) { }
|
|
23
|
|
24 // Note that these declarations are private and therefore
|
145
|
25 // cannot satisfy the constraints.
|
111
|
26 class S
|
|
27 {
|
|
28 using type = int;
|
|
29 void f() { }
|
|
30 } s;
|
|
31
|
|
32 int main()
|
|
33 {
|
145
|
34 f1(s); // { dg-error "unsatisfied|private" }
|
111
|
35 f2(s); // { dg-error "" }
|
|
36
|
|
37 // When used in non-SFINAE contexts, make sure that we fail
|
|
38 // the constraint check before emitting the access check
|
145
|
39 // failures. The context is being presented consistently
|
111
|
40 // in both cases.
|
|
41 static_assert(C1<S>(), ""); // { dg-error "failed" }
|
|
42 static_assert(C2<S>(), ""); // { dg-error "" }
|
|
43 }
|