auto res = *ranges::partition_point(views::iota(lo, hi), check);
this returns the first $$$x$$$ in the range $$$[lo, hi)$$$ such that check(x)
is not true, or $$$hi$$$ if it doesn't exist. Be careful to make sure the $$$lo$$$ and $$$hi$$$ are both integers of the same type, otherwise there is weird behavior.
example usage: 284450329
well known
I didn't know it and am thankful for the blog poster sharing it :O
It might be convenient for some of us,but not necessary.In fact,a simple binary search is easy to write.
Is this also applicable when $$$hi$$$ is 1e18 ?
You can use 1e18, too, when both
lo
andhi
are of the same type.