Tech Off Post

Single Post Permalink

View Thread: (STL) move_if algorithm, what's your take on it ?
  • User profile image

    I should explain what's wrong with your move_if():

    1. It requires forward iterators. copy_if() accepts input iterators.

    2. It writes into a container. copy_if() writes into an iterator, which is more general.

    3. It performs two passes, applying the predicate 2N times. copy_if() performs a single pass.

    4. It's not actually imitating copy_if(). It's imitating partition_copy(), which splits a source range into two output ranges (but not exactly, as partition_copy() prohibits input overlapping output).