我在编译用下面的代码时间麻烦:C++模板部分特例问题
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;
该错误消息是(在标出“这里”):
error: 'std::vector' is not a type
(的当然,我有包括向量从std!)。任何建议?我弄了一会儿,但我已经到了可以使用一些帮助的地步:-)我需要部分地专门化最初的模板声明,以便我可以让编译器根据实际的类型容器C(将有一个is_in用于集合,一个用于矢量,一个用于范围......,每次都有不同的算法)。
谢谢!
一种解决方法是将功能的一类。 – 2011-06-09 20:02:21
Booouuuhhhh! :-)当然,这将削减我的努力 - 我将不得不推出一个功能对象... – Frank 2011-06-09 20:03:14