Topic: Simple endianness support template proposal


Author: "Ivan G." <nekotekina@gmail.com>
Date: Wed, 14 Dec 2016 16:46:23 -0800 (PST)
Raw View
------=_Part_72_625145809.1481762783095
Content-Type: multipart/alternative;
 boundary="----=_Part_73_267085332.1481762783095"

------=_Part_73_267085332.1481762783095
Content-Type: text/plain; charset=UTF-8

namespace std
{
   template <typename Type, std::size_t Alignment = alignof(T)>
   using le = /* Little endian storage implementation */;

   template <typename Type, std::size_t Alignment = alignof(T)>
   using be = /* Big endian storage implementation */;

   template <typename Type, std::size_t Alignment = alignof(T)>
   using ne = /* Either LE or BE: native or fastest endianness */;

   template <typename Type, std::size_t Alignment = alignof(T)>
   using re = /* Either LE or BE: the opposite to "native" one */;
}

Four template aliases produce types with the following characteristics:
1) POD type with size = sizeof(Type) and specified Alignment.
2) Additional constructor and assignment operator which accept const Type&.
3) Method get() and conversion operator which return Type.
4) Internal representation is implementation-defined for a particular type.
5) Typedefs 'value_type' = Type and 'data_type' = implementation-defined.
6) Public member 'data'

If native endianness is LE or BE, the opposite endianness just reverses the
byte order for *any* type.
I don't know much about the systems with "middle endianness".
So I can't determine well which behaviour is guaranteed and which is
implementation-defined.

Trivial implementation for C++11:
https://github.com/Nekotekina/giggle-endian/blob/master/endian.hpp

There is, of course, boost/endian, and it's different in many ways.
 My implementation contains only the very basic functionality.



--
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/584f3bba-abb3-45a3-9074-a2e722cc6225%40isocpp.org.

------=_Part_73_267085332.1481762783095
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style=3D"background-color: #FAFAFA; border-color: #BB=
B; border-style: solid; border-width: 1px; word-wrap: break-word;" class=3D=
"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">namespace</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std<br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><table class=3D"highligh=
t tab-size js-file-line-container" data-tab-size=3D"8"><tbody><tr><td id=3D=
"LC295" class=3D"blob-code blob-code-inner js-file-line"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><span class=3D"=
pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
typename</span></span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Type=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span class=3D"p=
l-c1"><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t</spa=
n></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">Alignment</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">alignof</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 style=3D"color: #660;" class=3D"styled-by=
-prettify">)&gt;</span></td></tr><tr><td id=3D"LC296" class=3D"blob-code bl=
ob-code-inner js-file-line"><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> =C2=A0 =C2=A0</span><span class=3D"pl-k"><span style=3D"color: =
#008;" class=3D"styled-by-prettify">using</span></span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> le </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">/* Little endian storage implementation */</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span></td></tr><tr><td i=
d=3D"LC297" class=3D"blob-code blob-code-inner js-file-line"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span></td></tr><tr><td=
 id=3D"LC298" class=3D"blob-code blob-code-inner js-file-line"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span class=3D=
"pl-k"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">template</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span =
class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">ty=
pename</span></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Type</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span class=3D"pl-=
c1"><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t</span>=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">Alignment</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">alignof</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)&gt;</span></td></tr><tr><td id=3D"LC299" class=3D"blob-code blo=
b-code-inner js-file-line"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> =C2=A0 =C2=A0</span><span class=3D"pl-k"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">using</span></span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> be </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">/* Big endian storage implementation */</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span></td></tr><tr><td id=3D=
"LC300" class=3D"blob-code blob-code-inner js-file-line"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span></td></tr><tr><td id=3D"=
LC301" class=3D"blob-code blob-code-inner js-file-line"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><span class=3D"p=
l-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span=
 class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
ypename</span></span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Type<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span class=3D"pl=
-c1"><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t</span=
></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Alignment</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">alignof</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)&gt;</span></td></tr><tr><td id=3D"LC302" class=3D"blob-code blo=
b-code-inner js-file-line"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> =C2=A0 =C2=A0</span><span class=3D"pl-k"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">using</span></span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> ne </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">/* Either LE or BE: native or fastest endianness */</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span></td></tr><=
tr><td id=3D"LC303" class=3D"blob-code blob-code-inner js-file-line"><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></td></tr><t=
r><td id=3D"LC304" class=3D"blob-code blob-code-inner js-file-line"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><spa=
n class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span></span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typename</span></span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">Type</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 class=3D"pl-c1"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
size_t</span></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Alignm=
ent</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">alignof</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)&gt;</span></td></tr><tr><td id=3D"LC305" class=3D=
"blob-code blob-code-inner js-file-line"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><span class=3D"pl-k"><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">using</span></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> re </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">/* Either LE or BE: the opposite to &quot;na=
tive&quot; one */</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
</td></tr></tbody></table><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></div></code></div><br><div>Four template aliases produ=
ce types with the following characteristics:</div><div>1) POD type with siz=
e =3D sizeof(Type) and specified Alignment.</div><div>2) Additional constru=
ctor and assignment operator which accept const Type&amp;.</div><div>3) Met=
hod get() and conversion operator which return Type.</div><div>4) Internal =
representation is implementation-defined for a particular type.</div><div>5=
) Typedefs &#39;value_type&#39; =3D Type and &#39;data_type&#39; =3D implem=
entation-defined.</div><div>6) Public member <font face=3D"arial,sans-serif=
">&#39;</font>data&#39;</div><div><br></div><div>If native endianness is LE=
 or BE, the opposite endianness just reverses the byte order for *any* type=
..</div><div>I don&#39;t know much about the systems with &quot;middle endia=
nness&quot;.</div><div>So I can&#39;t determine well which behaviour is gua=
ranteed and which is implementation-defined.</div><div><br></div><div>Trivi=
al implementation for C++11:</div><div>https://github.com/Nekotekina/giggle=
-endian/blob/master/endian.hpp</div><div><br></div><div>There is, of course=
, boost/endian, and it&#39;s different in many ways.</div><div>=C2=A0My imp=
lementation contains only the very basic functionality.</div><div><br></div=
><div><br></div><div><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/584f3bba-abb3-45a3-9074-a2e722cc6225%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/584f3bba-abb3-45a3-9074-a2e722cc6225=
%40isocpp.org</a>.<br />

------=_Part_73_267085332.1481762783095--

------=_Part_72_625145809.1481762783095--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 14 Dec 2016 18:04:50 -0800 (PST)
Raw View
------=_Part_119_2095418143.1481767490436
Content-Type: multipart/alternative;
 boundary="----=_Part_120_747403282.1481767490436"

------=_Part_120_747403282.1481767490436
Content-Type: text/plain; charset=UTF-8



On Wednesday, December 14, 2016 at 7:46:23 PM UTC-5, Ivan G. wrote:
>
> namespace std
> {
>    template <typename Type, std::size_t Alignment = alignof(T)>
>    using le = /* Little endian storage implementation */;
>
>    template <typename Type, std::size_t Alignment = alignof(T)>
>    using be = /* Big endian storage implementation */;
>
>    template <typename Type, std::size_t Alignment = alignof(T)>
>    using ne = /* Either LE or BE: native or fastest endianness */;
>
>    template <typename Type, std::size_t Alignment = alignof(T)>
>    using re = /* Either LE or BE: the opposite to "native" one */;
> }
>
> Four template aliases produce types with the following characteristics:
> 1) POD type with size = sizeof(Type) and specified Alignment.
> 2) Additional constructor and assignment operator which accept const Type&.
> 3) Method get() and conversion operator which return Type.
> 4) Internal representation is implementation-defined for a particular type.
> 5) Typedefs 'value_type' = Type and 'data_type' = implementation-defined.
> 6) Public member 'data'
>

OK, that functionality is interesting. Now... what exactly would you use
any of these types to actually do?

You say the types have a constructor that accepts a `const Type&`. OK...
what does it do with that value? What does `get` and the conversion
operator return? What does this "public member 'data'" store?

In short, what is the purpose of these types?

If these types are intended to represent some kind of buffered storage for
an endian-converted object, I'd much rather have functions to actually do
the conversion: CopyFromLEToNE, CopyFromNEToBE, etc. They would take a
`const T&` and be given a region of storage you provide which will be
copied into.


> If native endianness is LE or BE, the opposite endianness just reverses
> the byte order for *any* type.
>

How is that possible with user-defined `Type`s? After, `Type` can have
multiple basic types stored in it. And endian-ness only applies to basic
types. If you have a type that stores a pair of `int`s, how could this
object know that it needs to flip the first sizeof(int) bytes, then the
next sizeof(int) bytes?

And even if it could know deconstruct a type and endian convert its
internals (and that's a big if, since we're potentially talking about
accessing private members), this would only be viable for types which are
trivially copyable. So "any type" isn't going to happen.

--
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/fc5b61db-212a-44d0-980b-98d5171842fc%40isocpp.org.

------=_Part_120_747403282.1481767490436
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, December 14, 2016 at 7:46:23 PM UTC-=
5, Ivan G. wrote:<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 style=3D"background-color:#fafafa;border-color:#bbb;border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color=
:#008">namespace</span><span style=3D"color:#000"> std<br></span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"> </span><table><tbody><=
tr><td><span style=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"=
color:#008">template</span><span style=3D"color:#000"> </span></span><span =
style=3D"color:#660">&lt;</span><span><span style=3D"color:#008">typename</=
span></span><span style=3D"color:#000"> </span><span style=3D"color:#606">T=
ype</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> st=
d</span><span style=3D"color:#660">::</span><span><span style=3D"color:#000=
">size_t</span></span><span style=3D"color:#000"> </span><span style=3D"col=
or:#606">Alignment</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">alignof</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000">T</span><span style=3D"color:#660">)&gt;</span></td></tr><tr><td>=
<span style=3D"color:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:=
#008">using</span></span><span style=3D"color:#000"> le </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#800">/* Little endian storage implementation */</span><span style=
=3D"color:#660">;</span></td></tr><tr><td><span style=3D"color:#000"> =C2=
=A0</span></td></tr><tr><td><span style=3D"color:#000"> =C2=A0</span><span>=
<span style=3D"color:#000"> =C2=A0</span><span style=3D"color:#008">templat=
e</span><span style=3D"color:#000"> </span></span><span style=3D"color:#660=
">&lt;</span><span><span style=3D"color:#008">typename</span></span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">Type</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span><span style=3D"color:#000">size_t</span></sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#606">Alignment<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">alignof</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000">T</span><=
span style=3D"color:#660">)&gt;</span></td></tr><tr><td><span style=3D"colo=
r:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008">using</span><=
/span><span style=3D"color:#000"> be </span><span style=3D"color:#660">=3D<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">/* Big =
endian storage implementation */</span><span style=3D"color:#660">;</span><=
/td></tr><tr><td><span style=3D"color:#000"><br></span></td></tr><tr><td><s=
pan style=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"color:#00=
8">template</span><span style=3D"color:#000"> </span></span><span style=3D"=
color:#660">&lt;</span><span><span style=3D"color:#008">typename</span></sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#606">Type</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</span><=
span style=3D"color:#660">::</span><span><span style=3D"color:#000">size_t<=
/span></span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
Alignment</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
alignof</span><span style=3D"color:#660">(</span><span style=3D"color:#000"=
>T</span><span style=3D"color:#660">)&gt;</span></td></tr><tr><td><span sty=
le=3D"color:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008">usi=
ng</span></span><span style=3D"color:#000"> ne </span><span style=3D"color:=
#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">/* Either LE or BE: native or fastest endianness */</span><span style=3D=
"color:#660">;</span></td></tr><tr><td><span style=3D"color:#000"><br></spa=
n></td></tr><tr><td><span style=3D"color:#000">=C2=A0 =C2=A0</span><span><s=
pan style=3D"color:#008">template</span><span style=3D"color:#000"> </span>=
</span><span style=3D"color:#660">&lt;</span><span><span style=3D"color:#00=
8">typename</span></span><span style=3D"color:#000"> </span><span style=3D"=
color:#606">Type</span><span style=3D"color:#660">,</span><span style=3D"co=
lor:#000"> std</span><span style=3D"color:#660">::</span><span><span style=
=3D"color:#000">size_t</span></span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#606">Alignment</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">alignof</span><span style=3D"color:#660">(</span><sp=
an style=3D"color:#000">T</span><span style=3D"color:#660">)&gt;</span></td=
></tr><tr><td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><span><span s=
tyle=3D"color:#008">using</span></span><span style=3D"color:#000"> re </spa=
n><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">/* Either LE or BE: the opposite to &quot;native&=
quot; one */</span><span style=3D"color:#660">;</span><span style=3D"color:=
#000"><br></span><span style=3D"color:#660">}</span></td></tr></tbody></tab=
le><span style=3D"color:#000"><br></span></div></code></div><br><div>Four t=
emplate aliases produce types with the following characteristics:</div><div=
>1) POD type with size =3D sizeof(Type) and specified Alignment.</div><div>=
2) Additional constructor and assignment operator which accept const Type&a=
mp;.</div><div>3) Method get() and conversion operator which return Type.</=
div><div>4) Internal representation is implementation-defined for a particu=
lar type.</div><div>5) Typedefs &#39;value_type&#39; =3D Type and &#39;data=
_type&#39; =3D implementation-defined.</div><div>6) Public member <font fac=
e=3D"arial,sans-serif">&#39;</font>data&#39;</div></div></blockquote><div><=
br>OK, that functionality is interesting. Now... what exactly would you use=
 any of these types to actually do?<br><br>You say the types have a constru=
ctor that accepts a `const Type&amp;`. OK... what does it do with that valu=
e? What does `get` and the conversion operator return? What does this &quot=
;public member &#39;data&#39;&quot; store?<br><br>In short, what is the pur=
pose of these types?<br><br>If these types are intended to represent some k=
ind of buffered storage for an endian-converted object, I&#39;d much rather=
 have functions to actually do the conversion: CopyFromLEToNE, CopyFromNETo=
BE, etc. They would take a `const T&amp;` and be given a region of storage =
you provide which will be copied into.<br>=C2=A0</div><blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><div>If native endianne=
ss is LE or BE, the opposite endianness just reverses the byte order for *a=
ny* type.</div></div></blockquote><div><br>How is that possible with user-d=
efined `Type`s? After, `Type` can have multiple basic types stored in it. A=
nd endian-ness only applies to basic types. If you have a type that stores =
a pair of `int`s, how could this object know that it needs to flip the firs=
t sizeof(int) bytes, then the next sizeof(int) bytes?<br><br>And even if it=
 could know deconstruct a type and endian convert its internals (and that&#=
39;s a big if, since we&#39;re potentially talking about accessing private =
members), this would only be viable for types which are trivially copyable.=
 So &quot;any type&quot; isn&#39;t going to happen.<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/fc5b61db-212a-44d0-980b-98d5171842fc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fc5b61db-212a-44d0-980b-98d5171842fc=
%40isocpp.org</a>.<br />

------=_Part_120_747403282.1481767490436--

------=_Part_119_2095418143.1481767490436--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 15 Dec 2016 07:50:56 +0100
Raw View
This is a multi-part message in MIME format.
--------------BAF33134C19D01459717972C
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 15/12/2016 =C3=A0 01:46, Ivan G. a =C3=A9crit :
> |
> namespacestd
> {
> template<typenameType,std::size_tAlignment=3Dalignof(T)>
> usingle =3D/* Little endian storage implementation */;
> template<typenameType,std::size_tAlignment=3Dalignof(T)>
> usingbe =3D/* Big endian storage implementation */;
>
> template<typenameType,std::size_tAlignment=3Dalignof(T)>
> usingne =3D/* Either LE or BE: native or fastest endianness */;
>
> template<typenameType,std::size_tAlignment=3Dalignof(T)>
> usingre =3D/* Either LE or BE: the opposite to "native" one */;
> }
>
>
> |
>
> Four template aliases produce types with the following characteristics:
> 1) POD type with size =3D sizeof(Type) and specified Alignment.
> 2) Additional constructor and assignment operator which accept const=20
> Type&.
> 3) Method get() and conversion operator which return Type.
> 4) Internal representation is implementation-defined for a particular=20
> type.
> 5) Typedefs 'value_type' =3D Type and 'data_type' =3D implementation-defi=
ned.
> 6) Public member 'data'
>
> If native endianness is LE or BE, the opposite endianness just=20
> reverses the byte order for *any* type.
> I don't know much about the systems with "middle endianness".
> So I can't determine well which behaviour is guaranteed and which is=20
> implementation-defined.
>
> Trivial implementation for C++11:
> https://github.com/Nekotekina/giggle-endian/blob/master/endian.hpp
>
> There is, of course, boost/endian, and it's different in many ways.
>  My implementation contains only the very basic functionality.
>
Hi,

We have used this revert technique, but with two different Type=20
representations depending on the endianess.

#if BIG
struct X {
     int32_t a;
     int8_t b;
     int32_t : 24;
};

#elsif LITTLE
struct X {
     int32_t : 24;
     int8_t b;
     int32_t a;
};
#endif

Now reverting the octects in the buffer moves from one representation to=20
the other.
Your implementation will work only when the Type is packed and trivial,=20
isn't it?
Am I missing something?

Having the same Type description will need some extra reflection and=20
meta-programming to copy each one of the fields to the good offset in=20
addition to reverse the octects.

Vicente

--=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/1624fedb-6b50-abbc-2ef1-95d976964a46%40wanadoo.f=
r.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 15/12/2016 =C3=A0 01:46, Ivan G. a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:584f3bba-abb3-45a3-9074-a2e722cc6225@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color: #FAFAFA; border-color: #BBB;
          border-style: solid; border-width: 1px; word-wrap:
          break-word;" class=3D"prettyprint"><code class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #008;"
                class=3D"styled-by-prettify">namespace</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std<br=
>
              </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span>
              <table class=3D"highlight tab-size js-file-line-container"
                data-tab-size=3D"8">
                <tbody>
                  <tr>
                    <td id=3D"LC295" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><s=
