The one thing that bothers me is that all of the std-equivalent functions are placed in the int128 namespace, which makes it harder to write generic code. Instead of this:
auto f(auto i) { return std::has_single_bit(i); }
I now have to write this instead:
auto f(auto i) { using namespace std; return has_single_bit(i); // use ADL }
This is annoying. I wish there was a function somewhere like this:
// not in some_namespace to prevent infinite recursion namespace some_namespace_detail {
auto impl_has_single_bit(auto i) { using namespace std; return has_single_bit(i); }
}
namespace some_namespace {
auto has_single_bit(auto i) { return some_namespace_detail::impl_has_single_bit(i); }
}
That way I could write my function like this, without using a using directive:
auto f(auto i) { return some_namespace::has_single_bit(i); }
However, that seems to be outside the scope of boost::int128.
Perhaps one day a proposal like P4188 (wg21.link/p4188) will allow us to do so inside of std. I agree it is rather annoying. Boost.Math has BOOST_MATH_STD_INCLUDE which expands to basically all of the cmath functions which is a bit better than having to write a bunch of using std::whatever; at the top of a function.
My verdict: ACCEPT unconditionally.
Thank you for the review Rainer! Matt