我在以下代码的编译时遇到了问题:
template <typename T,
template <class T, class Allocator = std::allocator<T> > class C>
bool is_in(const C<T>& a, const C<T>& b);
template <typename T, std::vector> // HERE
bool is_in(const std::vector<T>& a, const std::vector<T>& b)
{
return false; // implementation tbd
}
...
vector<int> a, b;
cout << is_in(a,b) << endl;
错误信息是(在标记为“HERE”的行上):
error: 'std::vector' is not a type
当然,我已经包含了来自std的向量!有什么建议吗?我已经试验了一段时间,但是现在需要帮助了 :-) 我需要部分特化初始模板声明,以便我可以让编译器根据容器C的实际类型切换实现(将为集合、向量、范围等各自提供is_in,每次都使用不同的算法)。
谢谢!