STL name for the “map” functional programming function
I would like to be able to write something like
char f(char); vector<char> bar; vector<char> foo = map(f, bar);
transform function appears to be similar, but it will not autogenerate the size of the resultant collection.
You can use
<iterator>, although providing the size in front is more efficient. For example:
string str = "hello world!", result; transform(str.begin(), str.end(), back_inserter(result), ::toupper); // result == "HELLO WORLD!"