我可以在 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 };