rt,今天发现一个奇怪的问题,set<pair<int, int> > s 可以编译,但 unordered_set<pair<int, int> > s 却不可以。
unordered_set<pait<int, int> > 编译错误信息:
main.cc:32:36: error: use of deleted function ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]’
32 | unordered_set<pair<int, int> > s;
| ^
In file included from /opt/rh/devtoolset-9/root/usr/include/c++/9/unordered_set:47,
from /opt/rh/devtoolset-9/root/usr/include/c++/9/x86_64-redhat-linux/bits/stdc++.h:118,
from main.cc:1:
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unordered_set.h:135:7: note: ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]’ is implicitly deleted because the default definition would be ill-formed:
135 | unordered_set() = default;
如何解决?