Check out example codes for "upper bound in c++". It will help you in understanding the concepts better.

Code Example 1

// ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const T& val, Compare comp);
std::vector<int>::iterator upper1, upper2; 
  
    // std :: upper_bound 
    upper1 = std::upper_bound(v.begin(), v.end(), 35); 
    upper2 = std::upper_bound(v.begin(), v.end(), 45); 
  
    std::cout << "\nupper_bound for element 35 is at position : " 
              << (upper1 - v.begin()); 
    std::cout << "\nupper_bound for element 45 is at position : "
              << (upper2 - v.begin());

Learn ReactJs, React Native from akashmittal.com