C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: std::format: Can't use a flag for floating-point and get the default format
From: Thiago Macieira (thiago_at_[hidden])
Date: 2021-02-06 19:29:09


On Saturday, 6 February 2021 10:16:08 PST Rob Lefebvre via Std-Discussion
wrote:
> g: If precision is specified, produces the output as if by calling
> std::to_chars(first, last, value, std::chars_format::general,
> precision)<https://en.cppreference.com/w/cpp/utility/to_chars> where
> precision is the specified precision; otherwise, the output is produced as
> if by calling std::to_chars(first, last,
> value)<https://en.cppreference.com/w/cpp/utility/to_chars>.
>
> none: same as g.

> Con: This breaks tradition with printf. It is also technically a breaking
> change to the C++20 spec, but since no vendor has yet created std::format,
> "breaking change" isn't as meaningful.

As you said, this breaks with printf. Since the precision is useful for C
coders too, can we approach WG14 and agree on the solution? I doubt it'll be
changing formatter "g".

> Possibility #2: Add a new type z and change none:

Similarly, "z" is used as a size modifier in printf, so it isn't likely to be
accepted.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups