다음을 통해 공유


copy_if

In a range of elements, copies the elements that are true for the specified condition.

template<class InputIterator, class OutputIterator, class BinaryPredicate>
   OutputIterator copy_if(
      InputIterator _First, 
      InputIterator _Last,
      OutputIterator _Dest,
      Predicate _Pred
    );

매개 변수

  • _First
    An input iterator that indicates the start of a range to check for the condition.

  • _Last
    An input iterator that indicates the end of the range.

  • _Dest
    The output iterator that indicates the destination for the copied elements.

  • _Pred
    The condition against which every element in the range is tested. This condition is provided by a user-defined predicate function object. A predicate takes one argument and returns true or false.

반환 값

An output iterator that equals _Dest incremented once for each element that fulfills the condition. In other words, the return value minus _Dest equals the number of copied elements.

설명

The template function evaluates

if (_Pred(*_First + N))

*_Dest++ = *(_First + N))

once for each N in the range [0, _Last - _First), 가장 낮은 값에서 시작하는 N 의 엄격하게 증가하는 값입니다. 만약 _Dest 와 _First 저장소의 지역을 지정할 수 있다면, _Dest 은 [_First, _Last)의 범위가 아닙니다.

요구 사항

헤더: <algorithm>

네임스페이스: std

참고 항목

참조

표준 템플릿 라이브러리