pan
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">template</span><span
                          style=3D"color: #000;"
                          class=3D"styled-by-prettify"> </span></span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">typename</span></spa=
n><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Type</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</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
                        class=3D"pl-c1"><span style=3D"color: #000;"
                          class=3D"styled-by-prettify">size_t</span></span>=
<span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Alignment</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #008;"
                        class=3D"styled-by-prettify">alignof</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
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>)&gt;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC296" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><=
span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">using</span></span><=
span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                        le </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #800;"
                        class=3D"styled-by-prettify">/* Little endian
                        storage implementation */</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC297" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC298" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0</span><span
                        class=3D"pl-k"><span style=3D"color: #000;"
                          class=3D"styled-by-prettify"> =C2=A0</span><span
                          style=3D"color: #008;"
                          class=3D"styled-by-prettify">template</span><span
                          style=3D"color: #000;"
                          class=3D"styled-by-prettify"> </span></span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">typename</span></spa=
n><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Type</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</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
                        class=3D"pl-c1"><span style=3D"color: #000;"
                          class=3D"styled-by-prettify">size_t</span></span>=
<span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Alignment</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #008;"
                        class=3D"styled-by-prettify">alignof</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
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>)&gt;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC299" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><=
span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">using</span></span><=
span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                        be </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #800;"
                        class=3D"styled-by-prettify">/* Big endian storage
                        implementation */</span><span style=3D"color:
                        #660;" class=3D"styled-by-prettify">;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC300" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC301" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><s=
pan
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">template</span><span
                          style=3D"color: #000;"
                          class=3D"styled-by-prettify"> </span></span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">typename</span></spa=
n><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Type</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</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
                        class=3D"pl-c1"><span style=3D"color: #000;"
                          class=3D"styled-by-prettify">size_t</span></span>=
<span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Alignment</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #008;"
                        class=3D"styled-by-prettify">alignof</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
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>)&gt;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC302" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><=
span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">using</span></span><=
span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                        ne </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #800;"
                        class=3D"styled-by-prettify">/* Either LE or BE:
                        native or fastest endianness */</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC303" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC304" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><s=
pan
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">template</span><span
                          style=3D"color: #000;"
                          class=3D"styled-by-prettify"> </span></span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">typename</span></spa=
n><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Type</span><span
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</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
                        class=3D"pl-c1"><span style=3D"color: #000;"
                          class=3D"styled-by-prettify">size_t</span></span>=
<span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #606;"
                        class=3D"styled-by-prettify">Alignment</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #008;"
                        class=3D"styled-by-prettify">alignof</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
                        style=3D"color: #660;" class=3D"styled-by-prettify"=
>)&gt;</span></td>
                  </tr>
                  <tr>
                    <td id=3D"LC305" class=3D"blob-code blob-code-inner
                      js-file-line"><span style=3D"color: #000;"
                        class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><=
span
                        class=3D"pl-k"><span style=3D"color: #008;"
                          class=3D"styled-by-prettify">using</span></span><=
span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                        re </span><span style=3D"color: #660;"
                        class=3D"styled-by-prettify">=3D</span><span
                        style=3D"color: #000;" class=3D"styled-by-prettify"=
>
                      </span><span style=3D"color: #800;"
                        class=3D"styled-by-prettify">/* Either LE or BE:
                        the opposite to "native" one */</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></td>
                  </tr>
                </tbody>
              </table>
              <span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>
              </span></div>
          </code></div>
        <br>
        <div>Four template aliases produce types with the following
          characteristics:</div>
        <div>1) POD type with size =3D sizeof(Type) and specified
          Alignment.</div>
        <div>2) Additional constructor and assignment operator which
          accept const Type&amp;.</div>
        <div>3) Method get() and conversion operator which return Type.</di=
v>
        <div>4) Internal representation is implementation-defined for a
          particular type.</div>
        <div>5) Typedefs 'value_type' =3D Type and 'data_type' =3D
          implementation-defined.</div>
        <div>6) Public member <font face=3D"arial,sans-serif">'</font>data'=
</div>
        <div><br>
        </div>
        <div>If native endianness is LE or BE, the opposite endianness
          just reverses the byte order for *any* type.</div>
        <div>I don't know much about the systems with "middle
          endianness".</div>
        <div>So I can't determine well which behaviour is guaranteed and
          which is implementation-defined.</div>
        <div><br>
        </div>
        <div>Trivial implementation for C++11:</div>
        <div><a class=3D"moz-txt-link-freetext" href=3D"https://github.com/=
Nekotekina/giggle-endian/blob/master/endian.hpp">https://github.com/Nekotek=
ina/giggle-endian/blob/master/endian.hpp</a></div>
        <div><br>
        </div>
        <div>There is, of course, boost/endian, and it's different in
          many ways.</div>
        <div>=C2=A0My implementation contains only the very basic
          functionality.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    <br>
    We have used this revert technique, but with two different Type
    representations depending on the endianess.<br>
    <br>
    #if BIG<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    };<br>
    <br>
    #elsif LITTLE<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    };<br>
    #endif<br>
    <br>
    Now reverting the octects in the buffer moves from one
    representation to the other.<br>
    Your implementation will work only when the Type is packed and
    trivial, isn't it?<br>
    Am I missing something?<br>
    <br>
    Having the same Type description will need some extra reflection and
    meta-programming to copy each one of the fields to the good offset
    in addition to reverse the octects.<br>
    <br>
    Vicente<br>
  </body>
</html>

<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/1624fedb-6b50-abbc-2ef1-95d976964a46%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1624fedb-6b50-abbc-2ef1-95d976964a46=
%40wanadoo.fr</a>.<br />

--------------BAF33134C19D01459717972C--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 01:17:14 -0800 (PST)
Raw View
------=_Part_113_1427963995.1481793434783
Content-Type: multipart/alternative;
 boundary="----=_Part_114_1875707079.1481793434784"

------=_Part_114_1875707079.1481793434784
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thanks, the main purpose of endian storage types is the ability to create a=
=20
struct with "endian" members. Another purpose is the ability to overwrite=
=20
type alignment, so it can effectively replace #pragma pack.
struct my_type
{
    std::be<std::uint32_t, 2> x;
    std::be<std::uint32_t, 2> y;
};

static_assert(alignof(my_type) =3D=3D 2, "Invalid my_type alignment");



Constructor takes `const Type&` and reads its internal representation, byte=
=20
after byte. The bytes are stored in normal or reversed order, depending on=
=20
the endianness.
This applies to user-defined types as well (of course they shall be=20
trivially copyable, but I can't define exact limitations).
In the case of pair of ints, my opinion is:
1) In the most simple case, it should probably be replaced with a pair of=
=20
`be<int>` or `le<int>`.
2) Byte representation is accessed from the first byte to the last byte,=20
regardless of the actual type. It will probably swap the ints.
3) Pair of ints, as well as any other imaginable type, should be supported=
=20
anyway because it may be exactly what the programmer wants.
 Of course, I said "any type" incorrectly, sorry about this. But I don't=20
want to limit endianness support with basic types only. For some types it=
=20
will cause undefined behaviour, or maybe hit static_assert.=20

Method `get()`, as well as the conversion operator, reconstructs a value of=
=20
type `Type` from its byte representation, loaded from endian storage.
Member `data` has implementation-defined type (probably an array of=20
unsigned chars). It's not too useful for the programmer, but I can imagine=
=20
some uses cases. It always was a private member in my previous experience,=
=20
but coexisted with another methods to access the internal representation.

`CopyFromLEToNE` or similar functions can be provided independently, since=
=20
they have their use cases as well. Or easily be emulated with be<> or le<>=
=20
types.

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 5:04:50 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Nicol Bolas =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:
>
>
>
> On Wednesday, December 14, 2016 at 7:46:23 PM UTC-5, Ivan G. wrote:
>>
>> namespace std
>> {=20
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>    using le =3D /* Little endian storage implementation */;
>> =20
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>    using be =3D /* Big endian storage implementation */;
>>
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>    using ne =3D /* Either LE or BE: native or fastest endianness */;
>>
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>    using re =3D /* Either LE or BE: the opposite to "native" one */;
>> }
>>
>> Four template aliases produce types with the following characteristics:
>> 1) POD type with size =3D sizeof(Type) and specified Alignment.
>> 2) Additional constructor and assignment operator which accept const=20
>> Type&.
>> 3) Method get() and conversion operator which return Type.
>> 4) Internal representation is implementation-defined for a particular=20
>> type.
>> 5) Typedefs 'value_type' =3D Type and 'data_type' =3D implementation-def=
ined.
>> 6) Public member 'data'
>>
>
> OK, that functionality is interesting. Now... what exactly would you use=
=20
> any of these types to actually do?
>
> You say the types have a constructor that accepts a `const Type&`. OK...=
=20
> what does it do with that value? What does `get` and the conversion=20
> operator return? What does this "public member 'data'" store?
>
> In short, what is the purpose of these types?
>
> If these types are intended to represent some kind of buffered storage fo=
r=20
> an endian-converted object, I'd much rather have functions to actually do=
=20
> the conversion: CopyFromLEToNE, CopyFromNEToBE, etc. They would take a=20
> `const T&` and be given a region of storage you provide which will be=20
> copied into.
> =20
>
>> If native endianness is LE or BE, the opposite endianness just reverses=
=20
>> the byte order for *any* type.
>>
>
> How is that possible with user-defined `Type`s? After, `Type` can have=20
> multiple basic types stored in it. And endian-ness only applies to basic=
=20
> types. If you have a type that stores a pair of `int`s, how could this=20
> object know that it needs to flip the first sizeof(int) bytes, then the=
=20
> next sizeof(int) bytes?
>
> And even if it could know deconstruct a type and endian convert its=20
> internals (and that's a big if, since we're potentially talking about=20
> accessing private members), this would only be viable for types which are=
=20
> trivially copyable. So "any type" isn't going to happen.
>

--=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/1de4b099-139b-4fa7-a3e3-fa2cddfd3f31%40isocpp.or=
g.

------=_Part_114_1875707079.1481793434784
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Thanks, the main purpose of endian storage types is t=
he ability to create a struct with &quot;endian&quot; members. Another purp=
ose is the ability to overwrite type alignment, so it can effectively repla=
ce #pragma pack.<br></div><div><div style=3D"background-color: #FAFAFA; bor=
der-color: #BBB; border-style: solid; border-width: 1px; word-wrap: break-w=
ord;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> my_type<b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0=
 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">be</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">uint32_t</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: #066;" class=3D"styled-b=
y-prettify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">be</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</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: #000;" =
class=3D"styled-by-prettify">uint32_t</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</sp=
an><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"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">static_assert</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">alignof</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">my_type</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">2</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: #=
080;" class=3D"styled-by-prettify">&quot;Invalid my_type alignment&quot;</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div>=
</code></div><br></div><div><br></div><div>Constructor takes `const Type&am=
p;` and reads its internal representation, byte after byte. The bytes are s=
tored in normal or reversed order, depending on the endianness.</div><div>T=
his applies to user-defined types as well (of course they shall be triviall=
y copyable, but I can&#39;t define exact limitations).</div><div>In the cas=
e of pair of ints, my opinion is:</div><div>1) In the most simple case, it =
should probably be replaced with a pair of `be&lt;int&gt;` or `le&lt;int&gt=
;`.</div><div>2) Byte representation is accessed from the first byte to the=
 last byte, regardless of the actual type. It will probably swap the ints.<=
/div><div>3) Pair of ints, as well as any other imaginable type, should be =
supported anyway because it may be exactly what the programmer wants.</div>=
<div>=C2=A0Of course, I said &quot;any type&quot; incorrectly, sorry about =
this. But I don&#39;t want to limit endianness support with basic types onl=
y. For some types it will cause undefined behaviour, or maybe hit static_as=
sert.=C2=A0</div><div><br></div><div>
<div>Method `get()`, as well as the conversion operator, reconstructs a val=
ue of type `Type` from its byte representation, loaded from endian storage.=
</div><div>Member `data` has implementation-defined type (probably an array=
 of unsigned chars). It&#39;s not too useful for the programmer, but I can =
imagine some uses cases. It always was a private member in my previous expe=
rience, but coexisted with another methods to access the internal represent=
ation.</div><div><br></div><div>`CopyFromLEToNE` or similar functions can b=
e provided independently, since they have their use cases as well. Or easil=
y be emulated with be&lt;&gt; or le&lt;&gt; types.</div></div><br>=D1=87=D0=
=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=B1=D1=80=
=D1=8F 2016 =D0=B3., 5:04:50 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=
=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Nicol Bolas =D0=BD=D0=B0=D0=BF=D0=B8=D1=
=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><br><br>On Wednesday, December 14, 2016 at 7:46:23 PM UTC-5, Ivan G. wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"b=
ackground-color:#fafafa;border-color:#bbb;border-style:solid;border-width:1=
px;word-wrap:break-word"><code><div><span style=3D"color:#008">namespace</s=
pan><span style=3D"color:#000"> std<br></span><span style=3D"color:#660">{<=
/span><span style=3D"color:#000"> </span><table><tbody><tr><td><span style=
=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"color:#008">templa=
te</span><span style=3D"color:#000"> </span></span><span style=3D"color:#66=
0">&lt;</span><span><span style=3D"color:#008">typename</span></span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> std</span><span styl=
e=3D"color:#660">::</span><span><span style=3D"color:#000">size_t</span></s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#606">Alignment=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">alignof</=
span><span style=3D"color:#660">(</span><span style=3D"color:#000">T</span>=
<span style=3D"color:#660">)&gt;</span></td></tr><tr><td><span style=3D"col=
or:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008">using</span>=
</span><span style=3D"color:#000"> le </span><span style=3D"color:#660">=3D=
</span><span style=3D"color:#000"> </span><span style=3D"color:#800">/* Lit=
tle endian storage implementation */</span><span style=3D"color:#660">;</sp=
an></td></tr><tr><td><span style=3D"color:#000"> =C2=A0</span></td></tr><tr=
><td><span style=3D"color:#000"> =C2=A0</span><span><span style=3D"color:#0=
00"> =C2=A0</span><span style=3D"color:#008">template</span><span style=3D"=
color:#000"> </span></span><span style=3D"color:#660">&lt;</span><span><spa=
n style=3D"color:#008">typename</span></span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">Type</span><span style=3D"color:#660">,</sp=
an><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</spa=
n><span><span style=3D"color:#000">size_t</span></span><span style=3D"color=
:#000"> </span><span style=3D"color:#606">Alignment</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">alignof</span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#000">T</span><span style=3D"color:#66=
0">)&gt;</span></td></tr><tr><td><span style=3D"color:#000"> =C2=A0 =C2=A0<=
/span><span><span style=3D"color:#008">using</span></span><span style=3D"co=
lor:#000"> be </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">/* Big endian storage implemen=
tation */</span><span style=3D"color:#660">;</span></td></tr><tr><td><span =
style=3D"color:#000"><br></span></td></tr><tr><td><span style=3D"color:#000=
">=C2=A0 =C2=A0</span><span><span style=3D"color:#008">template</span><span=
 style=3D"color:#000"> </span></span><span style=3D"color:#660">&lt;</span>=
<span><span style=3D"color:#008">typename</span></span><span style=3D"color=
:#000"> </span><span style=3D"color:#606">Type</span><span style=3D"color:#=
660">,</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span><span style=3D"color:#000">size_t</span></span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Alignment</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">alignof</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">T</span><span style=3D=
"color:#660">)&gt;</span></td></tr><tr><td><span style=3D"color:#000"> =C2=
=A0 =C2=A0</span><span><span style=3D"color:#008">using</span></span><span =
style=3D"color:#000"> ne </span><span style=3D"color:#660">=3D</span><span =
style=3D"color:#000"> </span><span style=3D"color:#800">/* Either LE or BE:=
 native or fastest endianness */</span><span style=3D"color:#660">;</span><=
/td></tr><tr><td><span style=3D"color:#000"><br></span></td></tr><tr><td><s=
pan style=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"color:#00=
8">template</span><span style=3D"color:#000"> </span></span><span style=3D"=
color:#660">&lt;</span><span><span style=3D"color:#008">typename</span></sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#606">Type</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</span><=
span style=3D"color:#660">::</span><span><span style=3D"color:#000">size_t<=
/span></span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
Alignment</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
alignof</span><span style=3D"color:#660">(</span><span style=3D"color:#000"=
>T</span><span style=3D"color:#660">)&gt;</span></td></tr><tr><td><span sty=
le=3D"color:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008">usi=
ng</span></span><span style=3D"color:#000"> re </span><span style=3D"color:=
#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">/* Either LE or BE: the opposite to &quot;native&quot; one */</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">}</span></td></tr></tbody></table><span style=3D"color=
:#000"><br></span></div></code></div><br><div>Four template aliases produce=
 types with the following characteristics:</div><div>1) POD type with size =
=3D sizeof(Type) and specified Alignment.</div><div>2) Additional construct=
or and assignment operator which accept const Type&amp;.</div><div>3) Metho=
d get() and conversion operator which return Type.</div><div>4) Internal re=
presentation is implementation-defined for a particular type.</div><div>5) =
Typedefs &#39;value_type&#39; =3D Type and &#39;data_type&#39; =3D implemen=
tation-defined.</div><div>6) Public member <font face=3D"arial,sans-serif">=
&#39;</font>data&#39;</div></div></blockquote><div><br>OK, that functionali=
ty is interesting. Now... what exactly would you use any of these types to =
actually do?<br><br>You say the types have a constructor that accepts a `co=
nst Type&amp;`. OK... what does it do with that value? What does `get` and =
the conversion operator return? What does this &quot;public member &#39;dat=
a&#39;&quot; store?<br><br>In short, what is the purpose of these types?<br=
><br>If these types are intended to represent some kind of buffered storage=
 for an endian-converted object, I&#39;d much rather have functions to actu=
