Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Function template unique



// In header: <boost/move/algo/unique.hpp>

template<typename ForwardIterator, typename BinaryPredicate> 
  unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);


Requires: The comparison function shall be an equivalence relation. The type of *first shall satisfy the MoveAssignable requirements

Effects: For a nonempty range, eliminates all but the first element from every consecutive group of equivalent elements referred to by the iterator i in the range [first + 1, last) for which the following conditions hold: pred(*(i - 1), *i) != false.

Returns: The end of the resulting range.

Complexity: For nonempty ranges, exactly (last - first) - 1 applications of the corresponding predicate.