C++ Logo


Advanced search

Re: [SG16-Unicode] Need a char8_t implementation for filesystem::path_view

From: JeanHeyd Meneide <phdofthehouse_at_[hidden]>
Date: Wed, 31 Jul 2019 11:11:15 -0400
On Wed, Jul 31, 2019 at 10:19 AM Lyberta <lyberta_at_[hidden]> wrote:

> > The benefit is unsigned char already has char_traits support too.
> I'm looking at [char.traits.specializations] and don't see it.

It's not in the standard specifically, no, but no implementation is dumb
enough to ban it. If you have a strong over unsigned char, you can then
specialize char_traits for it by just doing

template <>
struct char_traits<u8char> : char_traits<unsigned char> {};

This requires that there's an implicit conversion from u8char -> unsigned
char, which I would imagine is safe enough unless you really care about
overload resolution. If overload resolution is a problem, I would suggest
either biting the bullet of a full implementation, or throwing out the
strong typedef altogether and just using "unsigned char" for your u8 type


Received on 2019-07-31 17:11:29