ally do the conversion: CopyFromLEToNE, CopyFromNEToBE, etc. They would tak=
e a `const T&amp;` and be given a region of storage you provide which will =
be copied into.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
 dir=3D"ltr"><div>If native endianness is LE or BE, the opposite endianness=
 just reverses the byte order for *any* type.</div></div></blockquote><div>=
<br>How is that possible with user-defined `Type`s? After, `Type` can have =
multiple basic types stored in it. And endian-ness only applies to basic ty=
pes. If you have a type that stores a pair of `int`s, how could this object=
 know that it needs to flip the first sizeof(int) bytes, then the next size=
of(int) bytes?<br><br>And even if it could know deconstruct a type and endi=
an convert its internals (and that&#39;s a big if, since we&#39;re potentia=
lly talking about accessing private members), this would only be viable for=
 types which are trivially copyable. So &quot;any type&quot; isn&#39;t goin=
g to happen.<br></div></div></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/1de4b099-139b-4fa7-a3e3-fa2cddfd3f31%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1de4b099-139b-4fa7-a3e3-fa2cddfd3f31=
%40isocpp.org</a>.<br />

------=_Part_114_1875707079.1481793434784--

------=_Part_113_1427963995.1481793434783--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 02:11:00 -0800 (PST)
Raw View
------=_Part_137_1442851889.1481796660435
Content-Type: multipart/alternative;
 boundary="----=_Part_138_538932111.1481796660436"

------=_Part_138_538932111.1481796660436
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi, I think the Type must not necessarily be packed and trivial.

I'm not sure I understood the example. Assuming the disk/network endianness=
=20
is fixed, big endian, and bitfields are always MSB->LSB, it could be:

struct X_impl {
    int64_t a : 32;
    int64_t b : 8;
    int64_t : 24;
};
using X =3D std::be<X_impl>;

Other possibilities:

struct X {
    std::be<int32_t, 4> a;
    int8_t b; // Fixed position
};

union X {
    int64_t _data;
    bitfield_emulation<int64_t, 0, 32> a;
    bitfield_emulation<int64_t, 32, 40> b;
};

union X {
    std::be<int64_t> _data;
    bitfield_emulation<std::be<int64_t>, 0, 32> a;
    bitfield_emulation<std::be<int64_t>, 32, 40> b;
};

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 9:50:54 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vicente J. Botet=20
Escriba =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Le 15/12/2016 =C3=A0 01:46, Ivan G. a =C3=A9crit :
>
> namespace std
> {=20
>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>    using le =3D /* Little endian storage implementation */;=20
>  =20
>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>    using be =3D /* Big endian storage implementation */;=20
>
>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>    using ne =3D /* Either LE or BE: native or fastest endianness */;=20
>
>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>    using re =3D /* Either LE or BE: the opposite to "native" one */;
> }=20
>
> Four template aliases produce types with the following characteristics:
> 1) POD type with size =3D sizeof(Type) and specified Alignment.
> 2) Additional constructor and assignment operator which accept const Type=
&.
> 3) Method get() and conversion operator which return Type.
> 4) Internal representation is implementation-defined for a particular typ=
e.
> 5) Typedefs 'value_type' =3D Type and 'data_type' =3D implementation-defi=
ned.
> 6) Public member 'data'
>
> If native endianness is LE or BE, the opposite endianness just reverses=
=20
> the byte order for *any* type.
> I don't know much about the systems with "middle endianness".
> So I can't determine well which behaviour is guaranteed and which is=20
> implementation-defined.
>
> Trivial implementation for C++11:
> https://github.com/Nekotekina/giggle-endian/blob/master/endian.hpp
>
> There is, of course, boost/endian, and it's different in many ways.
>  My implementation contains only the very basic functionality.
>
> Hi,
>
> We have used this revert technique, but with two different Type=20
> representations depending on the endianess.
>
> #if BIG
> struct X {
>     int32_t a;
>     int8_t b;
>     int32_t : 24;
> };
>
> #elsif LITTLE
> struct X {
>     int32_t : 24;
>     int8_t b;
>     int32_t a;
> };
> #endif
>
> Now reverting the octects in the buffer moves from one representation to=
=20
> the other.
> Your implementation will work only when the Type is packed and trivial,=
=20
> isn't it?
> Am I missing something?
>
> Having the same Type description will need some extra reflection and=20
> meta-programming to copy each one of the fields to the good offset in=20
> addition to reverse the octects.
>
> Vicente
>

--=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/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%40isocpp.or=
g.

------=_Part_138_538932111.1481796660436
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi, I think the Type must not necessarily be packed a=
nd trivial.<br></div><div><br></div><div>I&#39;m not sure I understood the =
example. Assuming the disk/network endianness is fixed, big endian, and bit=
fields are always MSB-&gt;LSB, it could be:</div><div><br></div><div>
<div>struct X_impl {</div><div>=C2=A0 =C2=A0 int64_t a : 32;</div><div>=C2=
=A0 =C2=A0 int64_t b : 8;</div><div>=C2=A0 =C2=A0 int64_t : 24;</div><div>}=
;</div>using X =3D std::be&lt;X_impl&gt;;</div><div><br></div><div>Other po=
ssibilities:</div><div><br></div><div>struct X {</div><div>=C2=A0 =C2=A0 st=
d::be&lt;int32_t, 4&gt; a;</div><div>=C2=A0 =C2=A0 int8_t b; // Fixed posit=
ion</div><div>};</div><div><br></div><div>union X {</div><div>=C2=A0 =C2=A0=
 int64_t _data;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt;int64_t, 0, 3=
2&gt; a;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt;int64_t, 32, 40&gt; =
b;</div><div>};</div><div><br></div><div>union X {</div><div>=C2=A0 =C2=A0 =
std::be&lt;int64_t&gt; _data;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt=
;std::be&lt;int64_t&gt;, 0, 32&gt; a;</div><div>=C2=A0 =C2=A0 bitfield_emul=
ation&lt;std::be&lt;int64_t&gt;, 32, 40&gt; b;</div><div>};</div><div><br><=
/div>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=
=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 9:50:54 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vicente J. Botet Escriba =
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 15/12/2016 =C3=A0 01:46, Ivan G. a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color:#fafafa;border-color:#bbb;border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code>
            <div><span style=3D"color:#008">namespace</span><span style=3D"=
color:#000"> std<br>
              </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"> </span>
              <table>
                <tbody>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        le </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Little endian
                        storage implementation */</span><span style=3D"colo=
r:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0</span><span><spa=
n style=3D"color:#000"> =C2=A0</span><span style=3D"color:#008">template</s=
pan><span style=3D"color:#000"> </span></span><span style=3D"color:#660">&l=
t;</span><span><span style=3D"color:#008">typename</span></span><span style=
=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        be </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Big endian stora=
ge
                        implementation */</span><span style=3D"color:#660">=
;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        ne </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        native or fastest endianness */</span><span style=
=3D"color:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        re </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        the opposite to &quot;native&quot; one */</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br>
                      </span><span style=3D"color:#660">}</span></td>
                  </tr>
                </tbody>
              </table>
              <span style=3D"color:#000"><br>
              </span></div>
          </code></div>
        <br>
        <div>Four template aliases produce types with the following
          characteristics:</div>
        <div>1) POD type with size =3D sizeof(Type) and specified
          Alignment.</div>
        <div>2) Additional constructor and assignment operator which
          accept const Type&amp;.</div>
        <div>3) Method get() and conversion operator which return Type.</di=
v>
        <div>4) Internal representation is implementation-defined for a
          particular type.</div>
        <div>5) Typedefs &#39;value_type&#39; =3D Type and &#39;data_type&#=
39; =3D
          implementation-defined.</div>
        <div>6) Public member <font face=3D"arial,sans-serif">&#39;</font>d=
ata&#39;</div>
        <div><br>
        </div>
        <div>If native endianness is LE or BE, the opposite endianness
          just reverses the byte order for *any* type.</div>
        <div>I don&#39;t know much about the systems with &quot;middle
          endianness&quot;.</div>
        <div>So I can&#39;t determine well which behaviour is guaranteed an=
d
          which is implementation-defined.</div>
        <div><br>
        </div>
        <div>Trivial implementation for C++11:</div>
        <div><a href=3D"https://github.com/Nekotekina/giggle-endian/blob/ma=
ster/endian.hpp" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNekotek=
ina%2Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x3d1\x2=
6usg\x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA&#39;;return true;" onclick=3D"th=
is.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FN=
ekotekina%2Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA&#39;;return true;">https:/=
/github.com/Nekotekina/giggle-endian/blob/master/endian.hpp</a></div>
        <div><br>
        </div>
        <div>There is, of course, boost/endian, and it&#39;s different in
          many ways.</div>
        <div>=C2=A0My implementation contains only the very basic
          functionality.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    <br>
    We have used this revert technique, but with two different Type
    representations depending on the endianess.<br>
    <br>
    #if BIG<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    };<br>
    <br>
    #elsif LITTLE<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    };<br>
    #endif<br>
    <br>
    Now reverting the octects in the buffer moves from one
    representation to the other.<br>
    Your implementation will work only when the Type is packed and
    trivial, isn&#39;t it?<br>
    Am I missing something?<br>
    <br>
    Having the same Type description will need some extra reflection and
    meta-programming to copy each one of the fields to the good offset
    in addition to reverse the octects.<br>
    <br>
    Vicente<br>
  </div>

</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/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9bf3-4bc9-9723-092db1c258b6=
%40isocpp.org</a>.<br />

------=_Part_138_538932111.1481796660436--

------=_Part_137_1442851889.1481796660435--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 15 Dec 2016 10:31:17 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">struct X { int x; };</div><div style=3D"width: 100%; font-size:=
 initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color:=
 rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255=
);">struct Y { char a,b,c,d; };</div><div style=3D"width: 100%; font-size: =
initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: =
rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255)=
;"><br></div><div style=3D"width: 100%; font-size: initial; font-family: Ca=
libri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-a=
lign: initial; background-color: rgb(255, 255, 255);">be&lt;X&gt; bex;</div=
><div style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slat=
e Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initia=
l; background-color: rgb(255, 255, 255);">be&lt;Y&gt; bey;</div><div style=
=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', san=
s-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; backgrou=
nd-color: rgb(255, 255, 255);"><br></div><div style=3D"width: 100%; font-si=
ze: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; col=
or: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, =
255);">bex should flip the bytes, bey shouldn't. How does that work?</div><=
div style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate =
Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial;=
 background-color: rgb(255, 255, 255);"><br></div>                         =
                                                                           =
                                 <div style=3D"width: 100%; font-size: init=
ial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(=
31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><=
br style=3D"display:initial"></div>                                        =
                                                                           =
                                                                           =
     <div style=3D"font-size: initial; font-family: Calibri, 'Slate Pro', s=
ans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; backgr=
ound-color: rgb(255, 255, 255);">Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&nbs=
p;portable&nbsp;Babbage&nbsp;Device</div>                                  =
                                                                           =
                                                                     <table=
 width=3D"100%" style=3D"background-color:white;border-spacing:0px;"> <tbod=
y><tr><td colspan=3D"2" style=3D"font-size: initial; text-align: initial; b=
ackground-color: rgb(255, 255, 255);">                           <div style=
=3D"border-style: solid none none; border-top-color: rgb(181, 196, 223); bo=
rder-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha S=
ans', 'Slate Pro'; font-size: 10pt;">  <div><b>From: </b>Ivan G.</div><div>=
<b>Sent: </b>Thursday, December 15, 2016 5:11 AM</div><div><b>To: </b>ISO C=
++ Standard - Future Proposals</div><div><b>Reply To: </b>std-proposals@iso=
cpp.org</div><div><b>Subject: </b>Re: [std-proposals] Simple endianness sup=
port template proposal</div></div></td></tr></tbody></table><div style=3D"b=
order-style: solid none none; border-top-color: rgb(186, 188, 209); border-=
top-width: 1pt; font-size: initial; text-align: initial; background-color: =
rgb(255, 255, 255);"></div><br><div id=3D"_originalContent" style=3D""><div=
 dir=3D"ltr"><div>Hi, I think the Type must not necessarily be packed and t=
rivial.<br></div><div><br></div><div>I'm not sure I understood the example.=
 Assuming the disk/network endianness is fixed, big endian, and bitfields a=
re always MSB-&gt;LSB, it could be:</div><div><br></div><div>
<div>struct X_impl {</div><div>&nbsp; &nbsp; int64_t a : 32;</div><div>&nbs=
p; &nbsp; int64_t b : 8;</div><div>&nbsp; &nbsp; int64_t : 24;</div><div>};=
</div>using X =3D std::be&lt;X_impl&gt;;</div><div><br></div><div>Other pos=
sibilities:</div><div><br></div><div>struct X {</div><div>&nbsp; &nbsp; std=
::be&lt;int32_t, 4&gt; a;</div><div>&nbsp; &nbsp; int8_t b; // Fixed positi=
on</div><div>};</div><div><br></div><div>union X {</div><div>&nbsp; &nbsp; =
int64_t _data;</div><div>&nbsp; &nbsp; bitfield_emulation&lt;int64_t, 0, 32=
&gt; a;</div><div>&nbsp; &nbsp; bitfield_emulation&lt;int64_t, 32, 40&gt; b=
;</div><div>};</div><div><br></div><div>union X {</div><div>&nbsp; &nbsp; s=
td::be&lt;int64_t&gt; _data;</div><div>&nbsp; &nbsp; bitfield_emulation&lt;=
std::be&lt;int64_t&gt;, 0, 32&gt; a;</div><div>&nbsp; &nbsp; bitfield_emula=
tion&lt;std::be&lt;int64_t&gt;, 32, 40&gt; b;</div><div>};</div><div><br></=
div>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=
=D0=B1=D1=80=D1=8F 2016 =D0=B3., 9:50:54 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vicente J. Botet Escriba =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 15/12/2016 =C3=A0 01:46, Ivan G. a
      =C3=A9crit&nbsp;:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color:#fafafa;border-color:#bbb;border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code>
            <div><span style=3D"color:#008">namespace</span><span style=3D"=
color:#000"> std<br>
              </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"> </span>
              <table>
                <tbody>
                  <tr>
                    <td><span style=3D"color:#000">&nbsp; &nbsp;</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp; &nbsp;</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        le </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Little endian
                        storage implementation */</span><span style=3D"colo=
r:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp;</span><span><spa=
n style=3D"color:#000"> &nbsp;</span><span style=3D"color:#008">template</s=
pan><span style=3D"color:#000"> </span></span><span style=3D"color:#660">&l=
t;</span><span><span style=3D"color:#008">typename</span></span><span style=
=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp; &nbsp;</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        be </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Big endian stora=
ge
                        implementation */</span><span style=3D"color:#660">=
;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">&nbsp; &nbsp;</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp; &nbsp;</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        ne </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        native or fastest endianness */</span><span style=
=3D"color:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">&nbsp; &nbsp;</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> &nbsp; &nbsp;</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        re </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        the opposite to "native" one */</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br>
                      </span><span style=3D"color:#660">}</span></td>
                  </tr>
                </tbody>
              </table>
              <span style=3D"color:#000"><br>
              </span></div>
          </code></div>
        <br>
        <div>Four template aliases produce types with the following
          characteristics:</div>
        <div>1) POD type with size =3D sizeof(Type) and specified
          Alignment.</div>
        <div>2) Additional constructor and assignment operator which
          accept const Type&amp;.</div>
        <div>3) Method get() and conversion operator which return Type.</di=
v>
        <div>4) Internal representation is implementation-defined for a
          particular type.</div>
        <div>5) Typedefs 'value_type' =3D Type and 'data_type' =3D
          implementation-defined.</div>
        <div>6) Public member <font face=3D"arial,sans-serif">'</font>data'=
</div>
        <div><br>
        </div>
        <div>If native endianness is LE or BE, the opposite endianness
          just reverses the byte order for *any* type.</div>
        <div>I don't know much about the systems with "middle
          endianness".</div>
        <div>So I can't determine well which behaviour is guaranteed and
          which is implementation-defined.</div>
        <div><br>
        </div>
        <div>Trivial implementation for C++11:</div>
        <div><a href=3D"https://github.com/Nekotekina/giggle-endian/blob/ma=
ster/endian.hpp" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNekotekina%=
2Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x3d1\x26usg=
\x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA';return true;" onclick=3D"this.href=
=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNekotekina%2=
Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA';return true;">https://github.com/Nek=
otekina/giggle-endian/blob/master/endian.hpp</a></div>
        <div><br>
        </div>
        <div>There is, of course, boost/endian, and it's different in
          many ways.</div>
        <div>&nbsp;My implementation contains only the very basic
          functionality.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    <br>
    We have used this revert technique, but with two different Type
    representations depending on the endianess.<br>
    <br>
    #if BIG<br>
    struct X {<br>
    &nbsp;&nbsp;&nbsp; int32_t a;<br>
    &nbsp;&nbsp;&nbsp; int8_t b;<br>
    &nbsp;&nbsp;&nbsp; int32_t : 24;<br>
    };<br>
    <br>
    #elsif LITTLE<br>
    struct X {<br>
    &nbsp;&nbsp;&nbsp; int32_t : 24;<br>
    &nbsp;&nbsp;&nbsp; int8_t b;<br>
    &nbsp;&nbsp;&nbsp; int32_t a;<br>
    };<br>
    #endif<br>
    <br>
    Now reverting the octects in the buffer moves from one
    representation to the other.<br>
    Your implementation will work only when the Type is packed and
    trivial, isn't it?<br>
    Am I missing something?<br>
    <br>
    Having the same Type description will need some extra reflection and
    meta-programming to copy each one of the fields to the good offset
    in addition to reverse the octects.<br>
    <br>
    Vicente<br>
  </div>

</blockquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9bf3-4bc9-9723-092db1c2=
58b6%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>

<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/20161215153117.4898897.37939.21434%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20161215153117.4898897.37939.21434%40gm=
ail.com</a>.<br />

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 08:16:38 -0800 (PST)
Raw View
------=_Part_391_195402636.1481818598308
Content-Type: multipart/alternative;
 boundary="----=_Part_392_502391385.1481818598309"

