如何解决C++ unordered_set 向量?
开发过程中遇到C++ unordered_set 向量的问题如何解决?下面主要结合日常开发的经验,给出你关于C++ unordered_set 向量的解决方法建议,希望对你解决C++ unordered_set 向量有所启发或帮助;问题描述
我可以在 C++ 中创建一个 unordered_set 向量吗?像这样
std::unordered_set<std::vector<int>> s1;
因为我知道使用 std lib 的set"类是可能的,但似乎它不适用于无序版本谢谢
更新:这正是我要使用的代码
typedef int CustomerId; typedef std::vector<CustomerId> Route; typedef std::unordered_set<Route> Plan; // ... in the main Route r1 = { 4,5,2,10 }; Route r2 = { 1,3,8,6 }; Route r3 = { 9,7 }; Plan p = { r1,r2 };
如果我使用set就可以了,但是在尝试使用无序版本时我收到一个编译错误
main.cpp:46:11: error: non-aggregate type 'Route' (aka 'vector<CustomerId>') cannot be initialized with an initializer list Route r3 = { 9,7 };
尚未找到解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)