[Development] Oslo, we have a problem</apollo 13> [char8_t]
marc at kdab.com
Sat Jul 6 12:43:39 CEST 2019
C++20 is coming along, and it brings a disruptive change, one that far
surpasses the C++17 noexcept break: u8"Hello" is now const char8_t, no
longer const char.
To estimate the amount of breakage this will cause, assuming that using
u8"" is good practice today, to indicate that a string is in UTF-8. I've
tried to have at least QByteArray not break... and failed.
The initial idea is simple enough: add const char8_t* overloads for
const char* functions. This breaks passing nullptr, so you also add
std::nullptr_t overloads. This, however, still doesn't fix the case
where a 0 is passed. I've expected that the std::nullptr_t overload is a
preferred match over the const char[8_t]* ones, but GCC 9.1 disagrees,
and tells me it's still ambiguous.
So, if GCC is right, we have no way of adapting our API to not break in
C++20. So we need to decide what to break:
a) using 0 for nullptr, or
b) using u8"Hello" at all
The forward-looking choice would be to break (a) and support (b).
More information about the Development