I have a vector of class objects sorted by its integer indices. But the object index is generated by a member function of the class - therefore no is int idstored as a member variable.
class boundary
{
public:
int get_id();
}
std::vector<boundary> sample;
Now I need to find the object boundarythat int id, generated get_id(), is the same as the int valueone I'm looking for.
auto &iter = binary_search(sample.begin(),sample.end(), 5, custom_function)
Is it possible to use binary_search in this case? How to achieve this?
source
share