gcc/testsuite/g++.dg/cpp0x/constexpr-conv3.C
raw| 1 | // PR c++/87145 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | template<typename T, T t> struct integral_constant { |
| 5 | static constexpr T value = t; |
| 6 | }; |
| 7 | |
| 8 | enum class Enum : unsigned {}; |
| 9 | |
| 10 | struct Pod { |
| 11 | unsigned val; |
| 12 | |
| 13 | constexpr operator Enum() const { |
| 14 | return static_cast<Enum>(val); |
| 15 | } |
| 16 | }; |
| 17 | |
| 18 | template<unsigned N> |
| 19 | constexpr void foo() { |
| 20 | using Foo = integral_constant<Enum, Pod{N}>; |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | foo<2>(); |
| 25 | } |