gcc/testsuite/g++.dg/cpp0x/constexpr-conv4.C
raw| 1 | // PR c++/87145 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | struct S { |
| 5 | int val; |
| 6 | |
| 7 | constexpr operator int() const { |
| 8 | return static_cast<int>(val); |
| 9 | } |
| 10 | }; |
| 11 | |
| 12 | template<int N> |
| 13 | struct F { }; |
| 14 | |
| 15 | template<unsigned N> |
| 16 | constexpr void foo() { |
| 17 | F<int{N}> f; |
| 18 | F<S{N}> f2; |
| 19 | } |
| 20 | |
| 21 | int |
| 22 | main() |
| 23 | { |
| 24 | foo<2>(); |
| 25 | } |