Why there is no std::copy_if algorithm?


Question

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?

1
63
9/19/2009 3:53:37 PM

Accepted Answer

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)

41
9/19/2009 4:06:53 PM

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.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon