开发者

How to templatize the container type in a function declaration?

开发者 https://www.devze.com 2022-12-30 23:45 出处:网络
I want to write a function 开发者_JAVA技巧that accepts any container holding strings.Something like this:

I want to write a function 开发者_JAVA技巧that accepts any container holding strings. Something like this:

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

But this isn't the right syntax. What's the right syntax?


You need a template template parameter:

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

精彩评论

暂无评论...
验证码 换一张
取 消