Last active
December 12, 2015 04:49
-
-
Save acmorrow/4717073 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 offers type inference. That can cut both ways: | |
std::vector<std::map<std::string, std::string>> my_vec; | |
// OUCH: | |
std::vector<std::map<std::string, std::string>>::iterator current = my_vec.begin(); | |
// Better, but still pretty verbose, and introduces a new name to grok. | |
typedef std::vector<std::map<std::string, std::string>> strmap_vec; | |
strmap_vec::iterator current = my_vec.begin(); | |
// C++11 makes this super nice: | |
auto current = my_vec.begin(); // GREAT! | |
// BUT 'auto' is not without its perils | |
auto val = (*current)["query"].second; // What is type of val? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment