Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-explicit-spec1.C

raw
1 // { dg-do run { target c++20 } }
2 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
3
4 #include <cassert>
5
6 template<typename T>
7 concept C = __is_class(T);
8
9 template<typename T>
10 concept D = 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 }