Date: Wed, 6 Nov 2019 20:34:23 +0000
On Wed, Nov 6, 2019 at 8:23 PM Corentin Jabot <corentinjabot_at_[hidden]>
wrote:
> Hey.
>
> Agreed, it's a byte thing - actually, have you considered std::byte ?
> You showed that it is trivial to programmatically add a null terminator,
> which seems sufficient to cover all use cases
>
>
It is not exactly trivial for #embed or #embed_str. #embed generates a
brace-delimeted list of the bytes. It's as if the contents are directly
replaced by:
{ 102, 111, 111 }
You cannot "just append" a null terminator in there, so it would
require a copy. If that's okay (copying things), then we can throw
#embed_str out the window. As far as requiring bytes, you would need to
generate a brace-delimeted list with all of the entries cast to the right
type, because each of those entries is not trivially convertible to a
std::byte: https://godbolt.org/z/NRkSfK
There was mention in EWG for #embed TYPE(optional) LIMIT(optional)
*h-char-sequence*, where you could pick the type of the brace-delimited
list that comes out rather than letting it get converted down implicitly.
Maybe that's the solution we need, for std::byte?
Sincerely,
JeanHeyd
wrote:
> Hey.
>
> Agreed, it's a byte thing - actually, have you considered std::byte ?
> You showed that it is trivial to programmatically add a null terminator,
> which seems sufficient to cover all use cases
>
>
It is not exactly trivial for #embed or #embed_str. #embed generates a
brace-delimeted list of the bytes. It's as if the contents are directly
replaced by:
{ 102, 111, 111 }
You cannot "just append" a null terminator in there, so it would
require a copy. If that's okay (copying things), then we can throw
#embed_str out the window. As far as requiring bytes, you would need to
generate a brace-delimeted list with all of the entries cast to the right
type, because each of those entries is not trivially convertible to a
std::byte: https://godbolt.org/z/NRkSfK
There was mention in EWG for #embed TYPE(optional) LIMIT(optional)
*h-char-sequence*, where you could pick the type of the brace-delimited
list that comes out rather than letting it get converted down implicitly.
Maybe that's the solution we need, for std::byte?
Sincerely,
JeanHeyd
Received on 2019-11-06 21:34:36