std::pair 期待一个“类型”,但我给它一个类型

发布于 2024-09-24 11:45:30 字数 677 浏览 0 评论 0原文

这是我的代码:

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

感谢任何帮助。谢谢 :)

This is my code:

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

When I try to compile it, it gives me an error saying:

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’

But isn't, std::hash_multimap::iterator a type? All the examples I've seen online use the same kind of notation for the return type of std::hash_multimap<T1, T2>::equal_range(key)

Any help is appreciated. Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灵芸 2024-10-01 11:45:30

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

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

从属名称假定为 不命名类型,除非使用typename

This looks like it is in a template and VerticeType etc. are template parameters. In that case you are missing typename:

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

Dependent names are assumed to not name types unless typename is used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文