gcc/testsuite/g++.dg/cpp2a/nontype-class63.C
raw| 1 | // PR c++/112632 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | template<typename T> |
| 5 | inline constexpr bool C = true; |
| 6 | |
| 7 | struct n { |
| 8 | constexpr n(int a) : i(a) {} |
| 9 | int i; |
| 10 | }; |
| 11 | |
| 12 | template<n N> |
| 13 | using get_n_i_type = decltype(N.i); |
| 14 | |
| 15 | template<int X> |
| 16 | int f() { |
| 17 | using iii = get_n_i_type<X>; |
| 18 | #if 1 // Change to 0 and this compiles |
| 19 | static_assert(C<iii>); |
| 20 | #endif |
| 21 | return iii{}; |
| 22 | } |
| 23 | |
| 24 | template int f<3>(); |