c_cpp 用矢量作为键的地图

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 用矢量作为键的地图相关的知识,希望对你有一定的参考价值。

#include<bits/stdc++.h>
using namespace std;

int main(){
    map< vector<int>, int > m;
    vector<int> a={1,2,3};
    vector<int> b={1,2,3};
    m[a]=23;
    m[b]=46;
    cout<<m[a]<<endl;   // 46
    cout<<m[b]<<endl;   // 46

    // both return 46 as a=b m[a]=m[b]=m[{1,2,3}]

    return 0;
}

以上是关于c_cpp 用矢量作为键的地图的主要内容,如果未能解决你的问题,请参考以下文章