Fix compilation with C++20

Fixes #428
This commit is contained in:
Olivier Goffart 2021-08-20 18:43:52 +02:00
parent b42c187ed1
commit 59e1361388
2 changed files with 15 additions and 2 deletions

View file

@ -39,6 +39,19 @@ struct SharedString
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied. It is assumed that the string is UTF-8 encoded.
SharedString(const char *s) : SharedString(std::string_view(s)) { }
#if defined(__cpp_char8_t) || __cplusplus >= 202002L
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied.
SharedString(const char8_t *s) : SharedString(reinterpret_cast<const char*>(s)) { }
#endif
#ifdef __cpp_lib_char8_t
/// Creates a new SharedString from the string view \a s. The underlying string data is copied.
SharedString(std::u8string_view s)
{
cbindgen_private::sixtyfps_shared_string_from_bytes(
this, reinterpret_cast<const char*>(s.data()), s.size());
}
#endif
/// Creates a new SharedString from \a other.
SharedString(const SharedString &other)
{