| 1 |
// PR c++/94483 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
template<int... a> constexpr auto x1 |
| 5 |
= [...z = -a] (auto F) { return F(z...); }; |
| 6 |
|
| 7 |
template<const int&... a> constexpr auto x2 |
| 8 |
= [&...z = a] (auto F) { return F(z...); }; |
| 9 |
|
| 10 |
template<int... a> constexpr auto x3 |
| 11 |
= [z = -a] (auto F) { return F(z); }; // { dg-error "packs not expanded" } |
| 12 |
|
| 13 |
|
| 14 |
constexpr auto sum = [] (auto... xs) { return (xs + ... + 0); }; |
| 15 |
const int y1 = 1, y2 = 2, y3 = 3; |
| 16 |
|
| 17 |
static_assert(x1<1,2,3>(sum) == -6); |
| 18 |
static_assert(x2<y1,y2,y3>(sum) == 6); |