Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/concepts/explicit-spec1.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 C() { return __is_class(T); } | |
8 | |
9 template<typename T> | |
10 concept bool D() { return C<T>() && __is_empty(T); } | |
11 | |
12 struct X { } x; | |
13 struct Y { int n; } y; | |
14 | |
15 template<typename T> void g(T) { } // #1 | |
16 template<C T> void g(T) { } // #2 | |
17 template<D T> void g(T) { } // #3 | |
18 | |
19 int called; | |
20 | |
21 template<> void g(int) { called = 1; } // Specialization of #1 | |
22 template<> void g<X>(X) { called = 2; } // Specialization of #3 | |
23 template<> void g(Y) { called = 3; } // Specialization of #2 | |
24 | |
25 int main() { | |
26 g(0); | |
27 assert(called == 1); | |
28 g(x); | |
29 assert(called == 2); | |
30 g(y); | |
31 assert(called == 3); | |
32 } |