gcc/testsuite/g++.dg/cpp2a/nontype-class61.C
raw| 1 | // PR c++/113242 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | struct wrapper { int n; }; |
| 5 | |
| 6 | template<const wrapper& X> |
| 7 | void f1() { |
| 8 | static_assert(X.n == 42); |
| 9 | } |
| 10 | |
| 11 | template<const wrapper* X> |
| 12 | void f2() { |
| 13 | static_assert(X->n == 42); |
| 14 | } |
| 15 | |
| 16 | template<wrapper X> |
| 17 | void g() { |
| 18 | f1<X>(); |
| 19 | f2<&X>(); |
| 20 | } |
| 21 | |
| 22 | int main() { |
| 23 | constexpr wrapper X = {42}; |
| 24 | g<X>(); |
| 25 | } |