user9196120
user9196120

Reputation: 411

std::equal_range() return value

According to cppreference.com

Return value

std::pair containing a pair of iterators defining the wanted range, the first pointing to the first element that is not less than value and the second pointing to the first element greater than value. If there are no elements not less than value, last is returned as the first element. Similarly if there are no elements greater than value, last is returned as the second element.

As per the bold text, is it correct to assume the following?

auto p = equal_range(map.begin(), map.end(), value);

if(p.first && p.second){//there is a valid range}

else{//there is no valid range}

Upvotes: 0

Views: 742

Answers (0)

Related Questions