#include #include #include #include struct greater_by_two { template bool operator()(const T& left, const T& right) const { return left / 2 == right / 2; } }; int main() { std::vector v(10); std::iota(v.begin(), v.end(), 0); assert(boost::unique(v, greater_by_two()).size() == 5); }