#include <iostream>
#include <unordered_map>
#include <utility>
int main()
{
std::unordered_map<int, int> map;
map[3] = 333;
map[2] = 222;
map[1] = 111;
// loop 0
// QUESTION 1: Why is `std::pair<int, int> &` not allowed but `auto &` in loop 1 is?
// for(std::pair<int, int> & pair : map)
// pair.second++;
// loop 2
for(auto & pair : map)
// QUESTION 2: Why/How/When does `auto` differ from the concrete type (like `std::pair<int, int>` above)?
pair.second++;
// loop 3
for(auto const & pair : map)
// QUESTION 3: Why are this different pointers than in loop 4?
std::cout << pair.first << " (" << &pair.first << ") : " << pair.second << " (" << &pair.second << ")" << std::endl;
// loop 4
for(std::pair<int, int> const & pair : map)
// QUESTION 4: Why are this the same pointers for all map entries?
std::cout << pair.first << " (" << &pair.first << ") : " << pair.second << " (" << &pair.second << ")" << std::endl;
return 0;
}