...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::algorithm::copy_if_until — Copies all the elements from the input range that satisfy the copy predicate to the output range until the termination predicate is satisfied.
// In header: <boost/algorithm/cxx11/copy_if.hpp> template<typename Range, typename OutputIterator, typename CopyPredicate, typename TerminatePred> BOOST_CXX14_CONSTEXPR std::pair< typename boost::range_iterator< const Range >::type, OutputIterator > copy_if_until(const Range & r, OutputIterator result, CopyPredicate copy_pred, TerminatePred term_pred);