[all-commits] [llvm/llvm-project] d7444d: [libc++][format] Implement formatters.

mordante via All-commits all-commits at lists.llvm.org
Sat Sep 4 02:41:36 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d7444d9f41e34886d7d316659090ba6bf4d61cba
      https://github.com/llvm/llvm-project/commit/d7444d9f41e34886d7d316659090ba6bf4d61cba
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2021-09-04 (Sat, 04 Sep 2021)

  Changed paths:
    M libcxx/docs/ReleaseNotes.rst
    M libcxx/include/CMakeLists.txt
    A libcxx/include/__format/format_string.h
    A libcxx/include/__format/formatter.h
    M libcxx/include/format
    M libcxx/include/module.modulemap
    A libcxx/test/libcxx/diagnostics/detail.headers/format/format_string.module.verify.cpp
    A libcxx/test/libcxx/diagnostics/detail.headers/format/formatter.module.verify.cpp
    A libcxx/test/libcxx/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp
    A libcxx/test/libcxx/utilities/format/format.arguments/format.args/get.pass.cpp
    M libcxx/test/std/utilities/format/format.arguments/format.arg/operator_bool.pass.cpp
    R libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp
    R libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.bool.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.c_string.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.char.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.const_char_array.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.floating_point.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.signed_integral.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.string.pass.cpp
    A libcxx/test/std/utilities/format/format.formatter/format.context/format.formatter.spec/formatter.unsigned_integral.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format_tests.h
    A libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
    A libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp

  Log Message:
  -----------
  [libc++][format] Implement formatters.

This implements the initial version of the `std::formatter` class and its specializations. It also implements the following formatting functions:
- `format`
- `vformat`
- `format_to`
- `vformat_to`
- `format_to_n`
- `formatted_size`

All functions have a `char` and `wchar_t` version. Parsing the format-spec and
using the parsed format-spec hasn't been implemented. The code isn't optimized,
neither for speed, nor for size.

The goal is to have the rudimentary basics working, which can be used as a
basis to improve upon. The formatters used in this commit are simple stubs that
will be replaced by real formatters in later commits.

The formatters that are slated to be replaced in this patch series don't have
an availability macro to avoid merge conflicts.

Note the formatter for `bool` uses `0` and `1` instead of "false" and
"true". This will be fixed when the stub is replaced with a real
formatter.

Implements parts of:
- P0645 Text Formatting

Completes:
- LWG3539 format_to must not copy models of output_iterator<const charT&>

Reviewed By: ldionne, #libc, vitaut

Differential Revision: https://reviews.llvm.org/D96664




More information about the All-commits mailing list