我正在尝试创建一个 unordered_map
来映射整数对:
#include <unordered_map>
using namespace std;
using Vote = pair<string, string>;
using Unordered_map = unordered_map<Vote, int>;
我有一个声明 Unordered_map
为私有成员的类。
然而,当我尝试编译它时,我得到了下面的错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:948:38: Implicit instantiation of undefined template 'std::__1::hash, std::__1::basic_string > >'
如果我使用像 map<pair<string, string>, int>
这样的常规映射而不是 unordered_map
,我就不会得到这个错误。
在无序映射中是否可以使用 pair
作为键?