------=_Part_392_502391385.1481818598309
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

be<Y> won't work. Sorry for possible confusion.
But who would write be<Y> if just Y works regardless of actual endianness?
be<X> works and it may be useful for types which actually wrap int and=20
other basic types.

struct X { be<int> x; }; is preferred approach for general case.
It's effectively the same struct as { int x; } but preserves endianness.
It is just slightly inefficient in both code complexity and performance.
Byte swapping is pretty well accelerated on modern CPUs + compiler=20
optimizations (LLVM handles byteswaps excellently in my opinion).
Manually swapping bytes in order to produce native-endian struct is much=20
more annoying and error-prone.

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 18:31:22 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Tony V E =D0=BD=D0=B0=D0=BF=D0=
=B8=D1=81=D0=B0=D0=BB:
>
> struct X { int x; };
> struct Y { char a,b,c,d; };
>
> be<X> bex;
> be<Y> bey;
>
> bex should flip the bytes, bey shouldn't. How does that work?
>
>
> Sent from my BlackBerry portable Babbage Device
> *From: *Ivan G.
> *Sent: *Thursday, December 15, 2016 5:11 AM
> *To: *ISO C++ Standard - Future Proposals
> *Reply To: *std-pr...@isocpp.org <javascript:>
> *Subject: *Re: [std-proposals] Simple endianness support template proposa=
l
>
> Hi, I think the Type must not necessarily be packed and trivial.
>
> I'm not sure I understood the example. Assuming the disk/network=20
> endianness is fixed, big endian, and bitfields are always MSB->LSB, it=20
> could be:
>
> struct X_impl {
>     int64_t a : 32;
>     int64_t b : 8;
>     int64_t : 24;
> };
> using X =3D std::be<X_impl>;
>
> Other possibilities:
>
> struct X {
>     std::be<int32_t, 4> a;
>     int8_t b; // Fixed position
> };
>
> union X {
>     int64_t _data;
>     bitfield_emulation<int64_t, 0, 32> a;
>     bitfield_emulation<int64_t, 32, 40> b;
> };
>
> union X {
>     std::be<int64_t> _data;
>     bitfield_emulation<std::be<int64_t>, 0, 32> a;
>     bitfield_emulation<std::be<int64_t>, 32, 40> b;
> };
>
> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=
=D0=B1=D1=80=D1=8F 2016 =D0=B3., 9:50:54 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vicente J. Botet=20
> Escriba =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> Le 15/12/2016 =C3=A0 01:46, Ivan G. a =C3=A9crit :
>>
>> namespace std
>> {=20
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>>    using le =3D /* Little endian storage implementation */;=20
>>  =20
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>>    using be =3D /* Big endian storage implementation */;=20
>>
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>>    using ne =3D /* Either LE or BE: native or fastest endianness */;=20
>>
>>    template <typename Type, std::size_t Alignment =3D alignof(T)>=20
>>    using re =3D /* Either LE or BE: the opposite to "native" one */;
>> }=20
>>
>> Four template aliases produce types with the following characteristics:
>> 1) POD type with size =3D sizeof(Type) and specified Alignment.
>> 2) Additional constructor and assignment operator which accept const=20
>> Type&.
>> 3) Method get() and conversion operator which return Type.
>> 4) Internal representation is implementation-defined for a particular=20
>> type.
>> 5) Typedefs 'value_type' =3D Type and 'data_type' =3D implementation-def=
ined.
>> 6) Public member 'data'
>>
>> If native endianness is LE or BE, the opposite endianness just reverses=
=20
>> the byte order for *any* type.
>> I don't know much about the systems with "middle endianness".
>> So I can't determine well which behaviour is guaranteed and which is=20
>> implementation-defined.
>>
>> Trivial implementation for C++11:
>> https://github.com/Nekotekina/giggle-endian/blob/master/endian.hpp
>>
>> There is, of course, boost/endian, and it's different in many ways.
>>  My implementation contains only the very basic functionality.
>>
>> Hi,
>>
>> We have used this revert technique, but with two different Type=20
>> representations depending on the endianess.
>>
>> #if BIG
>> struct X {
>>     int32_t a;
>>     int8_t b;
>>     int32_t : 24;
>> };
>>
>> #elsif LITTLE
>> struct X {
>>     int32_t : 24;
>>     int8_t b;
>>     int32_t a;
>> };
>> #endif
>>
>> Now reverting the octects in the buffer moves from one representation to=
=20
>> the other.
>> Your implementation will work only when the Type is packed and trivial,=
=20
>> isn't it?
>> Am I missing something?
>>
>> Having the same Type description will need some extra reflection and=20
>> meta-programming to copy each one of the fields to the good offset in=20
>> addition to reverse the octects.
>>
>> Vicente
>>
> --=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9bf=
3-4bc9-9723-092db1c258b6%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9b=
f3-4bc9-9723-092db1c258b6%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
>

--=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/9bf2c8ac-6c7a-4cdf-a64e-ae8b7b4f76ef%40isocpp.or=
g.

------=_Part_392_502391385.1481818598309
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>be&lt;Y&gt; won&#39;t work. Sorry for possible confus=
ion.<br></div><div>But who would write be&lt;Y&gt; if just Y works regardle=
ss of actual endianness?</div><div>be&lt;X&gt; works and it may be useful f=
or types which actually wrap int and other basic types.</div><div><br></div=
><div>struct X { be&lt;int&gt; x; }; is preferred approach for general case=
..</div><div>It&#39;s effectively the same struct as { int x; } but preserve=
s endianness.</div><div>It is just slightly inefficient in both code comple=
xity and performance.</div><div>Byte swapping is pretty well accelerated on=
 modern CPUs + compiler optimizations (LLVM handles byteswaps excellently i=
n my opinion).</div><div>Manually swapping bytes in order to produce native=
-endian struct is much more annoying and error-prone.</div><br>=D1=87=D0=B5=
=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=B1=D1=80=D1=
=8F 2016 =D0=B3., 18:31:22 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Tony V E =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div lang=3D"en-US" =
style=3D"background-color:rgb(255,255,255);line-height:initial">           =
                                                                           =
<div style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slate P=
ro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backg=
round-color:rgb(255,255,255)">struct X { int x; };</div><div style=3D"width=
:100%;font-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,=
sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255=
,255,255)">struct Y { char a,b,c,d; };</div><div style=3D"width:100%;font-s=
ize:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;c=
olor:rgb(31,73,125);text-align:initial;background-color:rgb(255,255,255)"><=
br></div><div style=3D"width:100%;font-size:initial;font-family:Calibri,&#3=
9;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:init=
ial;background-color:rgb(255,255,255)">be&lt;X&gt; bex;</div><div style=3D"=
width:100%;font-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-s=
erif,sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rg=
b(255,255,255)">be&lt;Y&gt; bey;</div><div style=3D"width:100%;font-size:in=
itial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:r=
gb(31,73,125);text-align:initial;background-color:rgb(255,255,255)"><br></d=
iv><div style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slat=
e Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;ba=
ckground-color:rgb(255,255,255)">bex should flip the bytes, bey shouldn&#39=
;t. How does that work?</div><div style=3D"width:100%;font-size:initial;fon=
t-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,=
125);text-align:initial;background-color:rgb(255,255,255)"><br></div>      =
                                                                           =
                                                    <div style=3D"width:100=
%;font-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans=
-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,255=
,255)"><br style=3D"display:initial"></div>                                =
                                                                           =
                                                                           =
             <div style=3D"font-size:initial;font-family:Calibri,&#39;Slate=
 Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;bac=
kground-color:rgb(255,255,255)">Sent=C2=A0from=C2=A0my=C2=A0BlackBerry=C2=
=A0portable=C2=A0Babbage=C2=A0Device</div>                                 =
                                                                           =
                                                                      <tabl=
e width=3D"100%" style=3D"background-color:white;border-spacing:0px"> <tbod=
y><tr><td colspan=3D"2" style=3D"font-size:initial;text-align:initial;backg=
round-color:rgb(255,255,255)">                           <div style=3D"bord=
er-style:solid none none;border-top-color:rgb(181,196,223);border-top-width=
:1pt;padding:3pt 0in 0in;font-family:Tahoma,&#39;BB Alpha Sans&#39;,&#39;Sl=
ate Pro&#39;;font-size:10pt">  <div><b>From: </b>Ivan G.</div><div><b>Sent:=
 </b>Thursday, December 15, 2016 5:11 AM</div><div><b>To: </b>ISO C++ Stand=
ard - Future Proposals</div><div><b>Reply To: </b><a href=3D"javascript:" t=
arget=3D"_blank" gdf-obfuscated-mailto=3D"ZUQB3kkdCgAJ" rel=3D"nofollow" on=
mousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"thi=
s.href=3D&#39;javascript:&#39;;return true;">std-pr...@isocpp.org</a></div>=
<div><b>Subject: </b>Re: [std-proposals] Simple endianness support template=
 proposal</div></div></td></tr></tbody></table><br><div><div dir=3D"ltr"><d=
iv>Hi, I think the Type must not necessarily be packed and trivial.<br></di=
v><div><br></div><div>I&#39;m not sure I understood the example. Assuming t=
he disk/network endianness is fixed, big endian, and bitfields are always M=
SB-&gt;LSB, it could be:</div><div><br></div><div>
<div>struct X_impl {</div><div>=C2=A0 =C2=A0 int64_t a : 32;</div><div>=C2=
=A0 =C2=A0 int64_t b : 8;</div><div>=C2=A0 =C2=A0 int64_t : 24;</div><div>}=
;</div>using X =3D std::be&lt;X_impl&gt;;</div><div><br></div><div>Other po=
ssibilities:</div><div><br></div><div>struct X {</div><div>=C2=A0 =C2=A0 st=
d::be&lt;int32_t, 4&gt; a;</div><div>=C2=A0 =C2=A0 int8_t b; // Fixed posit=
ion</div><div>};</div><div><br></div><div>union X {</div><div>=C2=A0 =C2=A0=
 int64_t _data;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt;int64_t, 0, 3=
2&gt; a;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt;int64_t, 32, 40&gt; =
b;</div><div>};</div><div><br></div><div>union X {</div><div>=C2=A0 =C2=A0 =
std::be&lt;int64_t&gt; _data;</div><div>=C2=A0 =C2=A0 bitfield_emulation&lt=
;std::be&lt;int64_t&gt;, 0, 32&gt; a;</div><div>=C2=A0 =C2=A0 bitfield_emul=
ation&lt;std::be&lt;int64_t&gt;, 32, 40&gt; b;</div><div>};</div><div><br><=
/div>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=
=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 9:50:54 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vicente J. Botet Escriba =
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 15/12/2016 =C3=A0 01:46, Ivan G. a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div style=3D"background-color:#fafafa;border-color:#bbb;border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code>
            <div><span style=3D"color:#008">namespace</span><span style=3D"=
color:#000"> std<br>
              </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"> </span>
              <table>
                <tbody>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        le </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Little endian
                        storage implementation */</span><span style=3D"colo=
r:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0</span><span><spa=
n style=3D"color:#000"> =C2=A0</span><span style=3D"color:#008">template</s=
pan><span style=3D"color:#000"> </span></span><span style=3D"color:#660">&l=
t;</span><span><span style=3D"color:#008">typename</span></span><span style=
=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        be </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Big endian stora=
ge
                        implementation */</span><span style=3D"color:#660">=
;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        ne </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        native or fastest endianness */</span><span style=
=3D"color:#660">;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"><br>
                      </span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000">=C2=A0 =C2=A0</span><spa=
n><span style=3D"color:#008">template</span><span style=3D"color:#000"> </s=
pan></span><span style=3D"color:#660">&lt;</span><span><span style=3D"color=
:#008">typename</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000">
                        std</span><span style=3D"color:#660">::</span><span=
><span style=3D"color:#000">size_t</span></span><span style=3D"color:#000">
                      </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000">
                      </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000">
                      </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td>
                  </tr>
                  <tr>
                    <td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><sp=
an><span style=3D"color:#008">using</span></span><span style=3D"color:#000"=
>
                        re </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000">
                      </span><span style=3D"color:#800">/* Either LE or BE:
                        the opposite to &quot;native&quot; one */</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br>
                      </span><span style=3D"color:#660">}</span></td>
                  </tr>
                </tbody>
              </table>
              <span style=3D"color:#000"><br>
              </span></div>
          </code></div>
        <br>
        <div>Four template aliases produce types with the following
          characteristics:</div>
        <div>1) POD type with size =3D sizeof(Type) and specified
          Alignment.</div>
        <div>2) Additional constructor and assignment operator which
          accept const Type&amp;.</div>
        <div>3) Method get() and conversion operator which return Type.</di=
v>
        <div>4) Internal representation is implementation-defined for a
          particular type.</div>
        <div>5) Typedefs &#39;value_type&#39; =3D Type and &#39;data_type&#=
39; =3D
          implementation-defined.</div>
        <div>6) Public member <font face=3D"arial,sans-serif">&#39;</font>d=
ata&#39;</div>
        <div><br>
        </div>
        <div>If native endianness is LE or BE, the opposite endianness
          just reverses the byte order for *any* type.</div>
        <div>I don&#39;t know much about the systems with &quot;middle
          endianness&quot;.</div>
        <div>So I can&#39;t determine well which behaviour is guaranteed an=
d
          which is implementation-defined.</div>
        <div><br>
        </div>
        <div>Trivial implementation for C++11:</div>
        <div><a href=3D"https://github.com/Nekotekina/giggle-endian/blob/ma=
ster/endian.hpp" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.hre=
f=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNekotek=
ina%2Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x3d1\x2=
6usg\x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA&#39;;return true;" onclick=3D"th=
is.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FN=
ekotekina%2Fgiggle-endian%2Fblob%2Fmaster%2Fendian.hpp\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNEz4urWGZWe7UwZ-ceCvjc2MPPhrA&#39;;return true;">https:/=
/github.com/Nekotekina/giggle-endian/blob/master/endian.hpp</a></div>
        <div><br>
        </div>
        <div>There is, of course, boost/endian, and it&#39;s different in
          many ways.</div>
        <div>=C2=A0My implementation contains only the very basic
          functionality.</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    <br>
    We have used this revert technique, but with two different Type
    representations depending on the endianess.<br>
    <br>
    #if BIG<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    };<br>
    <br>
    #elsif LITTLE<br>
    struct X {<br>
    =C2=A0=C2=A0=C2=A0 int32_t : 24;<br>
    =C2=A0=C2=A0=C2=A0 int8_t b;<br>
    =C2=A0=C2=A0=C2=A0 int32_t a;<br>
    };<br>
    #endif<br>
    <br>
    Now reverting the octects in the buffer moves from one
    representation to the other.<br>
    Your implementation will work only when the Type is packed and
    trivial, isn&#39;t it?<br>
    Am I missing something?<br>
    <br>
    Having the same Type description will need some extra reflection and
    meta-programming to copy each one of the fields to the good offset
    in addition to reverse the octects.<br>
    <br>
    Vicente<br>
  </div>

</blockquote></div>



-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
ZUQB3kkdCgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"ZUQB3kkdCgAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@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/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/fb9cfe75-9bf3-4bc9-9723-092db1c258b6%40=
isocpp.org</a>.<br>
<br></div></div>
</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/9bf2c8ac-6c7a-4cdf-a64e-ae8b7b4f76ef%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9bf2c8ac-6c7a-4cdf-a64e-ae8b7b4f76ef=
%40isocpp.org</a>.<br />

------=_Part_392_502391385.1481818598309--

------=_Part_391_195402636.1481818598308--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 15 Dec 2016 08:27:35 -0800 (PST)
Raw View
------=_Part_331_1067204892.1481819255509
Content-Type: multipart/alternative;
 boundary="----=_Part_332_1430412224.1481819255510"

------=_Part_332_1430412224.1481819255510
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thursday, December 15, 2016 at 4:17:14 AM UTC-5, Ivan G. wrote:
>
> Thanks, the main purpose of endian storage types is the ability to create=
=20
> a struct with "endian" members. Another purpose is the ability to overwri=
te=20
> type alignment, so it can effectively replace #pragma pack.
> struct my_type
> {
>     std::be<std::uint32_t, 2> x;
>     std::be<std::uint32_t, 2> y;
> };
>
> static_assert(alignof(my_type) =3D=3D 2, "Invalid my_type alignment");
>
>
>
> Constructor takes `const Type&` and reads its internal representation,=20
> byte after byte. The bytes are stored in normal or reversed order,=20
> depending on the endianness.
> This applies to user-defined types as well (of course they shall be=20
> trivially copyable, but I can't define exact limitations).
> In the case of pair of ints, my opinion is:
> 1) In the most simple case, it should probably be replaced with a pair of=
=20
> `be<int>` or `le<int>`.
> 2) Byte representation is accessed from the first byte to the last byte,=
=20
> regardless of the actual type. It will probably swap the ints.
> 3) Pair of ints, as well as any other imaginable type, should be supporte=
d=20
> anyway because it may be exactly what the programmer wants.
>  Of course, I said "any type" incorrectly, sorry about this. But I don't=
=20
> want to limit endianness support with basic types only. For some types it=
=20
> will cause undefined behaviour, or maybe hit static_assert.
>

The problem I have with this is that it doesn't seem possible at present to=
=20
adequately restrict the types that these things take. You don't want to=20
limit it to the types we can easily guarantee it will work for (ie: basic=
=20
types). OK, so... how do you intend to *prevent* it from being used with=20
types where it cannot work? Because otherwise, it's way too dangerous to=20
use. It gives the impression that `le<Anything>` is viable, even when it's=
=20
not.

With static reflection, you would have the means to detect whether it was=
=20
viable or not. But then again, with static reflection, you would have the=
=20
means to perform endian conversion for any trivially copyable type.

So what do you plan to do in the meantime, before static reflection exists?=
=20
What mechanism can you use to ensure that users don't use the type=20
improperly?

