0

Why test<std::vector<int> >(); is wrong?

How to comprehend the usage of typename in template <template <typename T, typename AllocT > typename ContainerT>?

Here is the code snippet:

template <template <typename T, typename AllocT > typename ContainerT>
test()
{
    ContainerT<int, my::Allocator<int> > container.
}

int main()
{
     test<std::vector>();
     test<std::list>();
     test<std::set>();
}
John
  • 1,029
  • 2
  • 14
  • 2
    Does this answer your question? [Where and why do I have to put the "template" and "typename" keywords?](https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – Ulrich Eckhardt Dec 24 '20 at 09:52
  • Look here https://en.cppreference.com/w/cpp/language/template_parameters at template template parameter there are few examples. – Tony Dec 24 '20 at 09:52

1 Answers1

1

In this context, the typename keyword simply means that the template parameter is a type parameter.

eerorika
  • 181,943
  • 10
  • 144
  • 256