Is there any specific reason for not having std::copy_if algorithm in C++ ? I know I can use std::remove_copy_if to achieve the required behavior. I think it is coming in C++0x, but a simple copy_if which takes a range, a output iterator and a functor would have been nice. Was it just simply missed out or is there some other reason behind it?
According to Stroustrup's "The C++ Programming Language" it was just an over-sight.
(as a citation, the same question answered in boost mail-lists: copy_if)
Stroustrup says they forgot it. It's in C++11.
However, you can use remove_copy_if
(which really should be called copy_if_not
) along with not1
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With