C++ Logo


Advanced search

Re: Internal fill *not* considered harmful (re: P1652)

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Tue, 25 Jun 2019 15:20:17 -0400
On 25/06/2019 13.32, Zhihao Yuan via Std-Proposals wrote:
> On Tuesday, June 25, 2019 10:48 AM, Matthew Woehlke wrote:
>> [...] fill and arithmetic zero-padding
>> aren't precisely the same thing and shouldn't be conflated. In
>> particular, IMHO the following would be correct behavior:
>> std::string s2 = std::format("{:*<06}", 123); // s2 == "000123"
>> std::string s2 = std::format("{:*<06}", nan); // s2 == "***nan"
> Your proposed behavior shows that they
> conflate, while I agree that they shouldn't.

I'm suggesting that they are, and should be, orthogonal. The above shows
that zero-padding happens first, and may effectively supersede regular
fill, but that regular fill can *also* occur.


  std::string s1 = std::format("{:^07}", 123); // s1 == "0000123"
  std::string s2 = std::format("{:^07}", nan); // s2 == " nan "

>> [...] I hope folks will consider fixing this feature rather than
>> nuking it entirely because a related feature was (mis)specified in
>> terms of it.
> You seem to suggest that the "internal" fill
> is a feature that is independent from arithmetic
> zero-padding. That is not the case.

As currently specified, that is correct. I'm suggesting that the
specification should be changed so that they *are* independent. This
would also solve the problem noted in P1652, but without needing to
remove a feature to do so.

> Here is a copy of the paper proposed Iostreams [...]

I don't care what iostreams does. I'm suggesting that format should do
the sensible thing. I think we agree that some of iostreams' behavior is


Received on 2019-06-25 14:22:09