I've got a map declared as:
std::map< std::pair<int, int>, bool > allPositions; // essentially, keys are just 2D points
I need to get the range of its elements whose values are true
Using std::equal_range
auto range = std::equal_range(allPositions.begin(), allPositions.end(), true);
Gives these errors
Error C2672 'operator __surrogate_func': no matching overloaded function found xutility
Error C2893 Failed to specialize function template 'unknown-type std::less::operator ()(_Ty1 &&,_Ty2 &&) const' xutility
Error C2056 illegal expression xutility
Error C2672 'operator __surrogate_func': no matching overloaded function found algorithm
Error C2893 Failed to specialize function template 'unknown-type std::less::operator ()(_Ty1 &&,_Ty2 &&) const' algorithm
I think I don't need predicate function here because std::pair has got overloaded operator < otherwise map code wouldn't have been compiled
So how to use std::equal_range for map to get range of pairs with equal values ?
trueis not by default comparable tostd::pair<std::pair<int,int>,bool>. - Altainiamap:equal_rangeen.cppreference.com/w/cpp/container/map/equal_range - user2487382std::mapwill not give you range based on values. - Slava