You know the C++ rule that says that the keyword ‘typename’ can be used interchangably with ‘class’ in a template parameter? Not always! Not for the keyword ‘class’ that appears after the template parameter of a template template parameter!
This is a syntax error:
1 |
template <template <typename> <strong>typename</strong> T> struct Foo { ... }; |
You must write it like this:
1 |
template <template <typename> <strong>class</strong> T> struct Foo { ... }; |
Why is that? Jonathan Caves explains here that the rule ‘typename’ can be used interchangably with ‘class’ is a semantic rule, but the use of ‘class’ in the template template parameter is a syntax rule, and thus takes precedence.
Oversight? Intentional?
By the way, Visual C++ 2012 gives a really unhelpful pair of error messages for this, one of which includes an internal grammar rule name—and that is really non-optimal for a compiler error message:
1 2 |
error C2988: unrecognizable template declaration/definition error C2059: syntax error: '<L_TEMPLATEDECL>' |