summaryrefslogtreecommitdiff
path: root/include
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
parent1ee42f427fc80a4f3a63ee9fffbf9d187f1253ba (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')
-rw-r--r--include/editeng/editrids.hrc2
-rw-r--r--include/fpicker/strings.hrc2
-rw-r--r--include/rtl/string.hxx4
-rw-r--r--include/rtl/stringutils.hxx22
-rw-r--r--include/sfx2/strings.hrc2
-rw-r--r--include/svl/svl.hrc2
-rw-r--r--include/svtools/strings.hrc2
-rw-r--r--include/svx/strings.hrc2
-rw-r--r--include/svx/svxitems.hrc2
9 files changed, 33 insertions, 7 deletions
diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc
index c073b290d037..5a75b4ff8c85 100644
--- a/include/editeng/editrids.hrc
+++ b/include/editeng/editrids.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC
#define INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
// enum SvxBreak ------------------------------------------------------------
#define RID_SVXITEMS_BREAK_NONE NC_("RID_SVXITEMS_BREAK_NONE", "No break")
diff --git a/include/fpicker/strings.hrc b/include/fpicker/strings.hrc
index 3452509ab6b2..d86a5c569e7b 100644
--- a/include/fpicker/strings.hrc
+++ b/include/fpicker/strings.hrc
@@ -9,7 +9,7 @@
#ifndef INCLUDED_FPICKER_FPICKER_HRC
#define INCLUDED_FPICKER_FPICKER_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
#define STR_SVT_FILEPICKER_AUTO_EXTENSION NC_("STR_SVT_FILEPICKER_AUTO_EXTENSION", "~Automatic file name extension")
#define STR_SVT_FILEPICKER_PASSWORD NC_("STR_SVT_FILEPICKER_PASSWORD", "Save with pass~word")
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> {
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 322f5b23667f..6eee0347c0b7 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SFX2_INC_STRINGS_HRC
#define INCLUDED_SFX2_INC_STRINGS_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
#define STR_TEMPLATE_FILTER NC_("STR_TEMPLATE_FILTER", "Templates")
#define STR_SAVEDOC NC_("STR_SAVEDOC", "~Save")
diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc
index d9869d05aeb1..cd60edf6c346 100644
--- a/include/svl/svl.hrc
+++ b/include/svl/svl.hrc
@@ -19,7 +19,7 @@
#ifndef INCLUDED_SVL_SVL_HRC
#define INCLUDED_SVL_SVL_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
// Internet Media Type Presentations
diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc
index 3325069ddfee..84987002c7fb 100644
--- a/include/svtools/strings.hrc
+++ b/include/svtools/strings.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SVTOOLS_INC_STRINGS_HRC
#define INCLUDED_SVTOOLS_INC_STRINGS_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
#define STR_UNDO NC_("STR_UNDO", "Undo: ")
#define STR_REDO NC_("STR_REDO", "Re~do: ")
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index b93953e046e7..2d722447bdc4 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SVX_INC_STRINGS_HRC
#define INCLUDED_SVX_INC_STRINGS_HRC
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
#define STR_ObjNameSingulNONE NC_("STR_ObjNameSingulNONE", "Drawing object")
#define STR_ObjNamePluralNONE NC_("STR_ObjNamePluralNONE", "Drawing objects")
diff --git a/include/svx/svxitems.hrc b/include/svx/svxitems.hrc
index 1d11ec7acdf9..052c7fbd285c 100644
--- a/include/svx/svxitems.hrc
+++ b/include/svx/svxitems.hrc
@@ -26,7 +26,7 @@
#include <editeng/editids.hrc>
#include <utility>
-#define NC_(Context, String) (Context "\004" u8##String)
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
const std::pair<const char*, sal_uInt16> RID_ATTR_NAMES[] =
{