Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/concepts/fn9.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // { dg-do run } | |
2 // { dg-options "-std=c++17 -fconcepts" } | |
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 } |