r/cpp • u/eisenwave WG21 Member • Aug 18 '26
P4444: std::big_int
https://isocpp.org/files/papers/D4444R0.htmlHey folks! Matt Borland, Christopher Kormanyos, and I are working on bringing infinite-precision integers to C++29. We now have a D4444R0 draft of a paper that should be in the next mailing.
We could really use some feedback so that the published R0 is as polished as possible. Any thoughts on the paper and on the reference implementation are greatly appreciated.
It would also be very helpful if you tested out whether our big_int implementation works for you. We're in need of some real deployment experience. If you're currently using Boost.Multiprecision, the library should be a drop-in replacement for cpp_int for the most part.
View all comments
Show parent comment
2
u/eisenwave WG21 Member Aug 21 '26 edited Aug 21 '26
absis not entirely special. If negation returned a non-owning view, you could get a "negated view" of the samebig_int, andabsis one of the potential uses. However, I think it's more of an argument in favor of expression templates than in favor ofbig_int_viewbecause once we've "opened Pandora's box" of no longer returningbig_intfrom operations, we probably want to use that mechanic for a lot more things than justabs.Another consideration is that in your
abs(x) + func()example, you only suffer a copy ifxis immutable. Otherwise, you can useabs(std::move(x)), which calls the rvalue overload that merely flips the sign bit.If we ever were to standardize the "low-level operations on spans" as the paper discusses, you might also delegate to those rather than forming a view or needing expression templates, in those edge cases where the existing set of operations forces you into some overhead.
EDIT:
absand negation are still interesting points, and I've included them in https://isocpp.org/files/papers/D4444R0.html#std::big_int_view-is-just-not-useful-enough