unique_copy function template — Copies unique values
template<typename InIter, typename OutIter> OutIter unique_copy(InIter first, InIter last, OutIter result); template<typename InIter, typename OutIter, typename BinaryPredicate> OutIter unique_copy(InIter first, InIter last, OutIter result, BinaryPredicate pred);
The unique_copy
function
template copies items from [first
, last
) to the range that starts at result
, removing duplicates. For each
sequence of identical elements, only the first is kept. The return
value is one past the end of the result range.
The first form compares items with the ==
operator. The second form calls
pred(a
, b)
.
See Figure 13-21
for an example that calls unique_copy
.