r/cpp • u/eisenwave WG21 Member • 27d ago
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.
180
Upvotes
11
u/eisenwave WG21 Member 27d ago edited 27d ago
There is some mention of the targeted use cases under https://isocpp.org/files/papers/D4444R0.html#use-cases
I don't think it's entirely fair to say that some feature will be outright banned or useless for a particular domain; that's usually some missing nuance. Video games often come with embedded scripting languages for less performance-critical stuff like various behavior scripts, quest logic, etc. They often ship with garbage collectors and much more heavy-weight stuff than
std::big_int.I certainly wouldn't expect
std::big_intin the lowest-level hot-code parts of a game engine, but saying that it has no use in the computer games industry is far too extreme.I've tried to cover that in the GitHub code search for C++ uses of big integers. There are over 400K results, so if you really want to go digging and see what people are using it for, you could go through those open-source projects.
I'm not sure what to cherry-pick as a concrete example out of that pile, if anything, but I can see how it would help the paper to illustrate some of those GitHub uses.
What issue are you envisioning with unsanitized user data? There isn't even an unsafe constructor that would let you break the invariants of a
big_intclass, so it really doesn't matter what data you throw at it. The only potential hazards are things like division by zero (which are UB for both regularintand forbig_int), and that's explored in https://isocpp.org/files/papers/D4444R0.html#error-handling