
但下一个专业化是一个模板本身.你如何指定:
template<typename T>class Action{ public: voID doStuff() { std::cout << "Generic\n"; }}// A specialization for a persontemplate<>class Action<Person>{ public: voID doStuff() { std::cout << "A Person\n";}}// I can easily specialize for vectors of a particular type.// But how do I change the following so that it works with all types of vector.// Not just `int`template<>class Action<std::vector<int> >{ public: voID doStuff() { std::cout << "A Generic Vector\n";}}解决方法 琐碎的部分专业化? template <typename T>class Action<std::vector<T>> {public: voID doStuff() { std::cout << "A Generic Vector\n"; }}; 总结 以上是内存溢出为你收集整理的c – 本身就是模板的专业化全部内容,希望文章能够帮你解决c – 本身就是模板的专业化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)