C++ Logo


Advanced search

Subject: Re: [SG16-Unicode] String views with strong code unit types
From: Tom Honermann (tom_at_[hidden])
Date: 2019-07-06 22:28:55

On 6/4/19 3:38 AM, Lyberta 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?

This is a solvable problem in C++20 due to the adoption of P0732.  See
the "Emulate C++17 u8 literals" section of P1423R2
for an example.  Note that gcc's implementation of P0732 currently has a
defect that prevents this technique being used.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88095.%c2  A patch has been
proposed, but I haven't tried it yet.


SG16 list run by sg16-owner@lists.isocpp.org