[libcxx-commits] [PATCH] D128785: [libc++][format] Improve floating-point formatters.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 29 12:30:59 PDT 2022

Mordante created this revision.
Herald added a project: All.
Mordante updated this revision to Diff 441077.
Mordante added a comment.
Mordante published this revision for review.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Fixes CI and fixes some potential ADL issues.

Comment at: libcxx/include/__format/formatter_floating_point.h:424
+/// Fills the buffer with the data based on the requested formatting.
Moved from line 642.

Comment at: libcxx/include/__format/formatter_floating_point.h:570
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(
Moved from line 609.

Comment at: libcxx/include/__format/formatter_output.h:225
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
Copied from `__format/formatter.h`:194

This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 <https://reviews.llvm.org/P2286> adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606 <https://reviews.llvm.org/D125606>. That commit did the groundwork and did similar
changes for the string formatters.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128785.441077.patch
Type: text/x-patch
Size: 52370 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220629/570f03cb/attachment-0001.bin>

More information about the libcxx-commits mailing list