mardi 2 février 2016

Inserting into unordered_map

Is there anything semantically wrong with the following code?:

#include<iostream>
#include<unordered_map>
using namespace std;

int main()
{
  unordered_map<pair<int,int>, int> M;  // <--- many compiler errors here
  pair<int,int> p = make_pair(5,4);

  M[p] = 3;
}

I'm getting a bunch of compiler errors, but to me it seems like it should work fine (as it does if I just use an int as the key of the unordered_map). Any ideas why this happens?

Aucun commentaire:

Enregistrer un commentaire