remove_copy_if adapted as copy_if

Can anyone with advanced template-fu show me to an adaptation of remove_copy_if to be copy_if ? I do realize you just have to negate the predicate parameter of remove_copy_if. I would prefer to use a function that does that automatically, since the code would be easier for my co-workers to follow. thanks pj

AMDG PJ Durai wrote:
Can anyone with advanced template-fu show me to an adaptation of remove_copy_if to be copy_if ?
I do realize you just have to negate the predicate parameter of remove_copy_if.
I would prefer to use a function that does that automatically, since the code would be easier for my co-workers to follow.
thanks pj
template<class InIt, class OutIt, class Pred> OutIt copy_if(IntIt begin, InIt end, OutIt out, Pred pred) { for(; begin != end; ++begin) { typename std::iterator_traits<InIt>::reference element(*begin); if(pred(element)) *out = element; } } In Christ, Steven Watanabe
participants (2)
-
PJ Durai
-
Steven Watanabe