There is new method of binary search which may be exist but I didn't see it.
Instead of using left and right, we can simply add new bit to our answer if it is possible:
while bit > 0:
if check(ans + bit):
ans += bit
bit /= 2
Constant will be much smaller.
You can do better: create a new template function with multiple parameters: left, right, a function that returns true/false.
=> you don't need to write binary search never again (except few cases).
Like this (pseudocode):
Why not c++20?