Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-52282-1.C

raw
1 // PR c++/52282
2 // { dg-do compile { target c++11 } }
3
4 template <typename T, T V>
5 struct A
6 {
7 static constexpr T a() { return V; }
8 };
9
10 template <typename T, T V>
11 struct B
12 {
13 typedef T type;
14 static constexpr type b() { return V; }
15 };
16
17 template <typename T, T V>
18 struct C
19 {
20 static constexpr decltype(V) c() { return V; }
21 };
22 static_assert(A<int, 10>::a() == 10, "oops");
23 static_assert(B<int, 10>::b() == 10, "oops");
24 static_assert(C<int, 10>::c() == 10, "oops");
25
26 struct D
27 {
28 static constexpr int d() { return 10; }
29 };
30 static_assert((A<int(*)(), &D::d>::a())() == 10, "oops");
31 static_assert((B<int(*)(), &D::d>::b())() == 10, "oops");
32 static_assert((C<int(*)(), &D::d>::c())() == 10, "oops");