Standard C++ Library Reference ISO/IEC (VERSION3)

The first template function effectively assigns first to X, then executes the statement:
if (N == 0)
++X;
else if (!(*X == *(first + N)))
*X++ = V;
once for each N in the range [0, last - first). It then returns X. Thus, the function
repeatedly removes from the resulting sequence the second of a pair of elements for which the
predicate *(first + N) == *(first + N + 1) is true, until only the first of a
sequence of elements survives that satisfies the comparison. Here, operator== must perform
a pairwise comparison between its operands. It does so without altering the relative order of
remaining elements, and returns the iterator value that designates the end of the resulting
sequence. For a non-empty sequence, the function evaluates the predicate last - first -
1 times.
The second template function behaves the same, except that it executes the statement:
if (N == 0)
++X;
else if (!pred(*X, *(first + N)))
*X++ = V;
Note that for a sequence designated by the range [first, last) and ordered by pred, you
can remove all but the first of a sequence of elements that have equivalent ordering by calling
unique(first, last, not2(pred)).
unique_copy
template<class InIt, class OutIt>
OutIt unique_copy(InIt first, InIt last, OutIt dest);
template<class InIt, class OutIt, class Pr>
OutIt unique_copy(InIt first, InIt last, OutIt dest,
Pr pred);
The first template function effectively executes the statement:
if (N == 0 || !(*(first + N) == V))
V = *(first + N), *dest++ = V;
once for each N in the range [0, last - first). It then returns dest. Thus, the function
repeatedly removes from the resulting sequence the second of a pair of elements for which the
predicate *(first + N) == *(first + N - 1) is true, until only the first of a
sequence of equal elements survives. Here, operator== must perform a pairwise comparison
between its operands. It does so without altering the relative order of remaining elements, and
returns the iterator value that designates the end of the copied sequence. For a non-empty
sequence, the function evaluates the predicate last - first - 1 times.