3
我想写一个接受任何容器持有字符串的函数。像这样:如何在函数声明中模拟容器类型?
template <typename Container> void foo(Container<string>& stuff);
但这不是正确的语法。什么是正确的语法?
我想写一个接受任何容器持有字符串的函数。像这样:如何在函数声明中模拟容器类型?
template <typename Container> void foo(Container<string>& stuff);
但这不是正确的语法。什么是正确的语法?
你需要一个template template parameter:
template < template <typename> class Container> void foo (Container<string>& stuff);
'模板类Container'。 –
kennytm
2010-05-21 17:58:04
是的,第二个类型名称需要类,而它的工作原理。谢谢! – Kyle 2010-05-21 18:07:46
该链接页面的最后一句话是错误的。看到[我的问题](http://stackoverflow.com/questions/1469743/standard-library-containers-with-additional-optional-template-parameters) – 2010-05-21 18:09:09