Topic: Improved std::byte


Author: Ray Hamel <rayghamel@gmail.com>
Date: Thu, 4 Oct 2018 13:44:35 -0700 (PDT)
Raw View
------=_Part_531_638859117.1538685875097
Content-Type: multipart/alternative;
 boundary="----=_Part_532_1802197200.1538685875099"

------=_Part_532_1802197200.1538685875099
Content-Type: text/plain; charset="UTF-8"

Currently std::byte is declared as

enum class byte : unsigned char;

template<Integral T> constexpr T to_integer(byte) noexcept;

constexpr byte operator~(byte) noexcept;

constexpr byte operator|(byte, byte) noexcept;
constexpr byte operator&(byte, byte) noexcept;
constexpr byte operator^(byte, byte) noexcept;

constexpr byte &operator|=(byte&, byte) noexcept;
constexpr byte &operator&=(byte&, byte) noexcept;
constexpr byte &operator^=(byte&, byte) noexcept;

template<Integral T> constexpr byte operator<<(byte, T) noexcept;
template<Integral T> constexpr byte operator>>(byte, T) noexcept;

template<Integral T> constexpr byte &operator<<=(byte&, T) noexcept;
template<Integral T> constexpr byte &operator>>=(byte&, T) noexcept;

However, the additional type safety it affords over char and friends also
causes many to find it too cumbersome and verbose
<https://monoinfinito.wordpress.com/2018/10/02/stdbyte-great-idea-horrible-execution/>
to use as a vocabulary type.

Given that C-style type punning with unions is now officially well-defined
according to the C++ standard, I propose that the declaration of std::byte
be changed to

union byte {
        unsigned char u;
        signed char i;
        char c;

        template<Integral T> explicit constexpr operator T() const noexcept;
};

// same as above

This would maintain its current type safety while also providing a
non-verbose way to interact with literal integers and existing code using
char and friends.

This would, AFAICT, be a source-compatible change except for code that
refers to it as enum std::byte

std::byte foo{55}; // OK
enum std::byte bar{55}; // compilation error

I don't think that would break much real-world code.

This would also, AFAICT, be an ABI-compatible change for the Itanium ABI.

- Ray

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/dc1cb435-1d6e-4cb8-b148-221d8b3e4f2b%40isocpp.org.

------=_Part_532_1802197200.1538685875099
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Currently <span style=3D"font-family: courier new, mo=
nospace;">std::byte</span> is declared as<br></div><div><br></div><div><div=
 style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" =
