Debian Codegraph @

gcc/testsuite/g++.dg/concepts/fn3.C

raw
1 // { dg-do compile { target c++17 } }
2 // { dg-options "-fconcepts" }
3 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
4
5 #include <cassert>
6
7 // Check partial ordering during overload resolution.
8
9 template<typename T>
10 concept C = __is_class(T);
11
12 template<typename T>
13 concept D = C<T> and __is_empty(T);
14
15 struct S1 { } s1;
16 struct S2 { int n; } s2;
17
18 int called = 0;
19
20 template<C T> void f1(T x) { called = 1;}
21 template<D T> void f1(T x) { called = 2;}
22
23 int main() {
24 f1(s1); assert(called == 2);
25 f1(s2); assert(called == 1);
26 }