unique

template<class FwdIt>
    FwdIt unique(FwdIt first, FwdIt last);
template<class FwdIt, class Pred>
    FwdIt unique(FwdIt first, FwdIt last, Pred pr);

The first template function effectively assigns first to X, then executes the statement:

if (N == 0 || !(*(first + N) == V))
    V = *(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 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. It does so without altering the relative order of remaining elements, and returns the iterator value that designates the end of the revised sequence. The function evaluates the predicate last - first times, at most.

The second template function behaves the same, except that it executes the statement:

if (N == 0 || !pr(*(first + N), V))
    V = *(first + N), *X++ = V;