copy_if

copy_if は C++ 標準には入っていないので自分で作らなければならない。

template<class InputIterator, class OutputIterator, class Predicate>
OutputIterator copy_if(InputIterator begin, InputIterator end, OutputIterator dest_begin, Predicate p)
{
	while( begin != end )
	{
		if( p( *begin ) ){ *dest_begin++ = *begin; }
		++begin;
	}
	return dest_begin;
}

Stroustrup が入れ忘れた。