Is it legal to expand a package of non-type parameters to define an internal class template with non-type template parameters?

The minimum code I could create to reproduce the problem:

template <int> struct Tag { }; Tag<0> w; template <int... Is> struct Outer { template <Tag<Is> &...> struct Inner { }; }; int main() { Outer<0>::Inner<w> f; } 

g ++ (version 6.1.1 20160511) detects the following error when compiling code:

 pp.cc: In function 'int main()': pp.cc:14:21: internal compiler error: unexpected expression 'Is' of kind template_parm_index Outer<0>::Inner<w> f; 

And produces a long and boring stack trace. clang ++ in version 3.6.0 does not seem to have problems compiling code. The same code with type template parameters is compiled in both compilers:

 template <class> struct Tag { }; Tag<int> w; template <class... Ts> struct Outer { template <Tag<Ts> &...> struct Inner { }; }; int main() { Outer<int>::Inner<w> f; } 

So is this a g ++ bug, or did I miss something important in expanding the parameters of a non-standard template extension that does not extend to the extension of the template template parameters?

+5
source share
1 answer

(Not an answer, but someone might be interested)

A possible relatively simple workaround for GCC:

 template <int> struct Tag { }; Tag<0> w; template <class... Ts> struct OuterParent { template <Ts&...> struct Inner { }; }; template <int... Is> struct Outer:OuterParent<Tag<Is>...> { }; int main() { Outer<0>::Inner<w> f; } 
0
source

All Articles