C++ Logo

std-proposals

Advanced search

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

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Wed, 26 Jun 2019 10:35:43 -0400
On 25/06/2019 19.25, Zhihao Yuan wrote:
> On Tuesday, June 25, 2019 5:07 PM, Matthew Woehlke wrote:
>> {:0=6} → "-00123", "-00inf"
>> {:0=06} → "-00123", "-00inf"
>> {:=06} → "-00123", "- inf"
>> {:06} → "-00123", " -inf"
>>
>> The "quick" rule would be: "you didn't want to use '0' as the fill
>> character".
>
> Look, in your example, {:06}, and only {:06}, generates an output
> that can be parsed by strtod.
If your criteria for whether or not a feature should be allowed is
"produces output that can be parsed by strtod", then maybe you should
remove the ability to specify the fill character also:

  {:0>6} → "00-123", "000inf"
  {:0<6} → "-12300", "inf000"

> I feel doing evil if I'm adding more "rule of thumbs" to C++ since it
> already has too many.
Well... see above. Because you get that rule *whether or not* you keep
align==internal.

(Come to think of it, I bet compilers could be taught to warn when you
use a format that can't be round-tripped. But this would have to be an
optional warning, because I'll be surprised if folks don't sometimes do
that intentionally.)

-- 
Matthew

Received on 2019-06-26 09:37:36