[all-commits] [llvm/llvm-project] 9b43ae: [libc++][format] Implements LWG3892.

Mark de Wever via All-commits all-commits at lists.llvm.org
Sat Apr 8 05:12:21 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9b43aedeb311576ee9c99d7a6317b5f697954dd9
      https://github.com/llvm/llvm-project/commit/9b43aedeb311576ee9c99d7a6317b5f697954dd9
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2023-04-08 (Sat, 08 Apr 2023)

  Changed paths:
    M libcxx/docs/Status/Cxx2bIssues.csv
    M libcxx/include/__format/formatter_tuple.h
    M libcxx/include/__format/range_formatter.h
    M libcxx/test/std/utilities/format/format.range/format.range.fmtdef/format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h
    M libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.functions.tests.h
    M libcxx/test/std/utilities/format/format.range/format.range.fmtset/format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.format.pass.cpp
    M libcxx/test/std/utilities/format/format.range/format.range.formatter/format.functions.tests.h
    M libcxx/test/std/utilities/format/format.range/format.range.formatter/format.pass.cpp
    M libcxx/test/std/utilities/format/format.tuple/format.functions.format.pass.cpp
    M libcxx/test/std/utilities/format/format.tuple/format.functions.tests.h
    M libcxx/test/std/utilities/format/format.tuple/format.pass.cpp
    M libcxx/test/support/format.functions.common.h

  Log Message:
  -----------
  [libc++][format] Implements LWG3892.

This LWG issue is based on the discussion regarding

  P2733R3 Fix handling of empty specifiers in std::format

This paper was disussed and changed a few times in LEWG during the
Issaquah meeting. The paper was not voted in, instead LEWG asked for
a DR against C++26.

This LWG issue contains the direction voted by LEWG. This issue has not
been voted in yet. However it fixes some of the defencies on the
container based formatting. Without this fix the range-default-formatter
for strings looks bad when used in containers.

The changes of this issue match the intended changes of P27333.

type                      fmt     before     after (if changed)
---------------------------------------------------------------
char                      {}      a
char                      {:?}    'a'
array<char, 1>            {}      ['a']
array<char, 1>            {::}    [a]
array<char, 1>            {::c}   [a]
array<char, 1>            {::?}   ['a']
map<char, char>           {}      {a: a}     -> {'a': 'a'}
map<char, char>           {::}    {'a': 'a'}
set<char>                 {}      {'a'}
set<char>                 {::}    {a}
set<char>                 {::c}   {a}
set<char>                 {::?}   {'a'}
tuple<char>               {}      ('a')
stack<char>               {}      ['a']
stack<char>               {::}    [a]
stack<char>               {::c}   [a]
stack<char>               {::?}   ['a']
array<array<char, 1>, 1>  {}      [[a]]      -> {'a': 'a'}
array<array<char, 1>, 1>  {::}    [['a']]
array<array<char, 1>, 1>  {:::}   [[a]]
array<array<char, 1>, 1>  {:::c}  [[a]]
array<array<char, 1>, 1>  {:::?}  [['a']]
array<tuple<char>, 1>     {}      [(a)]      -> [('a')]
tuple<tuple<char>>        {}      ((a))      -> (('a'))
tuple<array<char, 1>>     {}      ([a])      -> (['a'])

Note the optimization text as mentioned in the tuple formatter can't be
done. The call to parse may affect the formatter so its state needs to
be preserved.

Reviewed By: ldionne, #libc, EricWF

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




More information about the All-commits mailing list