std :: pair期待'type',但我给它一个类型

时间:2010-09-23 13:14:30

标签: c++ templates stl

这是我的代码:

typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght;
std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*);

当我尝试编译它时,它给出了一个错误说:

error: type/value mismatch at argument 1 in template parameter list for ‘template<class _T1, class _T2> struct std::pair’
error:   expected a type, got ‘__gnu_cxx::hash_multimap::iterator’

但是不是,std :: hash_multimap :: iterator是一个类型?我在网上看到的所有示例都对std::hash_multimap<T1, T2>::equal_range(key)

的返回类型使用了相同的表示法

感谢任何帮助。谢谢:))

1 个答案:

答案 0 :(得分:14)

这看起来像是在模板中,VerticeType等是模板参数。在这种情况下,您缺少typename

std::pair<typename ght::iterator, typename ght::iterator> ...

除非使用typename,否则依赖名称将被假定为not name types