boostorg / multiprecision

Boost.Multiprecision
Boost Software License 1.0
194 stars 111 forks source link

Add support for std::format. #535

Open jzmaddock opened 1 year ago

jzmaddock commented 1 year ago

This is a tentative first step towards supporting C++20's std::format.

Integers are all working and feature complete other than the usual undiscovered bugs and corner cases.

Other number types will require some refactoring of the code in format.hpp, though exactly how/what remains to be seen.

This also ties in with https://github.com/boostorg/multiprecision/issues/297 as it adds binary string formatting.

Currently only latest msvc supports <format>, for gcc we will have to wait for gcc-13 later in the year, likewise clang/libc++.

Comments welcome as always.

DouisLavid commented 6 months ago

Hello, Thanks for the awesome work in Boost.Math :) I was wondering if there was any plan to merge this PR in the foreseeable future, as it is a feature that would be quite useful for me. If not, would you say that there is any reason that would make me not want to use your changes locally ? (I'm ok with the "usual undiscovered bugs and corner cases" as nothing display related is critical in my use case, and i'm ok with breaking changes when the feature gets officially supported in the future)

jzmaddock commented 6 months ago

Please do go ahead and use this and report back: we need to revisit this now that latest GCC supports std::format and finish this support off.