145
|
1 // { dg-do compile { target c++17_only } }
|
131
|
2 // { dg-options "-fconcepts" }
|
111
|
3
|
|
4 #include <cassert>
|
|
5
|
|
6 template<typename T>
|
|
7 concept bool Class() { return __is_class(T); }
|
|
8
|
|
9 template<typename T>
|
|
10 concept bool Empty() { return Class<T>() and __is_empty(T); }
|
|
11
|
|
12 template<Class T> int f(T) { return 1; }
|
|
13 template<Empty T> int f(T) { return 2; }
|
|
14
|
|
15 struct S {
|
|
16 template<Class T> int f(T) { return 1; }
|
|
17 template<Empty T> int f(T) { return 2; }
|
|
18 } s;
|
|
19
|
|
20 struct X { } x;
|
|
21 struct Y { X x; } y;
|
|
22
|
|
23 int main () {
|
|
24 auto p1 = &f<X>; // Empty f
|
|
25 assert(p1(x) == 2);
|
|
26
|
|
27 auto p2 = &f<Y>; // Class f
|
|
28 assert(p2(y) == 1);
|
|
29
|
|
30 auto p3 = &S::template f<X>; // Empty f
|
|
31 assert((s.*p3)(x) == 2);
|
|
32
|
|
33 auto p4 = &S::template f<Y>; // Empty f
|
|
34 assert((s.*p4)(y) == 1);
|
|
35 }
|