c++ - 迭代器列表

标签 c++ stl iterator

实现类图我需要这样的东西

unordered_map <Node, list<unordered_set<Edge<Node>>::iterator>> graph; 

为每个顶点存储邻接表。但是,它说 list<unordered_set<Edge<Node>>::iterator>不是有效参数。
我应该如何实现?

这里的错误:

Error 2 error C2923: 'std::unordered_map' : 'std::list<std::unordered_set<Edge<Node>>>::iterator' is not a valid template type argument for parameter '_Ty'

我正在使用带有标准编译器(兼容 c++11)的 VS2012 Express

template<class Node>
class Graph {
}

template<class Node>
    class Edge {
}

最佳答案

由于Node是模板参数,所以在指定依赖于它的类型时需要使用typename:

unordered_map <Node, list<typename unordered_set<Edge<Node>>::iterator>> graph;
                          ^^^^^^^^

关于c++ - 迭代器列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19114110/

相关文章:

python - Python 迭代器是否正式需要 __iter__ 方法?

c++ - 如何使用 MFC 应用程序 (C++ Visual Studio 2010) 中的按钮更改图像的可见属性?

c++ - 获取与 map 中的查询匹配的所有键

c++ - C++中的哈希表/无序映射

c++ - 调用 `string::c_str()` 时实际上做了什么?

python - 如何只读入文件的每一行?

c++ - 字符串流和多线程

c++ - 任何不将大型开关 block 转换为二叉树的编译器?

c++ pthread : how to set io_service. run() 作为 pthread_create 中的参数?

dictionary - 使用 Dart 有条件地返回 Map() 中的元素