int arr[] = {0, 1, 15, 22, 100, 101, 232, 2323};
int n = sizeof(arr) / sizeof(arr[0]);
int x = 232;
auto a = lower_bound(arr, arr + n, x) - arr;
if (a < n && arr[a] == x) {
// x found at index a
cout << x << " is found " << "at index: " << a << endl;
}
lower_bound returns an address of the element but if we subtract - arr from it, it dereferences the pointer. How come that happens?