I want to specialize the type parameter of the following template class, which has a type parameter and a template template parameter:
template <
typename T,
template <typename E> class Foo
> class Bar;
I tried every permutation of adding and/or omitting .template
and typename
in the last line of each of the following snippets, and none compiles:
1.)
template <
template <typename E> class Foo
> class Bar<int, Foo<typename E>>;
2.)
template <
template <typename E> class Foo
> class Bar<int, Foo.template <typename E>>;
3.)
template <
template <typename E> class Foo
> class Bar<int, Foo<E>>;
4.)
template <
template <typename E> class Foo
class Bar<int, Foo.template <E>>;
Why doesn't any of them work?
Regarding the last line of each applicable snippet:
- Doesn't
typename
clarifyE
is a type used by classFoo
, or can this syntax only be used within the{}
body ofBar
's class definition? - Doesn't
template
clarifyFoo
is a template and therefore prevent the compiler from parsingFoo <
asFoo
"is less than", or can this syntax only be used within the{}
body ofBar
's class definition?
How can I get this to work?