I'm writing wrapper functions for some of the functions in <algorithm>
.
While the following works perfectly, I'm not sure if this is the best way to approach it:
template<class ContainerType, class Predicate>
ContainerType filter(
const ContainerType& container,
Predicate predicate
) {
ContainerType filteredContainer;
std::remove_copy_if(
container.begin(),
container.end(),
std::back_inserter(filteredContainer),
predicate
);
return filteredContainer;
Would you change something about the wrapper? I'm especially worried about the template parameters, e.g. you'll have to read the entire function in order to know what types are valid for predicate
etc.