[libc-commits] [libc] [libc] Support C23 'b' (binary) modifier in printf (PR #80851)

via libc-commits libc-commits at lists.llvm.org
Tue Feb 6 09:56:53 PST 2024


================
@@ -33,14 +33,16 @@ using HexFmt = IntegerToString<uintmax_t, radix::Hex>;
 using HexFmtUppercase = IntegerToString<uintmax_t, radix::Hex::Uppercase>;
 using OctFmt = IntegerToString<uintmax_t, radix::Oct>;
 using DecFmt = IntegerToString<uintmax_t>;
+using BinFmt = IntegerToString<uintmax_t, radix::Bin>;
 
 LIBC_INLINE constexpr size_t num_buf_size() {
   constexpr auto max = [](size_t a, size_t b) -> size_t {
     return (a < b) ? b : a;
   };
   return max(HexFmt::buffer_size(),
----------------
michaelrj-google wrote:

nit: It would be nice to simplify this code. Since it's constexpr you could use a loop over a list here and it wouldn't effect the performance.

https://github.com/llvm/llvm-project/pull/80851


More information about the libc-commits mailing list