<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 20 October 2017 at 10:46, Jonathan Wakely <span dir="ltr">&lt;<a href="mailto:cxx@kayari.org" target="_blank">cxx@kayari.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Would something like this be suitable?<br>
<br>
#if __cpp_lib_byte &gt;= 201603<br>
  using byte_type = std::byte;<br>
#else<br>
  using byte_type = unsigned char;<br>
#endif<br>
  alignas(T) byte_type rawbytes[sizeof(T)];<br>
  // ...<br>
<br>
Both forms will work, but the std::byte version might be preferred to<br>
ensure that no arithmetic operations are accidentally performed on the<br>
values. The desired type-safety would only be enforced on<br>
implementations that support std::byte, but if the rest of the code is<br>
the same you can be fairly confident there&#39;s no arithmetic even when<br>
the type is unsigned char.</blockquote><div><br></div><div>Seems reasonable to me. </div></div></div></div>