C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A better std::byte type

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Fri, 26 Jun 2026 16:13:57 +0200
Hi Thiago,

On 2026-06-26T07:10:30-0700, Thiago Macieira via Std-Proposals wrote:
> On Friday, 26 June 2026 01:15:23 Pacific Daylight Time Rune Lund Olesen wrote:
> > 2. In generic code, while you can actually bitshift a std::byte, it eg. acts
> > as an enumeration type and returns false with std::is_integral,
> > std::is_fundamental, and so on - highlighting a few issues with using it
> > with generic code 3. The idea to have a type to correctly represent "raw
> > data" is good - it is the design or implementation if you will, that is
> > lacking, and it should interop easier with other things (like conversions)
> > and work better in generic code - right now it it way too restrictive and
> > cumbersome, to the point it is prohibiting adoption.
>
> I believe the main roadblock to adoption is that unsigned char is still there
> and *is* the byte type.

The main problem with unsigned char is that it's also uint8_t, and it's
also char8_t. That makes it rather difficult to distinguish UTF-8
strings from short integers, and from raw bytes.


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es>

Received on 2026-06-26 14:14:08