How to templatize a container type in a function declaration?

I want to write a function that accepts any container containing strings. Something like that:

template <typename Container> void foo(Container<string>& stuff);

But this is not the correct syntax. What is the correct syntax?

+3
source share
1 answer

You need a template template parameter :

template < template <typename> class Container> void foo (Container<string>& stuff);
+4
source

Source: https://habr.com/ru/post/1746599/


All Articles