summaryrefslogtreecommitdiffstats
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-11-17 15:46:38 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-11-17 17:17:26 +0100
commitc89a4996b82881988eb9cc1eeaf24e0d8f9e6dce (patch)
tree4583d522e843ee4e52e107cbaeace2aed09019b3 /include/rtl
parentdrop unused SvTreeListBoxFlags::IS_EXPANDING (diff)
downloadcore-c89a4996b82881988eb9cc1eeaf24e0d8f9e6dce.tar.gz
core-c89a4996b82881988eb9cc1eeaf24e0d8f9e6dce.zip
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')
-rw-r--r--include/rtl/string.hxx4
-rw-r--r--include/rtl/stringutils.hxx22
2 files changed, 26 insertions, 0 deletions
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index f19d8713eaae..812ceb71cd9e 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1804,6 +1804,10 @@ struct SAL_WARN_UNUSED OStringLiteral
{
template< int N >
explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
+#if defined __cpp_char8_t
+ template< int N >
+ explicit OStringLiteral( const char8_t (&str)[ N ] ) : size( N - 1 ), data( reinterpret_cast<char const *>(str) ) { assert( strlen( data ) == N - 1 ); }
+#endif
int size;
const char* data;
};
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> {