summaryrefslogtreecommitdiffstats
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-08-20 20:20:22 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-08-21 07:35:50 +0200
commitf0fcbcadac148a5bfd36b2a26795d45aef8eace4 (patch)
treebade826c5f4dc8148423af476b5c980a7de28837 /include/rtl
parenttdf#57589 writerfilter: support hash-encoded colors (diff)
downloadcore-f0fcbcadac148a5bfd36b2a26795d45aef8eace4.tar.gz
core-f0fcbcadac148a5bfd36b2a26795d45aef8eace4.zip
Make OUStringLiteral ctor actually constexpr
...which had accidentally been broken with 87707670c993794ab12b0fad0f048f11429269c2 "Make OUStringLiteral more useful". (std::strlen unfortunately isn't constexpr, so need to use an explicit loop instead.) Change-Id: I9a820e2940b99a0c37124477810ef879d82c8325 Reviewed-on: https://gerrit.libreoffice.org/59344 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/stringutils.hxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index c6a5fcb64917..53f7554ee132 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -13,10 +13,13 @@
#include "sal/config.h"
#include <cstddef>
-#include <cstring>
#include "sal/types.h"
+#if defined LIBO_INTERNAL_ONLY
+#include "config_global.h"
+#endif
+
// The unittest uses slightly different code to help check that the proper
// calls are made. The class is put into a different namespace to make
// sure the compiler generates a different (if generating also non-inline)
@@ -165,8 +168,20 @@ struct ConstCharArrayDetector< const char[ N ], T >
typedef T Type;
static const std::size_t length = N - 1;
static const bool ok = true;
- static bool isValid(char const (& literal)[N])
- { return std::strlen(literal) == length; }
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR
+ constexpr
+#endif
+ static bool isValid(char const (& literal)[N]) {
+ for (std::size_t i = 0; i != N - 1; ++i) {
+ if (literal[i] == '\0') {
+ return false;
+ }
+ }
+ return literal[N - 1] == '\0';
+ }
+#if defined LIBO_INTERNAL_ONLY
+ constexpr
+#endif
static char const * toPointer(char const (& literal)[N]) { return literal; }
};
#if defined LIBO_INTERNAL_ONLY