diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-11-17 15:46:38 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-11-17 17:17:26 +0100 |
commit | c89a4996b82881988eb9cc1eeaf24e0d8f9e6dce (patch) | |
tree | 4583d522e843ee4e52e107cbaeace2aed09019b3 /include/rtl/stringutils.hxx | |
parent | 1ee42f427fc80a4f3a63ee9fffbf9d187f1253ba (diff) |
Adapt to C++2a char_t
u8 literals incompatibly change their type (as implemented by recent Clang
trunk)
Change-Id: Ia4f7b91f5d86656a056303d2754981ab2093a739
Reviewed-on: https://gerrit.libreoffice.org/63494
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl/stringutils.hxx')
-rw-r--r-- | include/rtl/stringutils.hxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx index e9aacbc3becb..f7cd0ad1a47d 100644 --- a/include/rtl/stringutils.hxx +++ b/include/rtl/stringutils.hxx @@ -207,6 +207,28 @@ struct ConstCharArrayDetector< const char[ 1 ], T > }; #endif +#if defined LIBO_INTERNAL_ONLY && defined __cpp_char8_t +template<std::size_t N, typename T> +struct ConstCharArrayDetector<char8_t const [N], T> { + using Type = T; + static constexpr bool const ok = true; + static constexpr std::size_t const length = N - 1; +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + static bool isValid(char8_t const (& literal)[N]) { + for (std::size_t i = 0; i != N - 1; ++i) { + if (literal[i] == u8'\0') { + return false; + } + } + return literal[N - 1] == u8'\0'; + } + static constexpr char const * toPointer(char8_t const (& literal)[N]) + { return reinterpret_cast<char const *>(literal); } +}; +#endif + #if defined LIBO_INTERNAL_ONLY template<std::size_t N, typename T> struct ConstCharArrayDetector<sal_Unicode const [N], T> { |