Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C

raw
1 // { dg-do compile { target c++11 } }
2
3 template<typename _Tp, _Tp v>
4 struct A3
5 {
6 typedef _Tp value_type;
7 typedef A3<value_type,v> type;
8
9 static constexpr value_type value = v;
10
11 constexpr operator value_type() { return value; }
12 };
13
14 // Partial specialization.
15 template<typename _Tp, _Tp* v>
16 struct A3<_Tp*, v>
17 {
18 typedef _Tp* value_type;
19 typedef A3<value_type,v> type;
20
21 static constexpr value_type value = v;
22
23 constexpr operator value_type() { return value; }
24 };
25
26 // Explicit specialization.
27 template<>
28 struct A3<unsigned short, 0>
29 {
30 typedef unsigned short value_type;
31 typedef A3<value_type, 0> type;
32
33 static constexpr value_type value = 0;
34
35 constexpr operator value_type() { return value; }
36 };
37
38 // Explicitly instantiate.
39 template struct A3<int, 415>;
40
41 // Extern explicitly instantiate.
42 extern template struct A3<int, 510>;
43
44 // Use.
45 A3<int, 1111> a31;
46 A3<char, 9999> a32; // { dg-error "narrowing conversion" }