std::unique_copy
Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">
<td><algorithm>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td >ForwardIterator unique_copy( ForwardIterator first, ForwardIterator last,
<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td >ForwardIterator unique_copy( ForwardIterator first, ForwardIterator last,
<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end
Copies the elements from the range [first, last)
, to another range beginning at d_first
in such a way, that there are no consecutive equal elements. Only the first element of each group of equal elements is copied. The first version uses operator==
to compare the elements, the second version uses the given binary predicate p
.
Contents |
Parameters
first, last | - | the range of elements to process |
d_first | - | the beginning of the destination range |
p | - | binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following: bool pred(const Type1 &a, const Type2 &b); While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) |
Return value
output iterator to the element past the last written element
Equivalent function
Example
Complexity
linear in the distance between first
and last