C++ Logo

std-discussion

Advanced search

Re: reading values as bytes without memcpu, from enum unsigned char?

From: Jason Cobb <jason.e.cobb_at_[hidden]>
Date: Fri, 7 Aug 2020 12:11:18 -0400
On 8/7/20 12:06 PM, Roman Babinicz via Std-Discussion wrote:
> I think we should have a DR about the rules being unclear, and there
> should be such example with such explanations added there, regarding
> this access.
>
> For C++14 and higher standards.
>
> Any thoughts on making this happen?
>
> As a separate note, allowing the exception with enum of underlying type,
> would allow people to write custom std::byte in C++14 (possible also in
> other places of standard where std::byte is mentioned as blessed type)


AFAIK DRs can only be applied to the most recently published standard.
C++14 and previous are withdrawn, and 17 will be withdrawn when 20 is
published.

Second, the goal of having std::byte be blessed is to have it be a
marker for raw memory. If the standard were to bless all such enums, it
would inhibit optimizations the same way that char*s do now.

-- 
Jason Cobb

Received on 2020-08-07 11:14:42