That's what I don't like about these types: their interface appears to make=
=20
a promise that their implementation cannot (yet) keep. If the restrictions=
=20
on `T` cannot be a rule that the compiler can detect, then these types=20
ought to wait until static reflection allows us to detect it.
=20

> Method `get()`, as well as the conversion operator, reconstructs a value=
=20
> of type `Type` from its byte representation, loaded from endian storage.
> Member `data` has implementation-defined type (probably an array of=20
> unsigned chars). It's not too useful for the programmer, but I can imagin=
e=20
> some uses cases. It always was a private member in my previous experience=
,=20
> but coexisted with another methods to access the internal representation.
>

There's only one thing you can do to the internal representation: copy it=
=20
elsewhere. Since the type isn't allocating memory for the internal data,=20
there's no need to have a variable. Just declare that the type shall be=20
trivially copyable, and its value representation shall be the=20
endian-converted value of `T`. If a user wants to copy it to a byte array,=
=20
that's what `memcpy` is for.

No need to expose a `data` member variable.

`CopyFromLEToNE` or similar functions can be provided independently, since=
=20
> they have their use cases as well. Or easily be emulated with be<> or le<=
>=20
> types.
>

How exactly could they be emulated? At the very least, they would require=
=20
an additional copy. And copying from non-native endians requires providing=
=20
a pointer to raw memory, not a type. So I'm not sure how you would emulate=
=20
that.

Your types ultimately *rely upon* the existence of such functions.=20
Providing them as part of an independent proposal makes no sense. That kind=
=20
of thinking, providing high-level features externally to low-level ones=20
that they rely on, is why we had to suffer the limitations of=20
`std::to_string` and `std::stoi` for 6 years, until C++17 when we finally=
=20
got low-level string conversion functions.

Providing high-level types is good. But if they rely on low-level utilities=
=20
that would be generally useful, then those ought to be exposed at the same=
=20
time. They shouldn't wait on someone else to do it.


> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=
=D0=B1=D1=80=D1=8F 2016 =D0=B3., 5:04:50 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Nicol Bolas=20
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>>
>>
>> On Wednesday, December 14, 2016 at 7:46:23 PM UTC-5, Ivan G. wrote:
>>>
>>> namespace std
>>> {=20
>>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>>    using le =3D /* Little endian storage implementation */;
>>> =20
>>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>>    using be =3D /* Big endian storage implementation */;
>>>
>>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>>    using ne =3D /* Either LE or BE: native or fastest endianness */;
>>>
>>>    template <typename Type, std::size_t Alignment =3D alignof(T)>
>>>    using re =3D /* Either LE or BE: the opposite to "native" one */;
>>> }
>>>
>>> Four template aliases produce types with the following characteristics:
>>> 1) POD type with size =3D sizeof(Type) and specified Alignment.
>>> 2) Additional constructor and assignment operator which accept const=20
>>> Type&.
>>> 3) Method get() and conversion operator which return Type.
>>> 4) Internal representation is implementation-defined for a particular=
=20
>>> type.
>>> 5) Typedefs 'value_type' =3D Type and 'data_type' =3D implementation-de=
fined.
>>> 6) Public member 'data'
>>>
>>
>> OK, that functionality is interesting. Now... what exactly would you use=
=20
>> any of these types to actually do?
>>
>> You say the types have a constructor that accepts a `const Type&`. OK...=
=20
>> what does it do with that value? What does `get` and the conversion=20
>> operator return? What does this "public member 'data'" store?
>>
>> In short, what is the purpose of these types?
>>
>> If these types are intended to represent some kind of buffered storage=
=20
>> for an endian-converted object, I'd much rather have functions to actual=
ly=20
>> do the conversion: CopyFromLEToNE, CopyFromNEToBE, etc. They would take =
a=20
>> `const T&` and be given a region of storage you provide which will be=20
>> copied into.
>> =20
>>
>>> If native endianness is LE or BE, the opposite endianness just reverses=
=20
>>> the byte order for *any* type.
>>>
>>
>> How is that possible with user-defined `Type`s? After, `Type` can have=
=20
>> multiple basic types stored in it. And endian-ness only applies to basic=
=20
>> types. If you have a type that stores a pair of `int`s, how could this=
=20
>> object know that it needs to flip the first sizeof(int) bytes, then the=
=20
>> next sizeof(int) bytes?
>>
>> And even if it could know deconstruct a type and endian convert its=20
>> internals (and that's a big if, since we're potentially talking about=20
>> accessing private members), this would only be viable for types which ar=
e=20
>> trivially copyable. So "any type" isn't going to happen.
>>
>

--=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/97ff2223-0940-451f-90cf-14ab8d407354%40isocpp.or=
g.

------=_Part_332_1430412224.1481819255510
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, December 15, 2016 at 4:17:14 AM UTC-5, Ivan G=
.. wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>=
Thanks, the main purpose of endian storage types is the ability to create a=
 struct with &quot;endian&quot; members. Another purpose is the ability to =
overwrite type alignment, so it can effectively replace #pragma pack.<br></=
div><div><div style=3D"background-color:#fafafa;border-color:#bbb;border-st=
yle:solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"=
color:#008">struct</span><span style=3D"color:#000"> my_type<br></span><spa=
n style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0=
 std</span><span style=3D"color:#660">::</span><span style=3D"color:#000">b=
e</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">st=
d</span><span style=3D"color:#660">::</span><span style=3D"color:#000">uint=
32_t</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#066">2</span><span style=3D"color:#660">&gt;</s=
pan><span style=3D"color:#000"> x</span><span style=3D"color:#660">;</span>=
<span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color=
:#660">::</span><span style=3D"color:#000">be</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000">std</span><span style=3D"color:#6=
60">::</span><span style=3D"color:#000">uint32_t</span><span style=3D"color=
:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#066=
">2</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
 y</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><=
br></span><span style=3D"color:#008">static_assert</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#008">alignof</span><span style=3D"co=
lor:#660">(</span><span style=3D"color:#000">my_type</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:=
#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080">&quot;Invalid my_type alignment&quot;</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br=
></span></div></code></div><br></div><div><br></div><div>Constructor takes =
`const Type&amp;` and reads its internal representation, byte after byte. T=
he bytes are stored in normal or reversed order, depending on the endiannes=
s.</div><div>This applies to user-defined types as well (of course they sha=
ll be trivially copyable, but I can&#39;t define exact limitations).</div><=
div>In the case of pair of ints, my opinion is:</div><div>1) In the most si=
mple case, it should probably be replaced with a pair of `be&lt;int&gt;` or=
 `le&lt;int&gt;`.</div><div>2) Byte representation is accessed from the fir=
st byte to the last byte, regardless of the actual type. It will probably s=
wap the ints.</div><div>3) Pair of ints, as well as any other imaginable ty=
pe, should be supported anyway because it may be exactly what the programme=
r wants.</div><div>=C2=A0Of course, I said &quot;any type&quot; incorrectly=
, sorry about this. But I don&#39;t want to limit endianness support with b=
asic types only. For some types it will cause undefined behaviour, or maybe=
 hit static_assert.</div></div></blockquote><div><br>The problem I have wit=
h this is that it doesn&#39;t seem possible at present to adequately restri=
ct the types that these things take. You don&#39;t want to limit it to the =
types we can easily guarantee it will work for (ie: basic types). OK, so...=
 how do you intend to <i>prevent</i> it from being used with types where it=
 cannot work? Because otherwise, it&#39;s way too dangerous to use. It give=
s the impression that `le&lt;Anything&gt;` is viable, even when it&#39;s no=
t.<br><br>With static reflection, you would have the means to detect whethe=
r it was viable or not. But then again, with static reflection, you would h=
ave the means to perform endian conversion for any trivially copyable type.=
<br><br>So what do you plan to do in the meantime, before static reflection=
 exists? What mechanism can you use to ensure that users don&#39;t use the =
type improperly?<br><br>That&#39;s what I don&#39;t like about these types:=
 their interface appears to make a promise that their implementation cannot=
 (yet) keep. If the restrictions on `T` cannot be a rule that the compiler =
can detect, then these types ought to wait until static reflection allows u=
s to detect it.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr"><div></div><div>
<div>Method `get()`, as well as the conversion operator, reconstructs a val=
ue of type `Type` from its byte representation, loaded from endian storage.=
</div><div>Member `data` has implementation-defined type (probably an array=
 of unsigned chars). It&#39;s not too useful for the programmer, but I can =
imagine some uses cases. It always was a private member in my previous expe=
rience, but coexisted with another methods to access the internal represent=
ation.</div></div></div></blockquote><div><br>There&#39;s only one thing yo=
u can do to the internal representation: copy it elsewhere. Since the type =
isn&#39;t allocating memory for the internal data, there&#39;s no need to h=
ave a variable. Just declare that the type shall be trivially copyable, and=
 its value representation shall be the endian-converted value of `T`. If a =
user wants to copy it to a byte array, that&#39;s what `memcpy` is for.<br>=
<br>No need to expose a `data` member variable.<br><br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div></div><div>`CopyF=
romLEToNE` or similar functions can be provided independently, since they h=
ave their use cases as well. Or easily be emulated with be&lt;&gt; or le&lt=
;&gt; types.</div></div></div></blockquote><div><br>How exactly could they =
be emulated? At the very least, they would require an additional copy. And =
copying from non-native endians requires providing a pointer to raw memory,=
 not a type. So I&#39;m not sure how you would emulate that.<br><br>Your ty=
pes ultimately <i>rely upon</i> the existence of such functions. Providing =
them as part of an independent proposal makes no sense. That kind of thinki=
ng, providing high-level features externally to low-level ones that they re=
ly on, is why we had to suffer the limitations of `std::to_string` and `std=
::stoi` for 6 years, until C++17 when we finally got low-level string conve=
rsion functions.<br><br>Providing high-level types is good. But if they rel=
y on low-level utilities that would be generally useful, then those ought t=
o be exposed at the same time. They shouldn&#39;t wait on someone else to d=
o it.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=
=D0=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 5:04:50 UTC+3 =D0=BF=D0=BE=D0=BB=D1=
=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Nicol Bolas =D0=BD=D0=
=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><br><br>On Wednesday, December 14, 2016 at 7:46:23 PM UTC=
-5, Ivan G. wrote:<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"ltr">=
<div style=3D"background-color:#fafafa;border-color:#bbb;border-style:solid=
;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#00=
8">namespace</span><span style=3D"color:#000"> std<br></span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"> </span><table><tbody><tr><=
td><span style=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span></span><span styl=
e=3D"color:#660">&lt;</span><span><span style=3D"color:#008">typename</span=
></span><span style=3D"color:#000"> </span><span style=3D"color:#606">Type<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</s=
pan><span style=3D"color:#660">::</span><span><span style=3D"color:#000">si=
ze_t</span></span><span style=3D"color:#000"> </span><span style=3D"color:#=
606">Alignment</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">alignof</span><span style=3D"color:#660">(</span><span style=3D"color:=
#000">T</span><span style=3D"color:#660">)&gt;</span></td></tr><tr><td><spa=
n style=3D"color:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008=
">using</span></span><span style=3D"color:#000"> le </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">/* Little endian storage implementation */</span><span style=3D"col=
or:#660">;</span></td></tr><tr><td><span style=3D"color:#000"> =C2=A0</span=
></td></tr><tr><td><span style=3D"color:#000"> =C2=A0</span><span><span sty=
le=3D"color:#000"> =C2=A0</span><span style=3D"color:#008">template</span><=
span style=3D"color:#000"> </span></span><span style=3D"color:#660">&lt;</s=
pan><span><span style=3D"color:#008">typename</span></span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#606">Type</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> std</span><span style=3D"color=
:#660">::</span><span><span style=3D"color:#000">size_t</span></span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Alignment</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">alignof</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span styl=
e=3D"color:#660">)&gt;</span></td></tr><tr><td><span style=3D"color:#000"> =
=C2=A0 =C2=A0</span><span><span style=3D"color:#008">using</span></span><sp=
an style=3D"color:#000"> be </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#800">/* Big endian st=
orage implementation */</span><span style=3D"color:#660">;</span></td></tr>=
<tr><td><span style=3D"color:#000"><br></span></td></tr><tr><td><span style=
=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=3D"color:#008">templa=
te</span><span style=3D"color:#000"> </span></span><span style=3D"color:#66=
0">&lt;</span><span><span style=3D"color:#008">typename</span></span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Type</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> std</span><span styl=
e=3D"color:#660">::</span><span><span style=3D"color:#000">size_t</span></s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#606">Alignment=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">alignof</=
span><span style=3D"color:#660">(</span><span style=3D"color:#000">T</span>=
<span style=3D"color:#660">)&gt;</span></td></tr><tr><td><span style=3D"col=
or:#000"> =C2=A0 =C2=A0</span><span><span style=3D"color:#008">using</span>=
</span><span style=3D"color:#000"> ne </span><span style=3D"color:#660">=3D=
</span><span style=3D"color:#000"> </span><span style=3D"color:#800">/* Eit=
her LE or BE: native or fastest endianness */</span><span style=3D"color:#6=
60">;</span></td></tr><tr><td><span style=3D"color:#000"><br></span></td></=
tr><tr><td><span style=3D"color:#000">=C2=A0 =C2=A0</span><span><span style=
=3D"color:#008">template</span><span style=3D"color:#000"> </span></span><s=
pan style=3D"color:#660">&lt;</span><span><span style=3D"color:#008">typena=
me</span></span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">Type</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> std</span><span style=3D"color:#660">::</span><span><span style=3D"color:=
#000">size_t</span></span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Alignment</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">alignof</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">T</span><span style=3D"color:#660">)&gt;</span></td></tr><t=
r><td><span style=3D"color:#000"> =C2=A0 =C2=A0</span><span><span style=3D"=
color:#008">using</span></span><span style=3D"color:#000"> re </span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#800">/* Either LE or BE: the opposite to &quot;native&quot; on=
e */</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">}</span></td></tr></tbody></table><span=
 style=3D"color:#000"><br></span></div></code></div><br><div>Four template =
aliases produce types with the following characteristics:</div><div>1) POD =
type with size =3D sizeof(Type) and specified Alignment.</div><div>2) Addit=
ional constructor and assignment operator which accept const Type&amp;.</di=
v><div>3) Method get() and conversion operator which return Type.</div><div=
>4) Internal representation is implementation-defined for a particular type=
..</div><div>5) Typedefs &#39;value_type&#39; =3D Type and &#39;data_type&#3=
9; =3D implementation-defined.</div><div>6) Public member <font face=3D"ari=
al,sans-serif">&#39;</font>data&#39;</div></div></blockquote><div><br>OK, t=
hat functionality is interesting. Now... what exactly would you use any of =
these types to actually do?<br><br>You say the types have a constructor tha=
t accepts a `const Type&amp;`. OK... what does it do with that value? What =
does `get` and the conversion operator return? What does this &quot;public =
member &#39;data&#39;&quot; store?<br><br>In short, what is the purpose of =
these types?<br><br>If these types are intended to represent some kind of b=
uffered storage for an endian-converted object, I&#39;d much rather have fu=
nctions to actually do the conversion: CopyFromLEToNE, CopyFromNEToBE, etc.=
 They would take a `const T&amp;` and be given a region of storage you prov=
