My formal review of int128

Rainer Deyke via Boost <[email protected]> Mon, 27 Jul 2026 20:01:10 +0200
Newsgroups gmane.comp.lib.boost.devel
Message-ID <[email protected]>
Here is my formal review of the proposed int128 library.

There's not really much to review.  It's a portable int128_t type that 
somehow manages to outperform native __int128.  Assuming that the 
implementation makes good on the promises in the documentation (and I 
have no reason to suspect that it doesn't), there is barely any room for 
criticism.

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.


On 7/22/26 13:37, Arnaud Becheler via Boost wrote:
> Other questions you might want to answer in your review are:
>    - What is your evaluation of the design?

I see no room for criticism.  Aside from the basic (u)int128_t types, 
the library seems to offer everything needed for interoperability, up to 
the limits of the language itself.

>    - What is your evaluation of the implementation?

I haven't looked at the source code, but if the benchmarks are correct, 
then I am impressed.

>    - What is your evaluation of the documentation?

Readable, well organized, and it looks both complete and correct.  I see 
no room for criticism.

>    - What is your evaluation of the potential usefulness of the library?

Fairly useful, and definitely worth having.  While I found myself 
wishing for a good (ideally native) 128 bit integer type from time to 
time, I can't say that I ever really needed one.

>    - Did you try to use the library?

No.

>    - How much effort did you put into your evaluation? A glance? A quick
> reading? In-depth study?

Maybe an hour of work, most of it spent browsing the documentation.

>    - Are you knowledgeable about the problems tackled by the library?

Yes.


My verdict: ACCEPT unconditionally.


-- 
Rainer Deyke - [email protected]

_______________________________________________
Boost mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.boost.org/mailman3/lists/boost.lists.boost.org/
Archived at: https://lists.boost.org/archives/list/[email protected]/message/XFWNFYNRRKRLJSUOFS4F6NURMSTYJL7Q/