boost::adaptors::unique

References

Headers

boost::adaptors::unique is available by including any of the following headers:

  • boost/range/adaptor/uniqued.hpp or
  • boost/range/adaptors.hpp

Examples

uniqued-function.cpp

#include <iostream>
#include <vector>

#include <boost/range/adaptors.hpp>

const std::string str = "f00f";


int main() {
    // Equal values are unified if they are adjacent. Equal values that are
    // separated by different elements are left untouched.
    std::cout << "Uniqued version of \"" << str << "\": "
              << (boost::adaptors::unique(str))
              << std::endl;

    return 0;
}

Output:

Uniqued version of "f00f": f0f

 

Boost Range for Humans

This reference is part of Boost Range for Humans. Click the link to the overview.