title: Is it possible to initialize a vector from the keys in a map?
body: <p><a href="https://stackoverflow.com/questions/110157/how-to-retrieve-all-keys-or-values-from-a-stdmap">How to retrieve all keys (or values) from a std::map and put them into a vector?</a> covers the ways to populate a std::vector from the keys in a map pre-C++11.</p>
  
  <p>Is there a way to do this in C++11 using lambdas, etc, that means we can do it in one line so we can initialize the vector from the map instead of create a vector and populate it in 2 actions?</p>
  
  <p>e.g. <code>vector&lt;int&gt; v(???(m.begin(),m.end()));</code></p>
  
  <p>Pure C++11 is preferred but boost is acceptable... the aim is to do this in one line without it being overly complicated and "showing off", so it's not confusing to other developers.</p>
  
  <p>For comparison the "obvious" C++11 solution is:</p>
  
  <pre><code>vector&lt;int&gt; v;
  v.reserve(m.size()); //not always needed
  for(auto &amp;x : map)
    v.push_back(x.first)
  </code></pre>