ide which will be copied into.<br>=C2=A0</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr"><div>If native endianness is LE or BE, the oppo=
site endianness just reverses the byte order for *any* type.</div></div></b=
lockquote><div><br>How is that possible with user-defined `Type`s? After, `=
Type` can have multiple basic types stored in it. And endian-ness only appl=
ies to basic types. If you have a type that stores a pair of `int`s, how co=
uld this object know that it needs to flip the first sizeof(int) bytes, the=
n the next sizeof(int) bytes?<br><br>And even if it could know deconstruct =
a type and endian convert its internals (and that&#39;s a big if, since we&=
#39;re potentially talking about accessing private members), this would onl=
y be viable for types which are trivially copyable. So &quot;any type&quot;=
 isn&#39;t going to happen.<br></div></div></blockquote></div></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/97ff2223-0940-451f-90cf-14ab8d407354%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/97ff2223-0940-451f-90cf-14ab8d407354=
%40isocpp.org</a>.<br />

------=_Part_332_1430412224.1481819255510--

------=_Part_331_1067204892.1481819255509--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 10:07:08 -0800 (PST)
Raw View
------=_Part_378_1627355359.1481825228227
Content-Type: multipart/alternative;
 boundary="----=_Part_379_1209422783.1481825228227"

------=_Part_379_1209422783.1481825228227
Content-Type: text/plain; charset=UTF-8

OK, I must agree, incorrect usage may be the source of unnoticed bugs.

I think there is a compromiss solution: limit be<>/le<> to basic types (+
implementation-defined extensions like uint128_t) and allow manual
extension with user-provided template specializations, like std::hash<>.

I'll also think about the interface of endianness conversion functions.

--
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/4fd43189-9464-41d4-8722-19eea16b6263%40isocpp.org.

------=_Part_379_1209422783.1481825228227
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>OK, I must agree, incorrect usage may be the source o=
f unnoticed bugs.</div><div><br></div><div>I think there is a compromiss so=
lution: limit be&lt;&gt;/le&lt;&gt; to basic types (+ implementation-define=
d extensions like uint128_t) and allow manual extension with user-provided =
template specializations, like std::hash&lt;&gt;.</div><div><br></div><div>=
I&#39;ll also think about the interface of endianness conversion functions.=
</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/4fd43189-9464-41d4-8722-19eea16b6263%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4fd43189-9464-41d4-8722-19eea16b6263=
%40isocpp.org</a>.<br />

------=_Part_379_1209422783.1481825228227--

------=_Part_378_1627355359.1481825228227--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 13:22:11 -0800 (PST)
Raw View
------=_Part_534_568267841.1481836931808
Content-Type: multipart/alternative;
 boundary="----=_Part_535_380096862.1481836931809"

------=_Part_535_380096862.1481836931809
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

namespace std
{
template <typename T, std::size_t Align, bool Native>
class endian_base
{
        static_assert(std::is_arithmetic<T>::value || std::is_enum<T>::valu=
e
, "endian_base<>: invalid type");
public:
        using value_type =3D T;
        endian_base() =3D default;
        endian_base(const T& value);
        endian_base& operator=3D(const endian_base&) =3D default;
        endian_base& operator=3D(const T& value);
        operator T() const;
        T get() const;

        auto operator++(int);
        auto operator--(int);
        endian_base& operator++();
        endian_base& operator--();
        template <typename T2> endian_base& operator+=3D(T2&& rhs);
        template <typename T2> endian_base& operator-=3D(T2&& rhs);
        template <typename T2> endian_base& operator*=3D(T2&& rhs);
        template <typename T2> endian_base& operator/=3D(T2&& rhs);
        template <typename T2> endian_base& operator%=3D(T2&& rhs);
        template <typename T2> endian_base& operator&=3D(T2&& rhs);
        template <typename T2> endian_base& operator|=3D(T2&& rhs);
        template <typename T2> endian_base& operator^=3D(T2&& rhs);
        template <typename T2> endian_base& operator<<=3D(T2&& rhs);
        template <typename T2> endian_base& operator>>=3D(T2&& rhs);
};

template <typename T, std::size_t Align =3D alignof(T)>
using le =3D endian_base<T, Align, endian::native =3D=3D endian::little>;

template <typename T, std::size_t Align =3D alignof(T)>
using be =3D endian_base<T, Align, endian::native =3D=3D endian::big>;

template <typename T>
void le_store(void* dst, const T& value);

template <typename T>
void le_load(T& value, const void* src);

template <typename T>
T le_load(const void* src);

template <typename T>
void be_store(void* dst, const T& value);

template <typename T>
void be_load(T& value, const void* src);

template <typename T>
T be_load(const void* src);
}

Removed ne<>, re<>, exposed endian_base instead.

Added operators and load/store functions.

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 21:07:08 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ivan G. =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
> OK, I must agree, incorrect usage may be the source of unnoticed bugs.
>
> I think there is a compromiss solution: limit be<>/le<> to basic types (+=
=20
> implementation-defined extensions like uint128_t) and allow manual=20
> extension with user-provided template specializations, like std::hash<>.
>
> I'll also think about the interface of endianness conversion functions.
>

--=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/c8adab53-60c7-4e24-8e68-8deb29821f08%40isocpp.or=
g.

------=_Part_535_380096862.1481836931809
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style=3D"background-color: #FAFAFA; border-color: #BB=
B; border-style: solid; border-width: 1px; word-wrap: break-word;" class=3D=
"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">namespace</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std<br></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><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"st=
yled-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"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Align</span><spa=
n 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">bool</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Native</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> endian_base<br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=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">static_assert</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">is_arithmetic</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">value </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">||</span><span st=
yle=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: =
#000;" class=3D"styled-by-prettify">is_enum</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify">value</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;end=
ian_base&lt;&gt;: invalid type&quot;</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">public</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=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">using</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> value_type </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</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: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">defa=
ult</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 endian_base</span><span style=3D"color: #660;" class=3D"style=
d-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"=
>operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endian_bas=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">default</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><spa=
n 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">=3D(</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">operator</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"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">const</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 T </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">get</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">const</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">auto</span><span 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><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"co=
lor: #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">auto</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">--(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #66=
0;" 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 endian_base</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">operator</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">++();</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian=
_base</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">--();</span><span sty=
le=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">tem=
plate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> T2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> endian_base</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">operator</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">+=3D(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">T2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">);</span><span style=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">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endia=
n_base</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">operator</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">-=3D(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> rhs</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><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: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> T2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> endian_base</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">operator</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*=3D(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T=
2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rhs</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=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"=
>template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> T2</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> endian_base</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">/=3D(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">T2</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endia=
n_base</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">operator</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">%=3D(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> rhs</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><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: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> T2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> endian_base</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">operator</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&amp;=3D(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rhs<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><s=
pan style=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-pretti=
fy">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> T2</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> endian_base</span><span sty=
le=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">operator</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">|=3D(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">T2</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> end=
ian_base</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&a=
mp;</span><span 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">^=3D(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">T2</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> rhs</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">);</span><span style=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">template</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> T2</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> endian_base</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">operator</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;&lt;=3D(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> rhs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</=
span><span style=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">template</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typena=
me</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T2</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> endian_base</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </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">&gt;&gt;=3D(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> rhs</span><span style=3D"color: #660;" c=
lass=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"styled-by-pret=
tify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><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"> std</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">size_t </span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">Align</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">alig=
nof</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 st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> le </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endian_base</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</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=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Align</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> endian</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">native</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> endian</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">little</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&gt;;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">template</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</sp=
an><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"> std</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">size_t </span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">Align</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">a=
lignof</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">)&gt;</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">using</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> be </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endian_base</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</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=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Align</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> endian</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">native</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> endian</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">big</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&gt;;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> le_store</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> dst</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> value</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;" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> le_load</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> value</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">const</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> src</span><span s=
tyle=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"co=
lor: #008;" class=3D"styled-by-prettify">template</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>T le_load</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> src</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: #0=
08;" class=3D"styled-by-prettify">template</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</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">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> be_store<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> dst</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> v=
alue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">typename</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"><br></span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> be_load</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> src</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
emplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>T be_load</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">void</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> src</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code=
></div><br>Removed ne&lt;&gt;, re&lt;&gt;, exposed endian_base instead.<div=
><br></div><div>Added operators and load/store functions.<br></div><br>=D1=
=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=B1=
=D1=80=D1=8F 2016 =D0=B3., 21:07:08 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ivan G. =D0=BD=D0=B0=D0=BF=D0=B8=D1=
=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div>OK, I must agree, incorrect usage may be the source of unnoticed bu=
gs.</div><div><br></div><div>I think there is a compromiss solution: limit =
be&lt;&gt;/le&lt;&gt; to basic types (+ implementation-defined extensions l=
ike uint128_t) and allow manual extension with user-provided template speci=
alizations, like std::hash&lt;&gt;.</div><div><br></div><div>I&#39;ll also =
think about the interface of endianness conversion functions.</div></div></=
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/c8adab53-60c7-4e24-8e68-8deb29821f08%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c8adab53-60c7-4e24-8e68-8deb29821f08=
%40isocpp.org</a>.<br />

------=_Part_535_380096862.1481836931809--

------=_Part_534_568267841.1481836931808--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 15 Dec 2016 15:46:31 -0800 (PST)
Raw View
------=_Part_534_1517100592.1481845592042
Content-Type: multipart/alternative;
 boundary="----=_Part_535_980674262.1481845592044"

------=_Part_535_980674262.1481845592044
Content-Type: text/plain; charset=UTF-8



On Thursday, December 15, 2016 at 4:22:11 PM UTC-5, Ivan G. wrote:
>
> namespace std
> {
> template <typename T, std::size_t Align, bool Native>
> class endian_base
> {
>         static_assert(std::is_arithmetic<T>::value || std::is_enum<T>::
> value, "endian_base<>: invalid type");
> public:
>         using value_type = T;
>         endian_base() = default;
>         endian_base(const T& value);
>         endian_base& operator=(const endian_base&) = default;
>         endian_base& operator=(const T& value);
>         operator T() const;
>         T get() const;
>
>         auto operator++(int);
>         auto operator--(int);
>         endian_base& operator++();
>         endian_base& operator--();
>         template <typename T2> endian_base& operator+=(T2&& rhs);
>         template <typename T2> endian_base& operator-=(T2&& rhs);
>         template <typename T2> endian_base& operator*=(T2&& rhs);
>         template <typename T2> endian_base& operator/=(T2&& rhs);
>         template <typename T2> endian_base& operator%=(T2&& rhs);
>         template <typename T2> endian_base& operator&=(T2&& rhs);
>         template <typename T2> endian_base& operator|=(T2&& rhs);
>         template <typename T2> endian_base& operator^=(T2&& rhs);
>         template <typename T2> endian_base& operator<<=(T2&& rhs);
>         template <typename T2> endian_base& operator>>=(T2&& rhs);
> };
>
> template <typename T, std::size_t Align = alignof(T)>
> using le = endian_base<T, Align, endian::native == endian::little>;
>
> template <typename T, std::size_t Align = alignof(T)>
> using be = endian_base<T, Align, endian::native == endian::big>;
>
> template <typename T>
> void le_store(void* dst, const T& value);
>
> template <typename T>
> void le_load(T& value, const void* src);
>
> template <typename T>
> T le_load(const void* src);
>
> template <typename T>
> void be_store(void* dst, const T& value);
>
> template <typename T>
> void be_load(T& value, const void* src);
>
> template <typename T>
> T be_load(const void* src);
> }
>
>
Pointers ought to be endian-convertible as well. Also, why are you giving
an endian-conversion object operator overloads? That sounds like its trying
to do something more than it should.

--
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/cefdaec0-89a8-471a-b366-d73cb7bc74fa%40isocpp.org.

------=_Part_535_980674262.1481845592044
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, December 15, 2016 at 4:22:11 PM UTC-5=
, Ivan G. wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div style=3D"background-color:#fafafa;border-color:#bbb;border-style:so=
lid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:=
#008">namespace</span><span style=3D"color:#000"> std<br></span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">template</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><spa=
n style=3D"color:#000"> T</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span sty=
le=3D"color:#000">size_t </span><span style=3D"color:#606">Align</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">bool</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Native</span><span style=3D"color:#660">&gt;</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#008">class</span><span =
style=3D"color:#000"> endian_base<br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span=
 style=3D"color:#008">static_assert</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#000">std</span><span style=3D"color:#660">::</span>=
<span style=3D"color:#000">is_<wbr>arithmetic</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:#660=
">&gt;::</span><span style=3D"color:#000">value </span><span style=3D"color=
:#660">||</span><span style=3D"color:#000"> std</span><span style=3D"color:=
#660">::</span><span style=3D"color:#000">is_enum</span><span style=3D"colo=
r:#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:=
#660">&gt;::</span><span style=3D"color:#000">value</span><span style=3D"co=
lor:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#=
080">&quot;endian_base&lt;&gt;: invalid type&quot;</span><span style=3D"col=
or:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">public</span><span style=3D"color:#660">:</span><span style=3D"colo=
r:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">u=
sing</span><span style=3D"color:#000"> value_type </span><span style=3D"col=
or:#660">=3D</span><span style=3D"color:#000"> T</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 e=
ndian_base</span><span style=3D"color:#660">()</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">default</span><span style=3D"color:#66=
0">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endia=
n_base</span><span style=3D"color:#660">(</span><span style=3D"color:#008">=
const</span><span style=3D"color:#000"> T</span><span style=3D"color:#660">=
&amp;</span><span style=3D"color:#000"> value</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 end=
ian_base</span><span style=3D"color:#660">&amp;</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">operator</span><span style=3D"colo=
r:#660">=3D(</span><span style=3D"color:#008">const</span><span style=3D"co=
lor:#000"> endian_base</span><span style=3D"color:#660">&amp;)</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">default</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 endian_base</span><span style=3D"color:#660">&amp;</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span=
 style=3D"color:#660">=3D(</span><span style=3D"color:#008">const</span><sp=
an style=3D"color:#000"> T</span><span style=3D"color:#660">&amp;</span><sp=
an style=3D"color:#000"> value</span><span style=3D"color:#660">);</span><s=
pan style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">()</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">const</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 T </span><span style=3D"col=
or:#008">get</span><span style=3D"color:#660">()</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">const</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">operator</span><span style=3D"color:#66=
0">++(</span><span style=3D"color:#008">int</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#008">operator</span><span style=3D"color:#660">--(</s=
pan><span style=3D"color:#008">int</span><span style=3D"color:#660">);</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</s=
pan><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">operator</span><span style=3D"color:#660">++(=
);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_=
base</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">operator</span><span style=3D"color:#6=
60">--();</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
</span><span style=3D"color:#008">template</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">t=
ypename</span><span style=3D"color:#000"> T2</span><span style=3D"color:#66=
0">&gt;</span><span style=3D"color:#000"> endian_base</span><span style=3D"=
color:#660">&amp;</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#660">+=3D(</span><span styl=
e=3D"color:#000">T2</span><span style=3D"color:#660">&amp;&amp;</span><span=
 style=3D"color:#000"> rhs</span><span style=3D"color:#660">);</span><span =
style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</span><span =
style=3D"color:#000"> endian_base</span><span style=3D"color:#660">&amp;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">operator<=
/span><span style=3D"color:#660">-=3D(</span><span style=3D"color:#000">T2<=
/span><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000=
"> rhs</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">template=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</=
span><span style=3D"color:#008">typename</span><span style=3D"color:#000"> =
T2</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> =
endian_base</span><span style=3D"color:#660">&amp;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">operator</span><span style=3D"c=
olor:#660">*=3D(</span><span style=3D"color:#000">T2</span><span style=3D"c=
olor:#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color:#008">template</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"co=
lor:#008">typename</span><span style=3D"color:#000"> T2</span><span style=
=3D"color:#660">&gt;</span><span style=3D"color:#000"> endian_base</span><s=
pan style=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">operator</span><span style=3D"color:#660">/=3D(</sp=
an><span style=3D"color:#000">T2</span><span style=3D"color:#660">&amp;&amp=
;</span><span style=3D"color:#000"> rhs</span><span style=3D"color:#660">);=
</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color:#008">template</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</=
span><span style=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</=
span><span style=3D"color:#000"> endian_base</span><span style=3D"color:#66=
0">&amp;</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">operator</span><span style=3D"color:#660">%=3D(</span><span style=3D"colo=
r:#000">T2</span><span style=3D"color:#660">&amp;&amp;</span><span style=3D=
"color:#000"> rhs</span><span style=3D"color:#660">);</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">template</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"co=
lor:#000"> T2</span><span style=3D"color:#660">&gt;</span><span style=3D"co=
lor:#000"> endian_base</span><span style=3D"color:#660">&amp;</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span=
 style=3D"color:#660">&amp;=3D(</span><span style=3D"color:#000">T2</span><=
span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> rhs<=
/span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">template</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span>=
<span style=3D"color:#008">typename</span><span style=3D"color:#000"> T2</s=
pan><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> endia=
n_base</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#660">|=3D(</span><span style=3D"color:#000">T2</span><span style=3D"color:=
#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span><span style=3D=
"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color:#008">template</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#008">typename</span><span style=3D"color:#000"> T2</span><span style=3D"co=
lor:#660">&gt;</span><span style=3D"color:#000"> endian_base</span><span st=
yle=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">operator</span><span style=3D"color:#660">^=3D(</span><sp=
an style=3D"color:#000">T2</span><span style=3D"color:#660">&amp;&amp;</spa=
n><span style=3D"color:#000"> rhs</span><span style=3D"color:#660">);</span=
><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color:#008">template</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><=
span style=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</span><=
span style=3D"color:#000"> endian_base</span><span style=3D"color:#660">&am=
p;</span><span style=3D"color:#000"> </span><span style=3D"color:#008">oper=
ator</span><span style=3D"color:#660">&lt;&lt;=3D(</span><span style=3D"col=
or:#000">T2</span><span style=3D"color:#660">&amp;&amp;</span><span style=
=3D"color:#000"> rhs</span><span style=3D"color:#660">);</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color=
:#008">template</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"> endian_base</span><span style=3D"color:#660">&amp;</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">operator</span=
><span style=3D"color:#660">&gt;&gt;=3D(</span><span style=3D"color:#000">T=
2</span><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#0=
00"> rhs</span><span style=3D"color:#660">);</span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#660">};</span><span style=3D"color:#000=
"><br><br></span><span style=3D"color:#008">template</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"col=
or:#008">typename</span><span style=3D"color:#000"> T</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> std</span><span style=3D"co=
lor:#660">::</span><span style=3D"color:#000">size_t </span><span style=3D"=
color:#606">Align</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">alignof</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#000">T</span><span style=3D"color:#660">)&gt;</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">using</span><span style=3D"co=
lor:#000"> le </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> endian_base</span><span style=3D"color:#660">&lt;</span><span st=
yle=3D"color:#000">T</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Align</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> endian</span><span styl=
e=3D"color:#660">::</span><span style=3D"color:#008">native</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><span sty=
le=3D"color:#000"> endian</span><span style=3D"color:#660">::</span><span s=
tyle=3D"color:#000">little</span><span style=3D"color:#660">&gt;;</span><sp=
an style=3D"color:#000"><br><br></span><span style=3D"color:#008">template<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</s=
pan><span style=3D"color:#008">typename</span><span style=3D"color:#000"> T=
</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</=
span><span style=3D"color:#660">::</span><span style=3D"color:#000">size_t =
</span><span style=3D"color:#606">Align</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">alignof</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000">T</span><span style=3D"color:#660">)&gt;</sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#008">using</=
span><span style=3D"color:#000"> be </span><span style=3D"color:#660">=3D</=
span><span style=3D"color:#000"> endian_base</span><span style=3D"color:#66=
0">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:#660"=
>,</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Alig=
n</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> endi=
an</span><span style=3D"color:#660">::</span><span style=3D"color:#008">nat=
ive</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=
=3D</span><span style=3D"color:#000"> endian</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">big</span><span style=3D"color:#660"=
>&gt;;</span><span style=3D"color:#000"><br><br></span><span style=3D"color=
:#008">template</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span styl=
e=3D"color:#000"> le_store</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#008">void</span><span style=3D"color:#660">*</span><span sty=
le=3D"color:#000"> dst</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">const</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">&amp;</span><span style=
=3D"color:#000"> value</span><span style=3D"color:#660">);</span><span styl=
e=3D"color:#000"><br><br></span><span style=3D"color:#008">template</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#008">typename</span><span style=3D"color:#000"> T</span>=
<span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">void</span><span style=3D"color:#000"> le_load<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#000">T</span=
><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> value</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#008">const</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">void</span><span style=3D"color:#660">*</span><sp=
an style=3D"color:#000"> src</span><span style=3D"color:#660">);</span><spa=
n style=3D"color:#000"><br><br></span><span style=3D"color:#008">template</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#008">typename</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br>=
T le_load</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
8">const</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">void</span><span style=3D"color:#660">*</span><span style=3D"color:#000">=
 src</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#008">template</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#008">typename</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">void</span><span style=3D"color:#000"> be_store</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">void</span><span style=
=3D"color:#660">*</span><span style=3D"color:#000"> dst</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">const</span><span style=3D"color:#000"> T</span><span style=3D"c=
olor:#660">&amp;</span><span style=3D"color:#000"> value</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br><br></span><span st=
yle=3D"color:#008">template</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><=
span style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#008">void</span><=
span style=3D"color:#000"> be_load</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000">T</span><span style=3D"color:#660">&amp;</span>=
<span style=3D"color:#000"> value</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">const</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">void</span><sp=
an style=3D"color:#660">*</span><span style=3D"color:#000"> src</span><span=
 style=3D"color:#660">);</span><span style=3D"color:#000"><br><br></span><s=
pan style=3D"color:#008">template</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</=
span><span style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</s=
pan><span style=3D"color:#000"><br>T be_load</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#008">const</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">void</span><span style=3D"color:#660">=
*</span><span style=3D"color:#000"> src</span><span style=3D"color:#660">);=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</=
span><span style=3D"color:#000"><br></span></div></code></div><br></div></b=
lockquote><div><br>Pointers ought to be endian-convertible as well. Also, w=
hy are you giving an endian-conversion object operator overloads? That soun=
ds like its trying to do something more than it should.<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/cefdaec0-89a8-471a-b366-d73cb7bc74fa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cefdaec0-89a8-471a-b366-d73cb7bc74fa=
%40isocpp.org</a>.<br />

------=_Part_535_980674262.1481845592044--

------=_Part_534_1517100592.1481845592042--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Thu, 15 Dec 2016 16:13:56 -0800 (PST)
Raw View
------=_Part_504_165237997.1481847236582
Content-Type: multipart/alternative;
 boundary="----=_Part_505_137348446.1481847236585"

------=_Part_505_137348446.1481847236585
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Is there any use case for pointers?

These operators are implemented as read-modify-write operations, where=20
modify is executed for the underlying type. If particular type doesn't have=
=20
specific operator it will cause a compilation error. It seems convenient,=
=20
boost also implements something similar.

template <typename T2>
endian_base& operator+=3D(T2&& rhs)
{
    auto val =3D get();
    val +=3D std::forward<T2>(rhs);
    return (*this =3D val);
}



=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 16 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 2:46:32 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Nicol Bolas =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:
>
>
>
> On Thursday, December 15, 2016 at 4:22:11 PM UTC-5, Ivan G. wrote:
>>
>> namespace std
>> {
>> template <typename T, std::size_t Align, bool Native>
>> class endian_base
>> {
>>         static_assert(std::is_arithmetic<T>::value || std::is_enum<T>::
>> value, "endian_base<>: invalid type");
>> public:
>>         using value_type =3D T;
>>         endian_base() =3D default;
>>         endian_base(const T& value);
>>         endian_base& operator=3D(const endian_base&) =3D default;
>>         endian_base& operator=3D(const T& value);
>>         operator T() const;
>>         T get() const;
>>
>>         auto operator++(int);
>>         auto operator--(int);
>>         endian_base& operator++();
>>         endian_base& operator--();
>>         template <typename T2> endian_base& operator+=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator-=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator*=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator/=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator%=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator&=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator|=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator^=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator<<=3D(T2&& rhs);
>>         template <typename T2> endian_base& operator>>=3D(T2&& rhs);
>> };
>>
>> template <typename T, std::size_t Align =3D alignof(T)>
>> using le =3D endian_base<T, Align, endian::native =3D=3D endian::little>=
;
>>
>> template <typename T, std::size_t Align =3D alignof(T)>
>> using be =3D endian_base<T, Align, endian::native =3D=3D endian::big>;
>>
>> template <typename T>
>> void le_store(void* dst, const T& value);
>>
>> template <typename T>
>> void le_load(T& value, const void* src);
>>
>> template <typename T>
>> T le_load(const void* src);
>>
>> template <typename T>
>> void be_store(void* dst, const T& value);
>>
>> template <typename T>
>> void be_load(T& value, const void* src);
>>
>> template <typename T>
>> T be_load(const void* src);
>> }
>>
>>
> Pointers ought to be endian-convertible as well. Also, why are you giving=
=20
> an endian-conversion object operator overloads? That sounds like its tryi=
ng=20
> to do something more than it should.
>

--=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/b1455c60-4f69-44e0-9103-e33dca551ee1%40isocpp.or=
g.

