I\'m looking for practical and educational samples of C++ / STL code fitting in few lines. My actual favorites are:
Empty a vector freeing its reserved memory:<
For your second example use the value type:
#
Copy a map to a vector: typedef map MyMap; MyMap myMap; vector< MyMap::value_type > myVec(myMap.begin(), myMap.end());