I try to have a partially specialized template class inheriting from another template class. I’m not sure how to to that. Here is my code:
template < typename T>
struct SmallContainer
{
typedef vector<T> type;
};
template<typename CONTAINER, typename T>
class AnotherClass : public CONTAINER<SmallContainer<T>::type>
{ // ..... };
and gcc keeps saying
expected template-name before ‘<’ token
expected ‘{’ before ‘<’ token
expected unqualified-id before ‘<’ token
The idea of my object is to have AnotherClass be a generic container of vector of any other type I want.
I tried to do template< template CONTAINER, typename T> etc… without any success.
Any idea ?
Thanks…
This would work for a container of just one template argument:
This, however, won’t work for any of the standard containers as they have extra template arguments (like allocator).
Note that
typenameis needed beforeSmallContainer< T >::typeor otherwise the compiler will assume it refers to a value.