include/rtl/stringutils.hxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
New commits: commit bca5ba30e0bbfe04de652eb55d1a9ceac4be2b0b Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Jul 13 15:33:57 2023 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Jul 13 23:35:11 2023 +0200 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 <sberg...@redhat.com> 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; };