std::remove_copy() algorithm
- od C++20
- od C++17
- do C++17
// (1)
template< class InputIt, class OutputIt, class T >
constexpr OutputIt remove_copy( InputIt first, InputIt last,
OutputIt d_first, const T& value );
// (2)
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T >
ForwardIt2 remove_copy( ExecutionPolicy&& policy,
ForwardIt1 first, ForwardIt1 last,
ForwardIt2 d_first, const T& value );
// (1)
template< class InputIt, class OutputIt, class T >
OutputIt remove_copy( InputIt first, InputIt last,
OutputIt d_first, const T& value );
// (2)
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T >
ForwardIt2 remove_copy( ExecutionPolicy&& policy,
ForwardIt1 first, ForwardIt1 last,
ForwardIt2 d_first, const T& value );
// (1)
template< class InputIt, class OutputIt, class T >
OutputIt remove_copy( InputIt first, InputIt last,
OutputIt d_first, const T& value );
-
(1) Copies elements from the range [
first;last), to another range beginning atd_first, omitting the elements equal tovalue. -
(2) Same as (1), but executed according to
policy.Overload ResolutionThese overloads participate in overload resolution only if
std::is_execution_policy_v<std::decay_t<ExecutionPolicy>>(do C++20)std::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>>(od C++20) istrue.
If source and destination ranges overlap, the behavior is undefined
.Parameters
first last | The range of elements to copy. |
d_first | The beginning of the destination range. |
value | The value of the elements not to copy. |
policy | The execution policy to use. See execution policy for details. |
Type requirements
InputIt | LegacyInputIterator |
OutputIt | LegacyOutputIterator |
ForwardIt1 ForwardIt2 | LegacyForwardIterator |
Return value
Iterator to the element past the last element copied.
Complexity
Given N as std::distance(first, last):
Exactly N comparisons with value using operator==.
For the overloads with an ExecutionPolicy, there may be a performance cost if ForwardIt1's value_type is not MoveConstructible.