June 2017
Intermediate to advanced
532 pages
12h 59m
English
In this recipe, we use the initializer syntax in both the supported contexts in order to see how they tidy up our code:
if (auto itr (character_map.find(c)); itr != character_map.end()) { // *itr is valid. Do something with it. } else { // itr is the end-iterator. Don't dereference. } // itr is not available here at all
switch (char c (getchar()); c) { case 'a': move_left(); break; case 's': move_back(); break; case 'w': move_fwd(); ...Read now
Unlock full access