I want to find the first item in a sorted vector that has a field less than some value x. I need to supply a compare function that compares \'x\' with the internal value
Pass a lambda function to upper_bound
float x; MyClass target; target.x_ = x; std::vector< MyClass >::iterator last = std::upper_bound(myClass.begin(),myClass.end(),target, [](const MyClass& a, const MyClass& b){return a.x_ < b.x_;});