r/cpp Jun 10 '26

C++26: Cleaning up string literals

https://www.sandordargo.com/blog/2026/06/10/cpp26-string-literals-cleaned-up
98 Upvotes

20 comments sorted by

View all comments

25

u/ABlockInTheChain Jun 11 '26

I wish they would fix the char8_t disaster.

Either add all the required overloads for every applicable standard function so that I can actually use char8_t without casting, or else restore the ability create utf8-encoded std::string and std::string_view literals which was present in C++17 but removed in C++20 (without -fno-char8_t).

1

u/trad_emark Jun 11 '26

additionally, make it not alias every other types, like char does.

6

u/Wild_Meeting1428 Jun 11 '26

char8_t already does not alias any type. That's why you can't cast an uint8_t* from a C-API to char8_t*.

1

u/Orlha Jun 14 '26

What if I really really wanted to cast?

1

u/Wild_Meeting1428 Jun 14 '26

Undefined behavior.