Adapt > Engage > Dominate

An interesting tidbit of info I discovered recently was that std::for_each does not actually return the value object of the <key, value> map pair.  I had assumed (/laugh) that it did, similar to how, say, a vector’s object is passed to you to do something with.  In other words, I assumed it sent only the value of the map pair.  As you might expect by now, though, it returns a pair object of the same type stored in the map.  So if you’re working on the value part, you would use the object.second syntax and, likewise, object.first for playing around with the keys.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: