Date: Sat, 6 Jul 2019 23:28:55 -0400
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
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r2.html#emulate)
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. A patch has been
proposed, but I haven't tried it yet.
Tom.
> 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
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r2.html#emulate)
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. A patch has been
proposed, but I haven't tried it yet.
Tom.
Received on 2019-07-07 05:36:52