The following code represents a container based on std::vector
template
struct TList
{
typedef std::vector - Type;
};
Yes and no.
You can use a template template parameter, e.g.,
template class Container>
struct TList { /* ... */ };
However, in general, template template parameters are not particularly useful because the number and types of the template parameters have to match. So, the above would not match std::vector
because it actually has two template parameters: one for the value type and one for the allocator. A template template parameter can't take advantage of any default template arguments.
To be able to use the std::vector
template as an argument, TList
would have to be declared as:
template class Container>
struct TList { /* ... */ };
However, with this template, you wouldn't be able to use the std::map
template as an argument because it has four template parameters: the key and value types, the allocator type, and the comparator type.
Usually it is much easier to avoid template template parameters because of this inflexibility.