|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-09 18:22:57
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net