Code fix in std::map example
eugenefil opened this issue · comments
Evgeniy Filimonov commented
On p.33 in file 17.Iterators_Containers_Alg.pdf under "std::map example" there are couple fixes in the last chunk:
cout << it.second << " "; // 3, 5, 0, 7
map1.insert( {"jj", 1} ); // insert pair
- auto search = set1.find("jj"); // iterator
- cout << search != set1.end(); // true
- auto it = set1.lower_bound("bb");
- cout << *it.second;
+ auto search = map1.find("jj"); // iterator
+ cout << (search != map1.end()); // true
+ auto it = map1.lower_bound("bb");
+ cout << (*it).second; // 5
Namely:
- replaced set1 with map1
- added parens around
search != set1.end()
due to << having higher precedence - added parens around
*it
due to postfix.second
having higher precedence
Federico commented
Thanks for your careful review, @eugenefil
Evgeniy Filimonov commented
No, it's thank you, @federico-busato. Huge effort on your part. I'm trying to get up to speed with modern c++ and your course really helps. And the very format (practical, concise, like an index) is right on point.