C++ implementations of map, filter, reduce