【发布时间】:2016-03-15 14:39:03
【问题描述】:
我需要专门化这段代码:
template < class T, class Alloc, template <class, class> class VECTOR >
void function(const VECTOR<T, Alloc> &argument);
对于模板 std::vector。目前,它适用于任何 2 参数模板(“类 VECTOR”)参数。
换句话说:
// A, B -- any unpredictable types
function< std::vector <A, B> > (arg); // specialization
function< Some2ArgsTemplate <A, B> > (arg); // general
function< SomeOther2ArgsTemplate <A, B> > (arg); // general
是否可以在不了解 A 和 B 的情况下实现它?任何 C++11/C++14 想法都可以。
【问题讨论】:
-
template <class T, class Alloc> void function (const std::vector<T, Alloc>& argument);和调用有什么问题(function(arg))?