C++ Logo

std-proposals

Advanced search

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

From: Zhihao Yuan <zy_at_[hidden]>
Date: Fri, 26 Jun 2026 18:29:53 +0000
On Friday, June 26th, 2026 at 4:59 AM, Alejandro Colomar via Std-Proposals <std-proposals_at_[hidden]> wrote:

>

> If the new _Byte* had implicit conversions like void*, [...]
>

> And _Byte* would be the type to implement memcpy(3):
>


Conversion or not, I think this capability is enlightening.

> _Byte *
> memcpy(size_t n;
> _Byte dst[restrict n], const _Byte src[restrict n], size_t n)
> {
> for (size_t i = 0; i < n; i++)
> dst[i] = src[i];
> return dst;
> }
>

> Which would differ from void* in that it can be used to access memory,
> write to it, and do pointer arithmetic.
>

> Once n3674 is merged in C (and WG14 has already shown strong interest in
> it; we're just waiting for minor improvements to the proposal), type
> compatibility issues would entirely vanish.
>

> The remaining issue would be removing the "aliasing superpowers" from
> the character types. This is the part that will take decades. But I
> expect compilers could provide flags so that programs can already opt
> in to such semantics, declaring that they never alias anything with
> character types. Eventually, this might change to be the default, maybe
> in C5x or so, which would be nice.
>

>


--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2026-06-26 18:30:02