我刚刚发布了一个skiplist容器库。 Sun 编译器对此有抱怨:
template <class T, class R>
bool operator==(const IndexedSkipList<T,R> &left, const IndexedSkipList<T,R> &right)
{
return ((left.size() == right.size()) &&
(std::equal(left.begin(), left.end(), right.begin())));
}
错误是:
"include/CSIndexedSkipList.h", line 65: Error: Too few arguments for template std::reverse_iterator<CS::BidiIdxIterator<CS::IndexedSkipList<CS::T, CS::R>>>.
"include/CSIndexedSkipList.h", line 207: Where: While specializing "CS::IndexedSkipList<CS::T, CS::R>".
"include/CSIndexedSkipList.h", line 207: Where: Specialized in non-template code.
上面的代码是从207开始的。但它似乎在抱怨reverse_iterator。我真的无法理解它。我无法直接访问 Sun 编译器,所以我想知道我是否做错了什么。
另外,我在reverse_iterator中只使用了一个模板参数,但我注意到SGI文档说第二个参数T没有默认值。在我看过的所有地方,他们都只是使用这个:
typedef std::reverse_iterator<iterator> reverse_iterator;
这是编译器抱怨的第 65 行。我需要添加 T 作为参数吗?我无法弄清楚有问题的错误。
顺便说一句,这适用于我能找到的所有平台上的 gcc。它在 Borland 中也能工作。