c/c++-map

C++ map

map iterator

const auto :

1
2
3
4
5
6
7
8
9
// c++11
for (const auto &item : tempMap) {
cout << "[" << item.first << "," << item.second << "]\n";
}

// c++17
for (const auto& [key, value] : tempMap) {
cout << "[" << key << "," << value << "]\n";
}

iterator

1
2
3
4
for (auto iter = tempMap.begin(); iter != tempMap.end(); ++iter){
cout << "[" << iter->first << ","
<< iter->second << "]\n";
}

reference