Last active
October 13, 2015 00:54
-
-
Save thiagomg/8f910117dcbc4461a7e0 to your computer and use it in GitHub Desktop.
Range loops - Writing safe
This file contains 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
//First possibility | |
for(auto it = msgs.cbegin(); it != msgs.cend(); it++) { | |
PublishMessage(*it); | |
} | |
//Second possibility | |
for(const auto &msg : msgs) { | |
PublishMessage(msg); | |
} | |
//Thrird possibility | |
for_each(begin(msgs), end(msgs), [](const auto &msg) { | |
PublishMessage(msg); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment