C++ Logo

SG16

Advanced search

Subject: Re: [SG16-Unicode] Draft: char8_t backward compatibility remediation paper
From: Tom Honermann (tom_at_[hidden])
Date: 2019-01-25 09:42:15


On 1/25/19 5:30 AM, Lyberta wrote:
> Tom Honermann:
>> I'm not following.  std::to_integer is (currently, unless I missed a
>> proposal) only overloaded to provide the value of a std::byte as an
>> integral type.  I don't understand the motivation here, nor the
>> association with the char8_t remediation paper.
>>
>> Tom.
>>
> This paper makes std::cout << u8'x' ill-formed. I suggest to use
> std::to_integer to make it well-formed again.

I see.  I don't think this is a good fit.  std::byte is not an integral
type, which is why std::to_integer is useful for obtaining an integral
value.  But char8_t (and char16_t and char32_t) are already integral
types (even if we don't always treat them as such).  Pointers (which I
suspect is what you intended the result of std::to_integer(u8"text") to
be) are definitely not integral types.  I think the use cases (if any)
for the prior behavior are such that explicit casts are sufficient; I
don't think we need any special support in the standard library for the
prior (unintended) behavior.

Tom.


SG16 list run by sg16-owner@lists.isocpp.org