samedi 29 février 2020

Execution order of map[K] = V [duplicate]

Give the following C++ code.

std::map<std::pair<int, int>, int> map;
int test = 0;
map[std::make_pair(test, 2)] = ++test;

The contents of map becomes to (1,2) -> 1. Why not (0, 2) -> 1? Can anyone explain the order of execution in this scenario?

Aucun commentaire:

Enregistrer un commentaire