I have a sorted std::vector<unsigned long long int> myvector (and all values are different).
What is the shortest way to find the value of the first index size_t idx (not an iterator) of myvector strictly > to MAX_UI32 = 4294967295U.
For example :
[1, 34, 83495, 4294967295, 4294967296, 104000000000] -> idx = 4
[1, 34, 83495, 923834, 912834823, 4294967295] -> idx = 6 (= size of myvector)
How to achieve this in one line of code ?
Thank you very much.
A combination of
upper_boundanddistanceshould do the trick:If there is no such element,
upper_boundreturnsv.end(), so your result will equalv.size().