Regarding lower_bound in c++

Revision en1, by Sportsman, 2020-08-03 16:15:35

We all know that we can also use sort function for a specific portion of a vector. Eg: let a vector be v = {24, 11, 5, 7, 6} , now if we want to sort only last three elements, we can write sort(v.begin()+2,v.end()) Likewise, I thought we can also use lower_bound(v.begin()+2,v.end(),6) to find the lower_bound for 6 in the last three elements. But that's not working. May i please know where I'm going wrong . It seems the lower_bound and upper_bound functions only work for the whole vector despite our attempts & wants. Please correct me if I'm wrong.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Sportsman 2020-08-03 16:15:35 601 Initial revision (published)