 <p>I found this solution. But it's not very nice . </p> <pre><code>std::vector&lt;int&gt; list = {1,2,3,4}; std::vector&lt;int&gt; newList; std::for_each(list.begin(), list.end(),[&amp;newList](int val){newList.push_back(val*2);}); </code></pre>