Debian Codegraph @

gcc/testsuite/g++.dg/template/explicit-instantiation6.C

raw
1 // PR c++/110323
2 // { dg-do compile { target c++14 } }
3
4 template<bool B, class T, class F>
5 struct conditional { using type = T; };
6
7 template<class T, class F>
8 struct conditional<false, T, F> { using type = F; };
9
10 constexpr int VAL = 1;
11
12 static constexpr int getval () { return 1; }
13
14 template<typename>
15 constexpr int TVAL = 1;
16
17 static struct S {
18 constexpr operator bool() { return true; }
19 } s;
20
21 struct foo {
22 template <int B>
23 void bar(typename conditional<B == VAL, int, float>::type arg) { }
24
25 template <int B>
26 void qux(typename conditional<B == TVAL<int>, int, float>::type arg) { }
27
28 template <int B>
29 void sox(typename conditional<B == noexcept (VAL), int, float>::type arg) { }
30
31 template <int B>
32 void nim(typename conditional<B != sizeof (VAL), int, float>::type arg) { }
33 };
34
35 template void foo::bar<1>(int arg);
36 template void foo::qux<1>(int arg);
37 template void foo::sox<1>(int arg);
38 template void foo::nim<1>(int arg);
39
40 // { dg-final { scan-assembler "_ZN3foo3barILi1EEEvN11conditionalIXeqT_L_ZL3VALEEifE4typeE" } }
41 // { dg-final { scan-assembler "_ZN3foo3quxILi1EEEvN11conditionalIXeqT_L_Z4TVALIiEEEifE4typeE" } }
42 // { dg-final { scan-assembler "_ZN3foo3soxILi1EEEvN11conditionalIXeqT_nxL_ZL3VALEEifE4typeE" } }
43 // { dg-final { scan-assembler "_ZN3foo3nimILi1EEEvN11conditionalIXneT_szL_ZL3VALEEifE4typeE" } }