C++ Logo

sg16

Advanced search

Re: Follow up on SG16 review of P2996R2 (Reflection for C++26)

From: Tom Honermann <tom_at_[hidden]>
Date: Sat, 4 May 2024 00:46:36 -0400
On 5/3/24 8:49 PM, Peter Dimov wrote:
> Tom Honermann wrote:
>> Characters should be handled as well as strings:
>>
>>
>> template<class charT, class traits>
>> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&
>> out, char8_t);
>> template<class charT, class traits>
>> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&
>> out, char16_t);
>> template<class charT, class traits>
>> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&
>> out, char32_t);
> I don't think the first one of these makes any sense. It's not possible to transcode
> a char8_t on its own.

It is if it is an ASCII character. Differentiating ASCII vs whatever the
ordinary literal encoding is is why u8'x' was added in C++17. If we
support this:

std::cout << u8"x";

then we should also support:

std::cout << u8'x';

>
> char32_t can work. char16_t is borderline if we don't go outside the BMP.

Likewise for u'x', u'\u1234', etc...

Tom.

>
> I wouldn't shed any tears if we just disallow all three for consistency.
>
>

Received on 2024-05-04 04:46:38