vendredi 3 juillet 2015

c++11 collection `insert` with a lambda map

It is kind of exasperating that std collections don't provide a functional map interface to fill a collection

std::vector< int > oldV = {1,3,5};
std::vector< int > newV = (oldV % [&](int v)-> int{ return v+1; });
newV.insert( oldV.begin(), oldV.end(), [&](int v)-> int{ return 2*v; });

Is there a simple header library that implements wrappers for functional style programming with std collections?

Aucun commentaire:

Enregistrer un commentaire