【发布时间】:2018-08-25 07:06:10
【问题描述】:
#include <bits/stdc++.h>
std::unordered_map<std::pair<int,int>, int> mp;
int main()
{
mp[make_pair(1, 2)]++;
}
当使用[] operator时,我明白了
error: no match for ‘operator[]’ (operand types are ‘std::unordered_map<std::pair<int, int>, int>’ and ‘std::pair<int, int>’)
但是,对std::map 执行相同操作时,不会发生错误。为什么?
我怎样才能使它与std::unorderd_m一起工作?
【问题讨论】:
-
你用的c++是什么版本的?
-
我在 G++11 和 G++17 上都试过了,结果一样
标签: c++ c++11 unordered-map c++-standard-library std-pair