From e6ca379bcbe7d9fb426cf8944f24e345e8856d3f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 19 Oct 2023 13:21:20 +0200 Subject: Clean up some C++20 TODOs Change-Id: I8baece4349683c7a83a283b85e24f33874b47ba3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158177 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- include/rtl/string.hxx | 13 ++++--------- include/rtl/ustring.hxx | 7 ++----- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'include/rtl') diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index 62bf0530e819..55b83d675d8d 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -36,6 +36,7 @@ #include #if defined LIBO_INTERNAL_ONLY +#include #include #include #endif @@ -98,10 +99,7 @@ public: OStringLiteral(char const (&literal)[N]) { assertLayout(); assert(literal[N - 1] == '\0'); - //TODO: Use C++20 constexpr std::copy_n (P0202R3): - for (std::size_t i = 0; i != N; ++i) { - more.buffer[i] = literal[i]; - } + std::copy_n(literal, N, more.buffer); } #if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1938 && defined _MANAGED) @@ -113,10 +111,7 @@ public: OStringLiteral(char8_t const (&literal)[N]) { assertLayout(); assert(literal[N - 1] == '\0'); - //TODO: Use C++20 constexpr std::copy_n (P0202R3): - for (std::size_t i = 0; i != N; ++i) { - more.buffer[i] = literal[i]; - } + std::copy_n(literal, N, more.buffer); } #endif @@ -141,7 +136,7 @@ private: oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx) sal_Int32 length = N - 1; - char buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2) + char buffer[N]; }; public: diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index cd23f121e2ac..cad8cc10ac48 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -96,10 +96,7 @@ public: OUStringLiteral(char16_t const (&literal)[N]) { assertLayout(); assert(literal[N - 1] == '\0'); - //TODO: Use C++20 constexpr std::copy_n (P0202R3): - for (std::size_t i = 0; i != N; ++i) { - more.buffer[i] = literal[i]; - } + std::copy_n(literal, N, more.buffer); } constexpr sal_Int32 getLength() const { return more.length; } @@ -123,7 +120,7 @@ private: oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx) sal_Int32 length = N - 1; - sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2) + sal_Unicode buffer[N]; }; public: -- cgit