------=_Part_505_137348446.1481847236585
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Is there any use case for pointers?<br></div><div><br=
></div><div>These operators are implemented as read-modify-write operations=
, where modify is executed for the underlying type. If particular type does=
n&#39;t have specific operator it will cause a compilation error. It seems =
convenient, boost also implements something similar.</div><div><br></div><d=
iv><div style=3D"background-color: #FAFAFA; border-color: #BBB; border-styl=
e: solid; border-width: 1px; word-wrap: break-word;" class=3D"prettyprint">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><table class=3D"h=
ighlight tab-size js-file-line-container" data-tab-size=3D"8"><tbody><tr><t=
d id=3D"LC349" class=3D"blob-code blob-code-inner js-file-line"><span class=
=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">typename</span></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&gt;</span></td></tr><tr><td id=3D"LC350" class=3D"blob-code blob-code-in=
ner js-file-line"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> endian_base</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-=
prettify">operator</span></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">+=3D(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">T2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> rhs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</s=
pan></td></tr><tr><td id=3D"LC351" class=3D"blob-code blob-code-inner js-fi=
le-line"><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
</td></tr><tr><td id=3D"LC352" class=3D"blob-code blob-code-inner js-file-l=
ine"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=
=A0 </span><span class=3D"pl-k"><span style=3D"color: #008;" class=3D"style=
d-by-prettify">auto</span></span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> val </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span class=3D"pl-c1"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">get</span></span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">();</span></td></tr><tr><td id=3D"LC353" class=3D"blob-cod=
e blob-code-inner js-file-line"><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> =C2=A0 =C2=A0 val </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">+=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">forward</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T2</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">rhs</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">);</span></td></tr><tr><t=
d id=3D"LC354" class=3D"blob-code blob-code-inner js-file-line"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 </span><span =
class=3D"pl-k"><span style=3D"color: #008;" class=3D"styled-by-prettify">re=
turn</span></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(*</span=
><span class=3D"pl-v"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">this</span></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> val</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span></td></=
tr><tr><td id=3D"LC355" class=3D"blob-code blob-code-inner js-file-line"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span></td></tr></tbody></=
table></div></code></div><br><br></div><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=
=D1=86=D0=B0, 16 =D0=B4=D0=B5=D0=BA=D0=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 2=
:46:32 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C Nicol Bolas =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On Thursday,=
 December 15, 2016 at 4:22:11 PM UTC-5, Ivan G. wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex"><div dir=3D"ltr"><div style=3D"background-color:#fafafa;=
border-color:#bbb;border-style:solid;border-width:1px;word-wrap:break-word"=
><code><div><span style=3D"color:#008">namespace</span><span style=3D"color=
:#000"> std<br></span><span style=3D"color:#660">{</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=
=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> std</span><span styl=
e=3D"color:#660">::</span><span style=3D"color:#000">size_t </span><span st=
yle=3D"color:#606">Align</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">bool</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Native</span><span style=
=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">class</span><span style=3D"color:#000"> endian_base<br></s=
pan><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">static_assert</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000">std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">is_arithmet=
ic</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">T=
</span><span style=3D"color:#660">&gt;::</span><span style=3D"color:#000">v=
alue </span><span style=3D"color:#660">||</span><span style=3D"color:#000">=
 std</span><span style=3D"color:#660">::</span><span style=3D"color:#000">i=
s_enum</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#00=
0">T</span><span style=3D"color:#660">&gt;::</span><span style=3D"color:#00=
0">value</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&quot;endian_base&lt;&gt;: invalid typ=
e&quot;</span><span style=3D"color:#660">);</span><span style=3D"color:#000=
"><br></span><span style=3D"color:#008">public</span><span style=3D"color:#=
660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">using</span><span style=3D"color:#000"> valu=
e_type </span><span style=3D"color:#660">=3D</span><span style=3D"color:#00=
0"> T</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color:#660"=
>()</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">defaul=
t</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color:#660">(<=
/span><span style=3D"color:#008">const</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> va=
lue</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color:#660">=
&amp;</span><span style=3D"color:#000"> </span><span style=3D"color:#008">o=
perator</span><span style=3D"color:#660">=3D(</span><span style=3D"color:#0=
08">const</span><span style=3D"color:#000"> endian_base</span><span style=
=3D"color:#660">&amp;)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">default</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span sty=
le=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">operator</span><span style=3D"color:#660">=3D(</span><span=
 style=3D"color:#008">const</span><span style=3D"color:#000"> T</span><span=
 style=3D"color:#660">&amp;</span><span style=3D"color:#000"> value</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">operator</span><span=
 style=3D"color:#000"> T</span><span style=3D"color:#660">()</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">const</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 T </span><span style=3D"color:#008">get</span><span style=3D"col=
or:#660">()</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">const</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">a=
uto</span><span style=3D"color:#000"> </span><span style=3D"color:#008">ope=
rator</span><span style=3D"color:#660">++(</span><span style=3D"color:#008"=
>int</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">auto</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">operator</sp=
an><span style=3D"color:#660">--(</span><span style=3D"color:#008">int</spa=
n><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color:#660">&amp;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">operator<=
/span><span style=3D"color:#660">++();</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 endian_base</span><span style=3D"color:#660">&=
amp;</span><span style=3D"color:#000"> </span><span style=3D"color:#008">op=
erator</span><span style=3D"color:#660">--();</span><span style=3D"color:#0=
00"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">templ=
ate</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt=
;</span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> T2</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000=
"> endian_base</span><span style=3D"color:#660">&amp;</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">operator</span><span style=
=3D"color:#660">+=3D(</span><span style=3D"color:#000">T2</span><span style=
=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">template</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span styl=
e=3D"color:#008">typename</span><span style=3D"color:#000"> T2</span><span =
style=3D"color:#660">&gt;</span><span style=3D"color:#000"> endian_base</sp=
an><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">operator</span><span style=3D"color:#660">-=3D=
(</span><span style=3D"color:#000">T2</span><span style=3D"color:#660">&amp=
;&amp;</span><span style=3D"color:#000"> rhs</span><span style=3D"color:#66=
0">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008">template</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typen=
ame</span><span style=3D"color:#000"> T2</span><span style=3D"color:#660">&=
gt;</span><span style=3D"color:#000"> endian_base</span><span style=3D"colo=
r:#660">&amp;</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">operator</span><span style=3D"color:#660">*=3D(</span><span style=3D=
"color:#000">T2</span><span style=3D"color:#660">&amp;&amp;</span><span sty=
le=3D"color:#000"> rhs</span><span style=3D"color:#660">);</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"> endian_base</span><span style=3D"color:#660">&amp;</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">operator</span=
><span style=3D"color:#660">/=3D(</span><span style=3D"color:#000">T2</span=
><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> rh=
s</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">template</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span>=
<span style=3D"color:#008">typename</span><span style=3D"color:#000"> T2</s=
pan><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> endia=
n_base</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#660">%=3D(</span><span style=3D"color:#000">T2</span><span style=3D"color:=
#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span><span style=3D=
"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color:#008">template</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#008">typename</span><span style=3D"color:#000"> T2</span><span style=3D"co=
lor:#660">&gt;</span><span style=3D"color:#000"> endian_base</span><span st=
yle=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">operator</span><span style=3D"color:#660">&amp;=3D(</span=
><span style=3D"color:#000">T2</span><span style=3D"color:#660">&amp;&amp;<=
/span><span style=3D"color:#000"> rhs</span><span style=3D"color:#660">);</=
span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><spa=
n style=3D"color:#008">template</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</sp=
an><span style=3D"color:#000"> T2</span><span style=3D"color:#660">&gt;</sp=
an><span style=3D"color:#000"> endian_base</span><span style=3D"color:#660"=
>&amp;</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
operator</span><span style=3D"color:#660">|=3D(</span><span style=3D"color:=
#000">T2</span><span style=3D"color:#660">&amp;&amp;</span><span style=3D"c=
olor:#000"> rhs</span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>template</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"colo=
r:#000"> T2</span><span style=3D"color:#660">&gt;</span><span style=3D"colo=
r:#000"> endian_base</span><span style=3D"color:#660">&amp;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span s=
tyle=3D"color:#660">^=3D(</span><span style=3D"color:#000">T2</span><span s=
tyle=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span>=
<span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">template</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span s=
tyle=3D"color:#008">typename</span><span style=3D"color:#000"> T2</span><sp=
an style=3D"color:#660">&gt;</span><span style=3D"color:#000"> endian_base<=
/span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">operator</span><span style=3D"color:#660">&=
lt;&lt;=3D(</span><span style=3D"color:#000">T2</span><span style=3D"color:=
#660">&amp;&amp;</span><span style=3D"color:#000"> rhs</span><span style=3D=
"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color:#008">template</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#008">typename</span><span style=3D"color:#000"> T2</span><span style=3D"co=
lor:#660">&gt;</span><span style=3D"color:#000"> endian_base</span><span st=
yle=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">operator</span><span style=3D"color:#660">&gt;&gt;=3D(</s=
pan><span style=3D"color:#000">T2</span><span style=3D"color:#660">&amp;&am=
p;</span><span style=3D"color:#000"> rhs</span><span style=3D"color:#660">)=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">};=
</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008"=
>template</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"colo=
r:#000"> T</span><span style=3D"color:#660">,</span><span style=3D"color:#0=
00"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#00=
0">size_t </span><span style=3D"color:#606">Align</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">alignof</span><span style=3D"color:=
#660">(</span><span style=3D"color:#000">T</span><span style=3D"color:#660"=
>)&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">using</span><span style=3D"color:#000"> le </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> endian_base</span><span style=3D=
"color:#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"c=
olor:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:=
#606">Align</span><span style=3D"color:#660">,</span><span style=3D"color:#=
000"> endian</span><span style=3D"color:#660">::</span><span style=3D"color=
:#008">native</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D=3D</span><span style=3D"color:#000"> endian</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">little</span><span style=
=3D"color:#660">&gt;;</span><span style=3D"color:#000"><br><br></span><span=
 style=3D"color:#008">template</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</spa=
n><span style=3D"color:#000"> T</span><span style=3D"color:#660">,</span><s=
pan style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">size_t </span><span style=3D"color:#606">Align</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">alignof</span>=
<span style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span=
 style=3D"color:#660">)&gt;</span><span style=3D"color:#000"><br></span><sp=
an style=3D"color:#008">using</span><span style=3D"color:#000"> be </span><=
span style=3D"color:#660">=3D</span><span style=3D"color:#000"> endian_base=
</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">T</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">Align</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> endian</span><span style=3D"color:#660">::</span=
><span style=3D"color:#008">native</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> endian=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">big</=
span><span style=3D"color:#660">&gt;;</span><span style=3D"color:#000"><br>=
<br></span><span style=3D"color:#008">template</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#00=
8">typename</span><span style=3D"color:#000"> T</span><span style=3D"color:=
#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#008">void</span><span style=3D"color:#000"> le_store</span><span style=3D=
"color:#660">(</span><span style=3D"color:#008">void</span><span style=3D"c=
olor:#660">*</span><span style=3D"color:#000"> dst</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">const</span><span style=3D"color:#000"> T</span><span style=3D"color:#6=
60">&amp;</span><span style=3D"color:#000"> value</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br><br></span><span style=3D"c=
olor:#008">template</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span sty=
le=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span sty=
le=3D"color:#000"> le_load</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">T</span><span style=3D"color:#660">&amp;</span><span st=
yle=3D"color:#000"> value</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">const</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">void</span><span style=
=3D"color:#660">*</span><span style=3D"color:#000"> src</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br><br></span><span st=
yle=3D"color:#008">template</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><=
span style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><s=
pan style=3D"color:#000"><br>T le_load</span><span style=3D"color:#660">(</=
span><span style=3D"color:#008">const</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">void</span><span style=3D"color:#660">*</spa=
n><span style=3D"color:#000"> src</span><span style=3D"color:#660">);</span=
><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">templ=
ate</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt=
;</span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> T</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#008">void</span><span style=3D"color:#000=
"> be_store</span><span style=3D"color:#660">(</span><span style=3D"color:#=
008">void</span><span style=3D"color:#660">*</span><span style=3D"color:#00=
0"> dst</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">const</span><span style=3D"color:#000">=
 T</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">=
 value</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br><br></span><span style=3D"color:#008">template</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">&lt;</span><span style=3D"colo=
r:#008">typename</span><span style=3D"color:#000"> T</span><span style=3D"c=
olor:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">void</span><span style=3D"color:#000"> be_load</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000">T</span><span style=3D"=
color:#660">&amp;</span><span style=3D"color:#000"> value</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">const</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">void</span><span style=3D"color:#660">*</span><span style=3D"colo=
r:#000"> src</span><span style=3D"color:#660">);</span><span style=3D"color=
:#000"><br><br></span><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span style=
=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">&gt;</span><span style=3D"color:#000"><br>T be_load</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#008">const</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">void</span><=
span style=3D"color:#660">*</span><span style=3D"color:#000"> src</span><sp=
an style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#660">}</span><span style=3D"color:#000"><br></span></div>=
</code></div><br></div></blockquote><div><br>Pointers ought to be endian-co=
nvertible as well. Also, why are you giving an endian-conversion object ope=
rator overloads? That sounds like its trying to do something more than it s=
hould.<br></div></div></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/b1455c60-4f69-44e0-9103-e33dca551ee1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b1455c60-4f69-44e0-9103-e33dca551ee1=
%40isocpp.org</a>.<br />

------=_Part_505_137348446.1481847236585--

------=_Part_504_165237997.1481847236582--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Fri, 16 Dec 2016 04:50:12 -0800 (PST)
Raw View
------=_Part_647_1290465178.1481892613044
Content-Type: multipart/alternative;
 boundary="----=_Part_648_718922814.1481892613044"

------=_Part_648_718922814.1481892613044
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Small addition:

namespace std {
template <typename T>
struct has_endianness
    : std::integral_constant<bool, std::is_arithmetic<T>::value ||
                                       std::is_enum<T>::value ||
                                       std::is_pointer<T>::value> {};
}

User-provided specialization of this trait may enable endian_base and=20
store/load functions for arbitrary type.

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=D0=BA=D0=B0=D0=
=B1=D1=80=D1=8F 2016 =D0=B3., 21:07:08 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ivan G. =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
> OK, I must agree, incorrect usage may be the source of unnoticed bugs.
>
> I think there is a compromiss solution: limit be<>/le<> to basic types (+=
=20
> implementation-defined extensions like uint128_t) and allow manual=20
> extension with user-provided template specializations, like std::hash<>.
>
> I'll also think about the interface of endianness conversion functions.
>

--=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/14897b37-16c2-44ce-b805-3758ad695e20%40isocpp.or=
g.

------=_Part_648_718922814.1481892613044
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Small addition:<br></div><div><br></div><div><div sty=
le=3D"background-color: #FAFAFA; border-color: #BBB; border-style: solid; b=
order-width: 1px; word-wrap: break-word;" class=3D"prettyprint"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">namespace</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: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">template</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> has_endianness<br>=C2=A0 =C2=A0=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">integral_constant</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</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: #000;" class=3D"styl=
ed-by-prettify">is_arithmetic</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&gt;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
value </span><span style=3D"color: #660;" class=3D"styled-by-prettify">||</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">is_enum</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">||</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">is_pointe=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&gt;::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">value</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=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></div></code></div><br>User-provided specialization o=
f this trait may enable endian_base and store/load functions for arbitrary =
type.</div><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 15 =D0=B4=D0=B5=
=D0=BA=D0=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 21:07:08 UTC+3 =D0=BF=D0=BE=D0=
=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ivan G. =D0=BD=D0=
=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div>OK, I must agree, incorrect usage may be the so=
urce of unnoticed bugs.</div><div><br></div><div>I think there is a comprom=
iss solution: limit be&lt;&gt;/le&lt;&gt; to basic types (+ implementation-=
defined extensions like uint128_t) and allow manual extension with user-pro=
vided template specializations, like std::hash&lt;&gt;.</div><div><br></div=
><div>I&#39;ll also think about the interface of endianness conversion func=
tions.</div></div></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/14897b37-16c2-44ce-b805-3758ad695e20%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/14897b37-16c2-44ce-b805-3758ad695e20=
%40isocpp.org</a>.<br />

------=_Part_648_718922814.1481892613044--

------=_Part_647_1290465178.1481892613044--

.


Author: "D. B." <db0451@gmail.com>
Date: Fri, 16 Dec 2016 12:56:18 +0000
Raw View
--001a1130cf0697acf90543c61849
Content-Type: text/plain; charset=UTF-8

On Fri, Dec 16, 2016 at 12:13 AM, Ivan G. <nekotekina@gmail.com> wrote:

> Is there any use case for pointers?
>

I'm also struggling to think of one. I would presume endianness wrapping
would be useful for sharing data between different (types of) machines.
Storing pointer values between runs of a program is of no use, even on the
same machine!

--
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/CACGiwhHi6LASzkM7V7MqPgu_7RXgprg91PWGPUp0fUnxUfgTRA%40mail.gmail.com.

--001a1130cf0697acf90543c61849
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Fri, Dec 16, 2016 at 12:13 AM, Ivan G. <span dir=3D"ltr">&lt;<a href=
=3D"mailto:nekotekina@gmail.com" target=3D"_blank">nekotekina@gmail.com</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>=
Is there any use case for pointers?<br></div></div></blockquote><div><br></=
div><div>I&#39;m also struggling to think of one. I would presume endiannes=
s wrapping would be useful for sharing data between different (types of) ma=
chines. Storing pointer values between runs of a program is of no use, even=
 on the same machine!<br>=C2=A0<br></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/CACGiwhHi6LASzkM7V7MqPgu_7RXgprg91PWG=
PUp0fUnxUfgTRA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhHi6LASzkM7=
V7MqPgu_7RXgprg91PWGPUp0fUnxUfgTRA%40mail.gmail.com</a>.<br />

--001a1130cf0697acf90543c61849--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Sun, 18 Dec 2016 04:42:50 -0800 (PST)
Raw View
------=_Part_995_1255170551.1482064970893
Content-Type: multipart/alternative;
 boundary="----=_Part_996_383261965.1482064970893"

------=_Part_996_383261965.1482064970893
Content-Type: text/plain; charset=UTF-8


>
>
> Another problem: should bool type be explicitly forbidden?

I'm also struggling to think of one. I would presume endianness wrapping
> would be useful for sharing data between different (types of) machines.
> Storing pointer values between runs of a program is of no use, even on the
> same machine!


Well, technically nothing prevents storing pointers in foreign byte order
and using them at the same time. And address space can theoretically be
shared in some way.

--
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/2d1213d1-2790-4711-970d-a4031038e0aa%40isocpp.org.

------=_Part_996_383261965.1482064970893
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br></blockqu=
ote><div>Another problem: should bool type be explicitly forbidden?=C2=A0</=
div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I&#39;m als=
o struggling to think of one. I would presume endianness wrapping would be =
useful for sharing data between different (types of) machines. Storing poin=
ter values between runs of a program is of no use, even on the same machine=
!</blockquote><div><br></div><div>Well, technically nothing prevents storin=
g pointers in foreign byte order and using them at the same time. And addre=
ss space can theoretically be shared in some way.</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/2d1213d1-2790-4711-970d-a4031038e0aa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2d1213d1-2790-4711-970d-a4031038e0aa=
%40isocpp.org</a>.<br />

------=_Part_996_383261965.1482064970893--

------=_Part_995_1255170551.1482064970893--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 18 Dec 2016 09:45:08 -0800
Raw View
On domingo, 18 de dezembro de 2016 04:42:50 PST Ivan G. wrote:
> > Another problem: should bool type be explicitly forbidden?
>
> I'm also struggling to think of one. I would presume endianness wrapping
>
> > would be useful for sharing data between different (types of) machines.
> > Storing pointer values between runs of a program is of no use, even on the
> > same machine!
>
> Well, technically nothing prevents storing pointers in foreign byte order
> and using them at the same time. And address space can theoretically be
> shared in some way.

If it's not a pointer to your program's address space in your machine's byte
order, it's not a pointer. Store it in a different type instead, something of
suitable size.

Like uintptr_t.

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

--
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/3721821.2rzyqfnEDx%40tjmaciei-mobl1.

.


Author: Myriachan <myriachan@gmail.com>
Date: Mon, 19 Dec 2016 11:46:13 -0800 (PST)
Raw View
------=_Part_4955_1634436637.1482176773161
Content-Type: multipart/alternative;
 boundary="----=_Part_4956_1651568577.1482176773161"

------=_Part_4956_1651568577.1482176773161
Content-Type: text/plain; charset=UTF-8

On Sunday, December 18, 2016 at 9:45:12 AM UTC-8, Thiago Macieira wrote:
>
> On domingo, 18 de dezembro de 2016 04:42:50 PST Ivan G. wrote:
> > > Another problem: should bool type be explicitly forbidden?
> >
> > I'm also struggling to think of one. I would presume endianness wrapping
> >
> > > would be useful for sharing data between different (types of)
> machines.
> > > Storing pointer values between runs of a program is of no use, even on
> the
> > > same machine!
> >
> > Well, technically nothing prevents storing pointers in foreign byte
> order
> > and using them at the same time. And address space can theoretically be
> > shared in some way.
>
> If it's not a pointer to your program's address space in your machine's
> byte
> order, it's not a pointer. Store it in a different type instead, something
> of
> suitable size.
>
> Like uintptr_t.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>
>
Yeah, I agree with this, and wish that e.g. Windows NT's WriteProcessMemory
took a uintptr_t instead of a void * for the pointer in the target
process's address space, because the pointer has no meaning in the source
process.

I'm glad that this proposal at least supports the architecture that exists
where integers and floating-point numbers are opposite endianness.

I don't like the names "le" and "be", because in the crowded std namespace,
two-letter names don't seem appropriate.  Also, "native" being an alias for
the native endianness would be nice.

I do have a question, though: would these *_load and *_store functions be
required to comply with C++'s aliasing rules?  For example, would this be
defined or undefined behavior?:

std::uint32_t i;
float f = ...;
static_assert(sizeof(i) == sizeof(f));
std::be_store(&i, f);

If this would be defined behavior, then I feel that there should be a
native_load and native_store, because I'm sick of having to use std::memcpy
for this purpose.

Melissa

--
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/f85bbf95-e6b6-4d69-bac7-7688786ac868%40isocpp.org.

------=_Part_4956_1651568577.1482176773161
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, December 18, 2016 at 9:45:12 AM UTC-8, Thiago M=
acieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On domingo, 18 d=
e dezembro de 2016 04:42:50 PST Ivan G. wrote:
<br>&gt; &gt; Another problem: should bool type be explicitly forbidden?
<br>&gt;=20
<br>&gt; I&#39;m also struggling to think of one. I would presume endiannes=
s wrapping
<br>&gt;=20
<br>&gt; &gt; would be useful for sharing data between different (types of)=
 machines.
<br>&gt; &gt; Storing pointer values between runs of a program is of no use=
, even on the
<br>&gt; &gt; same machine!
<br>&gt;=20
<br>&gt; Well, technically nothing prevents storing pointers in foreign byt=
e order
<br>&gt; and using them at the same time. And address space can theoretical=
ly be
<br>&gt; shared in some way.
<br>
<br>If it&#39;s not a pointer to your program&#39;s address space in your m=
achine&#39;s byte=20
<br>order, it&#39;s not a pointer. Store it in a different type instead, so=
mething of=20
<br>suitable size.
<br>
<br>Like uintptr_t.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote><div><br>Yeah, I agree with this, and wish that e.g. Windo=
ws NT&#39;s WriteProcessMemory took a uintptr_t instead of a void * for the=
 pointer in the target process&#39;s address space, because the pointer has=
 no meaning in the source process.<br><br>I&#39;m glad that this proposal a=
t least supports the architecture that exists where integers and floating-p=
oint numbers are opposite endianness.<br><br>I don&#39;t like the names &qu=
ot;le&quot; and &quot;be&quot;, because in the crowded std namespace, two-l=
etter names don&#39;t seem appropriate.=C2=A0 Also, &quot;native&quot; bein=
g an alias for the native endianness would be nice.<br><br>I do have a ques=
tion, though: would these *_load and *_store functions be required to compl=
y with C++&#39;s aliasing rules?=C2=A0 For example, would this be defined o=
r undefined behavior?:<br><br>std::uint32_t i;<br>float f =3D ...;<br>stati=
c_assert(sizeof(i) =3D=3D sizeof(f));<br>std::be_store(&amp;i, f);<br><br>I=
f this would be defined behavior, then I feel that there should be a native=
_load and native_store, because I&#39;m sick of having to use std::memcpy f=
or this purpose.<br><br>Melissa<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/f85bbf95-e6b6-4d69-bac7-7688786ac868%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f85bbf95-e6b6-4d69-bac7-7688786ac868=
%40isocpp.org</a>.<br />

------=_Part_4956_1651568577.1482176773161--

------=_Part_4955_1634436637.1482176773161--

.


Author: "Ivan G." <nekotekina@gmail.com>
Date: Sun, 25 Dec 2016 09:45:00 -0800 (PST)
Raw View
------=_Part_694_496097409.1482687900099
Content-Type: multipart/alternative;
 boundary="----=_Part_695_642809621.1482687900099"

------=_Part_695_642809621.1482687900099
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

What about le_t and be_t?

Regarding reinterpreting floats as integers and vice versa, I'm not sure.=
=20
FP representation remains implementation-specific. But the example should=
=20
work in my opinion, because the function reads bytes and stores bytes.

=D0=BF=D0=BE=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA, 19 =D0=
=B4=D0=B5=D0=BA=D0=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 22:46:13 UTC+3 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Myriacha=
n=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> On Sunday, December 18, 2016 at 9:45:12 AM UTC-8, Thiago Macieira wrote:
>>
>> On domingo, 18 de dezembro de 2016 04:42:50 PST Ivan G. wrote:=20
>> > > Another problem: should bool type be explicitly forbidden?=20
>> >=20
>> > I'm also struggling to think of one. I would presume endianness=20
>> wrapping=20
>> >=20
>> > > would be useful for sharing data between different (types of)=20
>> machines.=20
>> > > Storing pointer values between runs of a program is of no use, even=
=20
>> on the=20
>> > > same machine!=20
>> >=20
>> > Well, technically nothing prevents storing pointers in foreign byte=20
>> order=20
>> > and using them at the same time. And address space can theoretically b=
e=20
>> > shared in some way.=20
>>
>> If it's not a pointer to your program's address space in your machine's=
=20
>> byte=20
>> order, it's not a pointer. Store it in a different type instead,=20
>> something of=20
>> suitable size.=20
>>
>> Like uintptr_t.=20
>>
>> --=20
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>>    Software Architect - Intel Open Source Technology Center=20
>>
>>
> Yeah, I agree with this, and wish that e.g. Windows NT's=20
> WriteProcessMemory took a uintptr_t instead of a void * for the pointer i=
n=20
> the target process's address space, because the pointer has no meaning in=
=20
> the source process.
>
> I'm glad that this proposal at least supports the architecture that exist=
s=20
> where integers and floating-point numbers are opposite endianness.
>
> I don't like the names "le" and "be", because in the crowded std=20
> namespace, two-letter names don't seem appropriate.  Also, "native" being=
=20
> an alias for the native endianness would be nice.
>
> I do have a question, though: would these *_load and *_store functions be=
=20
> required to comply with C++'s aliasing rules?  For example, would this be=
=20
> defined or undefined behavior?:
>
> std::uint32_t i;
> float f =3D ...;
> static_assert(sizeof(i) =3D=3D sizeof(f));
> std::be_store(&i, f);
>
> If this would be defined behavior, then I feel that there should be a=20
> native_load and native_store, because I'm sick of having to use std::memc=
py=20
> for this purpose.
>
> Melissa
>

--=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/b01f6406-b74a-4e4f-a4a4-0484ac04d515%40isocpp.or=
g.

------=_Part_695_642809621.1482687900099
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>What about le_t and be_t?<br></div><div><br></div><di=
v>Regarding reinterpreting floats as integers and vice versa, I&#39;m not s=
ure. FP representation remains implementation-specific. But the example sho=
uld work in my opinion, because the function reads bytes and stores bytes.<=
/div><br>=D0=BF=D0=BE=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=
, 19 =D0=B4=D0=B5=D0=BA=D0=B0=D0=B1=D1=80=D1=8F 2016 =D0=B3., 22:46:13 UTC+=
3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Myriachan =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr">On Sunday, December 18, 2016 at 9:4=
5:12 AM UTC-8, Thiago Macieira wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex=
">On domingo, 18 de dezembro de 2016 04:42:50 PST Ivan G. wrote:
<br>&gt; &gt; Another problem: should bool type be explicitly forbidden?
<br>&gt;=20
<br>&gt; I&#39;m also struggling to think of one. I would presume endiannes=
s wrapping
<br>&gt;=20
<br>&gt; &gt; would be useful for sharing data between different (types of)=
 machines.
<br>&gt; &gt; Storing pointer values between runs of a program is of no use=
, even on the
<br>&gt; &gt; same machine!
<br>&gt;=20
<br>&gt; Well, technically nothing prevents storing pointers in foreign byt=
e order
<br>&gt; and using them at the same time. And address space can theoretical=
ly be
<br>&gt; shared in some way.
<br>
<br>If it&#39;s not a pointer to your program&#39;s address space in your m=
achine&#39;s byte=20
<br>order, it&#39;s not a pointer. Store it in a different type instead, so=
mething of=20
<br>suitable size.
<br>
<br>Like uintptr_t.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.googl=
e.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3=
dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.href=
=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return tru=
e;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofol=
low" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.google.co=
m/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGR=
Jdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote><div><br>Yeah, I agree with this, and wish that e.g. Windo=
ws NT&#39;s WriteProcessMemory took a uintptr_t instead of a void * for the=
 pointer in the target process&#39;s address space, because the pointer has=
 no meaning in the source process.<br><br>I&#39;m glad that this proposal a=
t least supports the architecture that exists where integers and floating-p=
oint numbers are opposite endianness.<br><br>I don&#39;t like the names &qu=
ot;le&quot; and &quot;be&quot;, because in the crowded std namespace, two-l=
etter names don&#39;t seem appropriate.=C2=A0 Also, &quot;native&quot; bein=
g an alias for the native endianness would be nice.<br><br>I do have a ques=
tion, though: would these *_load and *_store functions be required to compl=
y with C++&#39;s aliasing rules?=C2=A0 For example, would this be defined o=
r undefined behavior?:<br><br>std::uint32_t i;<br>float f =3D ...;<br>stati=
c_assert(sizeof(i) =3D=3D sizeof(f));<br>std::be_store(&amp;i, f);<br><br>I=
f this would be defined behavior, then I feel that there should be a native=
_load and native_store, because I&#39;m sick of having to use std::memcpy f=
or this purpose.<br><br>Melissa<br></div></div></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/b01f6406-b74a-4e4f-a4a4-0484ac04d515%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b01f6406-b74a-4e4f-a4a4-0484ac04d515=
%40isocpp.org</a>.<br />

------=_Part_695_642809621.1482687900099--

------=_Part_694_496097409.1482687900099--

.