#1
Is it possible to get binary_search to actually return an iterator instead of just true or false? The way various documentation explains it all it does is return true if the value is present. Well, thats kind of useless!
#2
If binary_search is useless... How can one do math on iterators! Example:
std::vector<movement>::iterator low;
std::vector<movement>::iterator middle;
std::vector<movement>::iterator high;
low = whatever.begin();
high = whatever.end() - 1;
while (low <= high ) {
// HERE IS THE REAL QUESTION!!! //
middle = (low + high) / 2; <== Does not work
}
How can you do math with iterators? To make your own binary_search it is required.
Also lower_bound and upper_bound are useless as they will not search an object for specific variables. std::distance (std::distance(low, high) will not work as it needs to be equal to ::difference_type - Which you cant do anything with afterwards.
DO you guys think there is anyway to solve this or is it a brick wall?