summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-07-13 15:33:57 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-07-13 23:35:11 +0200
commitbca5ba30e0bbfe04de652eb55d1a9ceac4be2b0b (patch)
treed849dc24107277ca4b2e7b5bb45c307596cedfec /include/rtl
parent0c421a9aa3210d3bafdc8bb5e0d79cc1b58b4b33 (diff)
Restrict deleted catch-all O[U]StringChar ctor to arithmetic/enum types
...which should still cover the issues that 7320d7a4a4dd0657f2d650a6f580ad399529f0f1 "OUStringChar must either take a sal_Unicode or an ASCII char" wanted to address, but without causing ambiguities where some unrelated type would unexpectedly be sucked into a conversion chain going through these ctors Change-Id: Iee3769dc6af5d7a1c8540a548bc2e10a89e637da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154391 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/stringutils.hxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index 58781973fab9..2c5d05c82784 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -19,6 +19,10 @@
#include <cassert>
#include <cstddef>
+#if defined LIBO_INTERNAL_ONLY
+#include <type_traits>
+#endif
+
#include "sal/types.h"
// The unittest uses slightly different code to help check that the proper
@@ -48,7 +52,8 @@ namespace rtl
//
struct SAL_WARN_UNUSED OStringChar {
constexpr OStringChar(char theC): c(theC) {}
- template<typename T> OStringChar(T &&) = delete;
+ template<typename T> OStringChar(
+ T, std::enable_if_t<std::is_arithmetic_v<T> || std::is_enum_v<T>, int> = 0) = delete;
constexpr operator std::string_view() const { return {&c, 1}; }
char const c;
};
@@ -98,7 +103,8 @@ struct SAL_WARN_UNUSED OStringChar {
struct SAL_WARN_UNUSED OUStringChar_ {
constexpr OUStringChar_(sal_Unicode theC): c(theC) {}
constexpr OUStringChar_(char theC): c(theC) { assert(c <= 0x7F); }
- template<typename T> OUStringChar_(T &&) = delete;
+ template<typename T> OUStringChar_(
+ T, std::enable_if_t<std::is_arithmetic_v<T> || std::is_enum_v<T>, int> = 0) = delete;
constexpr operator std::u16string_view() const { return {&c, 1}; }
sal_Unicode const c;
};