fmt icon indicating copy to clipboard operation
fmt copied to clipboard

Add support for _BitInt on clang

Open Arghnews opened this issue 1 year ago • 4 comments

Issue #4007

Only enabled for clang >= 14 as that's all that supports _BitInt at the moment

We need a forwarding reference for map to be a "more specialized" match; const T&, T etc. are ambiguous.

I'm not too familiar, would there be a better way to do this by adding an entry into enum class type for _BitInts? Or this is fine?


Fyi this worked in version 9 because of this catch-all overload:

https://github.com/fmtlib/fmt/blob/a33701196adfad74917046096bf5a2aa0ab0bb50/include/fmt/core.h#L1506-L1516

Which was then subsequently narrowed down to extended FP types (which "broke" the accidental support for this):

https://github.com/fmtlib/fmt/blob/6a192f8d34cbca3bf6a06575d8f159043d8c7f79/include/fmt/base.h#L1527-L1537

Arghnews avatar Jul 13 '24 18:07 Arghnews

@Arghnews, do you plan to update this PR or shall we close it for now (can be reopened later)?

vitaut avatar Jul 27 '24 18:07 vitaut

@Arghnews, do you plan to update this PR or shall we close it for now (can be reopened later)?

@vitaut Hi, sorry been busy and now I'm on holiday for 2 weeks, but will update once back and implement your feedback. I'd say leave it open and I'll update in 2-3 weeks, but it's up to you (can reopen of course). Cheers!

Arghnews avatar Jul 27 '24 22:07 Arghnews

No hurry. Let's keep it open and enjoy your holiday!

vitaut avatar Jul 27 '24 23:07 vitaut

Hi,

Reworked this so that now fmtlib will format _BitInts up to 128 bits

Uses wider formatter ie. integer types are widened to 64bit if <= 64 bits wide (assume this is acceptable for performance) If FMT_USE_INT128 then supports up to 128 bits

Can't write static_assert(fmt::is_formattable<signed_bitint<129>, char>{}, ""); as apple clang only allows up to 128 bits. BITINT_MAXWIDTH isn't defined, could check __apple_build_version__ but I just removed this test

Let me know any feedback @vitaut

Arghnews avatar Aug 26 '24 14:08 Arghnews

Merged, thanks!

vitaut avatar Aug 29 '24 01:08 vitaut