class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #008;" class=3D"styled-by-prettify">enum</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">byte</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>unsigned</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Integral</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> T to_integer</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">byte</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> noexc=
ept</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">~(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">byte</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> noexcept</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">con=
stexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">byte</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">|(</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">byte</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 noexcept</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&amp;(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">byte</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">byte</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> noexcept=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">^(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">byte</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">byte</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> noexcept</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">byte</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">operator</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">|=3D(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">byte</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">byte</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> noexcept</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">byte</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&amp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">op=
erator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp=
;=3D(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">byte<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">byte</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> noexcept</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">byte</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&amp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">opera=
tor</span><span style=3D"color: #660;" class=3D"styled-by-prettify">^=3D(</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">byte</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;,</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> noexcept</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Integral</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;&lt;(</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">byte</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
noexcept</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Integral</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">byte</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;&gt;(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">byt=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> noexcept</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">Integral</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const=
expr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">byte</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;&lt;=3D(</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">byte</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&amp;,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> noexcept</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
emplate</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt=
;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Integral<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">byte</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&amp;</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&gt;&gt;=3D(</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">byte</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&amp;,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> noexcept</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></=
div></div><div><br></div><div>However, the additional type safety it afford=
s over <span style=3D"font-family: courier new, monospace;">char</span> and=
 friends also causes <a href=3D"https://monoinfinito.wordpress.com/2018/10/=
02/stdbyte-great-idea-horrible-execution/">many to find it too cumbersome a=
nd verbose</a> to use as a vocabulary type.</div><div><br></div><div>Given =
that C-style type punning with unions is now officially well-defined accord=
ing to the C++ standard, I propose that the declaration of <span style=3D"f=
ont-family: courier new, monospace;">std::byte</span> be changed to<br></di=
v><div><br></div><div><div style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ov=
erflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">union</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
byte</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">un=
signed</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> u</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">signed</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> i</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> c</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Integral</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">explicit</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">oper=
ator</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> noexcept</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// same as above</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span></div></code></div></div><div><br></div><div=
>This would maintain its current type safety while also providing a non-ver=
bose way to interact with literal integers and existing code using <span st=
yle=3D"font-family: courier new, monospace;">char</span> and friends.</div>=
<div><br></div><div>This would, AFAICT, be a source-compatible change excep=
t for code that refers to it as <font face=3D"courier new,monospace">enum s=
td::byte</font><br></div><div><br></div><div><div style=3D"background-color=
: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid=
; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">byte</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">55</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">// OK</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">enum</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">byte</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> bar</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">55</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">// compilation error</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
/div></code></div><br>I don&#39;t think that would break much real-world co=
de.<br></div><div><br></div><div>This would also, AFAICT, be an ABI-compati=
ble change for the Itanium ABI.<br></div><div><br>- Ray<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/dc1cb435-1d6e-4cb8-b148-221d8b3e4f2b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/dc1cb435-1d6e-4cb8-b148-221d8b3e4f2b=
%40isocpp.org</a>.<br />

------=_Part_532_1802197200.1538685875099--

------=_Part_531_638859117.1538685875097--

.


Author: Phil Miller <unmobile@gmail.com>
Date: Thu, 4 Oct 2018 21:50:46 +0000
Raw View
--00000000000067d95d05776e263c
Content-Type: text/plain; charset="UTF-8"

On Thu, Oct 4, 2018 at 8:44 PM Ray Hamel <rayghamel@gmail.com> wrote:

> This would also, AFAICT, be an ABI-compatible change for the Itanium ABI.
>

The calling convention might not change (I'll take your word for it), but
name mangling would change, wouldn't it? So, linking between objects
compiled with a mix of the current and proposed definitions would break on
cross-object calls to functions taking `byte` as an argument

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMDbWJFv6qSVfy_aXdna9CW%3DG60HVcc%3DD-GV_uodQLMu0iyrJg%40mail.gmail.com.

--00000000000067d95d05776e263c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thu, Oct 4, 2018 at 8:44 PM Ray Hamel &lt;<a href=3D"ma=
ilto:rayghamel@gmail.com">rayghamel@gmail.com</a>&gt; wrote:<br><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>This =
would also, AFAICT, be an ABI-compatible change for the Itanium ABI.<br></d=
iv></div></blockquote><div><br></div><div>The calling convention might not =
change (I&#39;ll take your word for it), but name mangling would change, wo=
uldn&#39;t it? So, linking between objects compiled with a mix of the curre=
nt and proposed definitions would break on cross-object calls to functions =
taking `byte` as an argument<br></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAMDbWJFv6qSVfy_aXdna9CW%3DG60HVcc%3D=
D-GV_uodQLMu0iyrJg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMDbWJFv6qSV=
fy_aXdna9CW%3DG60HVcc%3DD-GV_uodQLMu0iyrJg%40mail.gmail.com</a>.<br />

--00000000000067d95d05776e263c--

.


Author: Ray Hamel <rayghamel@gmail.com>
Date: Thu, 4 Oct 2018 15:34:49 -0700 (PDT)
Raw View
------=_Part_525_1238455296.1538692489888
Content-Type: multipart/alternative;
 boundary="----=_Part_526_1777585130.1538692489888"

------=_Part_526_1777585130.1538692489888
Content-Type: text/plain; charset="UTF-8"

Phil,

AFAICT name mangling would not be affected.

Name mangling with current std::byte:
https://wandbox.org/permlink/Inpfx2I5bh6PP4iK
Name mangling with union: https://wandbox.org/permlink/KGz2A6QiTPOQAam0

- Ray

On Thursday, October 4, 2018 at 5:51:00 PM UTC-4, Phil Miller wrote:
>
> On Thu, Oct 4, 2018 at 8:44 PM Ray Hamel <rayg...@gmail.com <javascript:>>
> wrote:
>
>> This would also, AFAICT, be an ABI-compatible change for the Itanium ABI.
>>
>
> The calling convention might not change (I'll take your word for it), but
> name mangling would change, wouldn't it? So, linking between objects
> compiled with a mix of the current and proposed definitions would break on
> cross-object calls to functions taking `byte` as an argument
>

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b725bdf4-fc08-4339-bb52-f01caf191faa%40isocpp.org.

------=_Part_526_1777585130.1538692489888
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Phil,<br></div><div><br></div><div>AFAICT name mangli=
ng would not be affected.</div><div><br></div><div>Name mangling with curre=
nt std::byte: https://wandbox.org/permlink/Inpfx2I5bh6PP4iK</div><div>Name =
mangling with union: https://wandbox.org/permlink/KGz2A6QiTPOQAam0</div><di=
v><br></div><div>- Ray<br></div><br>On Thursday, October 4, 2018 at 5:51:00=
 PM UTC-4, Phil Miller wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div dir=3D"ltr">On Thu, Oct 4, 2018 at 8:44 PM Ray Hamel &lt;<a href=3D"jav=
ascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Cm27Qb7xAgAJ" rel=3D"n=
ofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onc=
lick=3D"this.href=3D&#39;javascript:&#39;;return true;">rayg...@gmail.com</=
a>&gt; wrote:<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<div dir=3D"ltr"><div>This would also, AFAICT, be an ABI-compatible change =
for the Itanium ABI.<br></div></div></blockquote><div><br></div><div>The ca=
lling convention might not change (I&#39;ll take your word for it), but nam=
e mangling would change, wouldn&#39;t it? So, linking between objects compi=
led with a mix of the current and proposed definitions would break on cross=
-object calls to functions taking `byte` as an argument<br></div></div></di=
v>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b725bdf4-fc08-4339-bb52-f01caf191faa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b725bdf4-fc08-4339-bb52-f01caf191faa=
%40isocpp.org</a>.<br />

------=_Part_526_1777585130.1538692489888--

------=_Part_525_1238455296.1538692489888--

.


Author: Chris DeVisser <chris.n.devisser@gmail.com>
Date: Fri, 5 Oct 2018 02:09:48 -0400
Raw View
--000000000000c91cb30577751f77
Content-Type: text/plain; charset="UTF-8"

On Thu, Oct 4, 2018 at 4:44 PM Ray Hamel <rayghamel@gmail.com> wrote:

> Given that C-style type punning with unions is now officially well-defined
> according to the C++ standard, I propose that the declaration of std::byte
> be changed to
>

May I ask where this information came from? It doesn't look that way to me
based on http://eel.is/c++draft/class.union#1.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM6NJy786gVWXZMxH%2B1QZ1VAo54cLwRf96DWEx-zTA8KN%3DUvKQ%40mail.gmail.com.

--000000000000c91cb30577751f77
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr">On Thu, Oct 4, 2018 at 4:44 PM Ray Ham=
el &lt;<a href=3D"mailto:rayghamel@gmail.com">rayghamel@gmail.com</a>&gt; w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div>Given that C-style type punning with unions is now officially=
 well-defined according to the C++ standard, I propose that the declaration=
 of <span style=3D"font-family:&quot;courier new&quot;,monospace">std::byte=
</span> be changed to</div></div></blockquote><div><br></div><div>May I ask=
 where this information came from? It doesn&#39;t look that way to me based=
 on <a href=3D"http://eel.is/c++draft/class.union#1">http://eel.is/c++draft=
/class.union#1</a>.<font color=3D"#1155cc"><u></u></font></div></div></div>=
</div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAM6NJy786gVWXZMxH%2B1QZ1VAo54cLwRf96=
DWEx-zTA8KN%3DUvKQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM6NJy786gVW=
XZMxH%2B1QZ1VAo54cLwRf96DWEx-zTA8KN%3DUvKQ%40mail.gmail.com</a>.<br />

--000000000000c91cb30577751f77--

.


Author: Alberto Barbati <albertobarbati@gmail.com>
Date: Fri, 5 Oct 2018 01:03:01 -0700 (PDT)
Raw View
------=_Part_583_1594205924.1538726581330
Content-Type: multipart/alternative;
 boundary="----=_Part_584_501131742.1538726581331"

------=_Part_584_501131742.1538726581331
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Il giorno venerd=C3=AC 5 ottobre 2018 00:34:50 UTC+2, Ray Hamel ha scritto:
>
> Phil,
>
> AFAICT name mangling would not be affected.
>
> Name mangling with current std::byte:=20
> https://wandbox.org/permlink/Inpfx2I5bh6PP4iK
> Name mangling with union: https://wandbox.org/permlink/KGz2A6QiTPOQAam0
>

The fact that this may be true for Itanium doesn't mean it is true on all=
=20
platforms that support C++. I'm sorry but this evidence is not sufficient=
=20
to say this change is safe for C++ as a language.

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d3456e86-ed75-42fc-b2d3-e1ebaac0fcd2%40isocpp.or=
g.

------=_Part_584_501131742.1538726581331
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Il giorno venerd=C3=AC 5 ottobre 2018 00:34:50 UTC+2, Ray =
Hamel ha scritto:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div>Phil,<br></div><div><br></div><div>AFAICT name mangling would not =
be affected.</div><div><br></div><div>Name mangling with current std::byte:=
 <a href=3D"https://wandbox.org/permlink/Inpfx2I5bh6PP4iK" target=3D"_blank=
" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.google.com/u=
rl?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FInpfx2I5bh6PP4iK\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNGbvBlC3oT-DMDI_Jd5wJYBgHZCxg&#39;;return true;=
" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2=
Fwandbox.org%2Fpermlink%2FInpfx2I5bh6PP4iK\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNGbvBlC3oT-DMDI_Jd5wJYBgHZCxg&#39;;return true;">https://wandbox.org=
/permlink/<wbr>Inpfx2I5bh6PP4iK</a></div><div>Name mangling with union: <a =
href=3D"https://wandbox.org/permlink/KGz2A6QiTPOQAam0" target=3D"_blank" re=
l=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.google.com/url?q=
\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FKGz2A6QiTPOQAam0\x26sa\x3dD\x26s=
ntz\x3d1\x26usg\x3dAFQjCNGSDnU8Y_1DTpRmwVPZz_9dWddcBA&#39;;return true;" on=
click=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwan=
dbox.org%2Fpermlink%2FKGz2A6QiTPOQAam0\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNGSDnU8Y_1DTpRmwVPZz_9dWddcBA&#39;;return true;">https://wandbox.org/per=
mlink/<wbr>KGz2A6QiTPOQAam0</a></div></div></blockquote><div><br></div><div=
>The fact that this may be true for Itanium doesn&#39;t mean it is true on =
all platforms that support C++. I&#39;m sorry but this evidence is not suff=
icient to say this change is safe for C++ as a language.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d3456e86-ed75-42fc-b2d3-e1ebaac0fcd2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d3456e86-ed75-42fc-b2d3-e1ebaac0fcd2=
%40isocpp.org</a>.<br />

------=_Part_584_501131742.1538726581331--

------=_Part_583_1594205924.1538726581330--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 05 Oct 2018 08:38:00 -0700
Raw View
On Friday, 5 October 2018 01:03:01 PDT Alberto Barbati wrote:
> Il giorno venerd=C3=AC 5 ottobre 2018 00:34:50 UTC+2, Ray Hamel ha scritt=
o:
> > Phil,
> >=20
> > AFAICT name mangling would not be affected.
> >=20
> > Name mangling with current std::byte:
> > https://wandbox.org/permlink/Inpfx2I5bh6PP4iK
> > Name mangling with union: https://wandbox.org/permlink/KGz2A6QiTPOQAam0
>=20
> The fact that this may be true for Itanium doesn't mean it is true on all
> platforms that support C++. I'm sorry but this evidence is not sufficient
> to say this change is safe for C++ as a language.

In fact, it is *not* the same for the MSVC ABI. Unions are prefix "T", stru=
cts=20
are prefix "U", classes are prefix "V" and enums are prefix "W4".

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center



--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1820760.6L8AS0xSh1%40tjmaciei-mobl1.

.