【问题标题】:std::pair expecting a 'type', but I am giving it a typestd::pair 期待一个“类型”,但我给它一个类型
【发布时间】:2010-09-23 13:14:29
【问题描述】:

这是我的代码:

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&lt;T1, T2&gt;::equal_range(key)的返回类型使用相同的表示法

感谢任何帮助。谢谢:)

【问题讨论】:

  • 旁注:单数为顶点,复数为顶点或顶点。

标签: c++ templates stl


【解决方案1】:

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

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

除非使用typename,否则从属名称假定为not name types

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 2020-04-22
    • 2021-11-26
    相关资源
    最近更新 更多