C++ binary search implementation