gcc/testsuite/g++.dg/cpp1y/var-templ33.C
raw| 1 | // Test for variable templates in pack expansion |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | template <int I> const int Val = I; |
| 5 | |
| 6 | constexpr int f () { return 0; } |
| 7 | template <class T, class ...Ts> |
| 8 | constexpr int f(T t, Ts... ts) |
| 9 | { |
| 10 | return t + f(ts...); |
| 11 | } |
| 12 | |
| 13 | template <int... Is> |
| 14 | constexpr int g() |
| 15 | { |
| 16 | return f(Val<Is>...); |
| 17 | } |
| 18 | |
| 19 | #define SA(X) static_assert((X),#X) |
| 20 | SA((g<1,2,3,4>() == 1+2+3+4)); |