In my previous question (Is it legal to use an unexpanded parameter pack as the type of a template template parameter's non-type template parameter?), it was pointed out that it is not legal to expand a parameter pack in the same template parameter list it was declared in, per [temp.param]/17. However, the question still stands when the expansion is done in a separate parameter list. In the following code:
template <typename... Args>
struct tuple {};
template <typename... Types>
struct A {
template <typename>
struct B;
};
template <typename... Types>
template <
template <Types> typename... Outer, // XXX
Types... Inner
>
struct A<Types...>::B<tuple<Outer<Inner>...>> {};
template <long T> struct O1 {};
template <unsigned T> struct O2 {};
A<long, unsigned>::B<tuple<O1<1>, O2<2>>> test;
clang accepts the code, deducing Types = {long, unsigned}, Outer = {O1, O2}, Inner={1L, 2U}. Structurally, this seems correct.
gcc ICEs on the code, while MSVC and ICC reject it.
Is this code valid? On the line denoted XXX, is it valid to have a parameter pack as the type of the template template parameter's non-type template parameter?