[SG16-Unicode] String views with strong code unit types

JeanHeyd Meneide phdofthehouse at gmail.com
Tue Jun 4 09:43:39 CEST 2019


On Tue, Jun 4, 2019 at 3:39 AM Lyberta <lyberta at lyberta.net> wrote:

> I'm trying to replicate a "sv" UDL with strong code unit types.
>
> constexpr auto operator "" _cus(const char8_t* literal, std::size_t size)
>
> As view types require some outside storage, I'm will need to create an
> array of code units in static memory. I'm not sure how to do that. Also,
> the compiler says that "size" is not a constant expression. Any ideas?
>

The answer is "cheat and reinterpret cast", but you can't reinterpret cast
in "constexpr". So the real answer is: it's somewhat helpless. Whether we
like it or not, char, char8_t, char16_t, and char32_t are the strongest
string literal types we're ever going to have.

Sincerely,
ThePhD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/unicode/attachments/20190604/4b2140da/attachment.html 


More information about the Unicode mailing list