<div dir="ltr"><div dir="ltr">On Wed, Nov 6, 2019 at 10:28 PM Thiago Macieira &lt;<a href="mailto:thiago@macieira.org" target="_blank">thiago@macieira.org</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wednesday, 6 November 2019 12:34:23 PST JeanHeyd Meneide wrote:<br>
&gt; It is not exactly trivial for #embed or #embed_str. #embed generates a<br>
&gt; brace-delimeted list of the bytes. It&#39;s as if the contents are directly<br>
&gt; replaced by:<br>
&gt; <br>
&gt;      { 102, 111, 111 }<br>
&gt; <br>
&gt;      You cannot &quot;just append&quot; a null terminator in there, so it would<br>
&gt; require a copy. If that&#39;s okay (copying things), then we can throw<br>
&gt; #embed_str out the window. As far as requiring bytes, you would need to<br>
&gt; generate a brace-delimeted list with all of the entries cast to the right<br>
&gt; type, because each of those entries is not trivially convertible to a<br>
&gt; std::byte: <a href="https://godbolt.org/z/NRkSfK" rel="noreferrer" target="_blank">https://godbolt.org/z/NRkSfK</a><br>
<br>
It&#39;s easy to add the terminating null with constexpr. And that function should <br>
be provided. Similarly, it should be easy to concatenate such arrays.<br></blockquote><div><br></div><div>Arrays in C++ (and C) do not have any syntax or behavior for compile-time concatenation. String literals get away with it by having &quot;foo&quot; &quot;bar&quot; be acceptable syntax, meaning someone could add a null terminator with &quot;\0&quot; for #embed_str, but not #embed.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
It should be easy to import non-terminated byte data, null-terminated byte <br>
data and UTF-8 text.<br>
<br>
SG16 should also provide a way to constexpr-time convert UTF-8 text to UTF-16 <br>
or UTF-32<br></blockquote><div><br></div><div>That is something I am already working on (and a separate proposal); all of the UTF8/16/32 encoding objects are constexpr, and one of Corentin&#39;s upcoming papers is a consteval ways to detect the compile-time literal encoding. That should be enough.<br><br></div><div>I think this is highlighting that #embed is the only thing we need, and that #embed_str only real benefit is a null terminating code unit and that there should be better ways to provide that to the user.<br></div></div></div>