| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
template<typename T, typename U> struct is_same { |
| 4 |
static const bool value = false; |
| 5 |
}; |
| 6 |
|
| 7 |
template<typename T> struct is_same<T, T> { |
| 8 |
static const bool value = true; |
| 9 |
}; |
| 10 |
|
| 11 |
template<typename...> struct Tuple {}; |
| 12 |
template<typename T1, typename T2> struct Pair {}; |
| 13 |
|
| 14 |
template<typename... Args1> |
| 15 |
struct zip { |
| 16 |
template<typename... Args2> |
| 17 |
struct with { |
| 18 |
typedef Tuple<Pair<Args1, Args2>...> type; // { dg-error "mismatched argument pack" } |
| 19 |
}; |
| 20 |
}; |
| 21 |
|
| 22 |
static_assert |
| 23 |
(is_same<zip<short, int>::with<unsigned short, unsigned>::type, |
| 24 |
Tuple<Pair<short, unsigned short>, Pair<int, unsigned> > >::value, |
| 25 |
"zip"); |
| 26 |
|
| 27 |
typedef zip<short>::with<unsigned short, unsigned>::type T2; // error: different number of arguments specified |
| 28 |
// for Args1 and Args2 |
| 29 |
|
| 30 |
template<typename... Args> void f(Args...); |
| 31 |
|
| 32 |
template<typename... Args> void g(Args... args) |
| 33 |
{ |
| 34 |
f(const_cast<const Args*>(&args)...); // okay: ``Args'' and ``args'' are expanded |
| 35 |
f(5 ...); // { dg-error "contains no parameter packs" } |
| 36 |
f(args); // { dg-error "5:parameter packs not expanded" } |
| 37 |
// { dg-message "args" "note" { target *-*-* } .-1 } |
| 38 |
f(h(args...) + args...); // okay: first ``args'' expanded within h, second ``args'' expanded within f. |
| 39 |
} |