From 46875d83476942ca215429c837a3457f55c3ccb0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 8 Nov 2022 11:51:13 +0100 Subject: A better fix for C++23 P2266R1 After 6d6a143913603b040c10a5db83c2103557899011 "Address some of the sprintf in vcl/source/fontsubset/cff.cxx", --with-latest-c++ builds that pick up a C++23 compiler that implements "P2266R1: Simpler implicit move" started to fail with something like > vcl/source/fontsubset/cff.cxx:2061:16: error: no viable conversion from returned value of type 'char[64]' to function return type 'OString' > return aDefaultGlyphName; > ^~~~~~~~~~~~~~~~~ [...] > include/rtl/string.hxx:313:5: note: candidate constructor [with T = char[64]] not viable: expects an lvalue for 1st argument > OString( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() ) > ^ etc. So I figured there should be something better than 433ab39b2175bdadb4916373cd2dc8e1aabc08a5 "Adapt implicit OString return value construction to C++23 P2266R1" (which this commit reverts, modulo its conflicts in comphelper/source/xml/xmltools.cxx and sc/source/filter/xcl97/XclExpChangeTrack.cxx) to address the underlying issue in a way that keeps code that works up to C++20 also working in C++23. (The fix is only relevant for non-explicit constructors that involve NonConstCharArrayDetector and non-const lvalue references, not for other functions involving those. OUString has a similar constructor but which is explicit, and OUStringBuffer doesn't have any similar constructors at all, so this only affects OString and OStringBuffer constructors.) Change-Id: I31cf16b9507899f5999243f8467dfa24bc94c5ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142455 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- l10ntools/source/po.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'l10ntools/source') diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index b053067ea163..e075d52b0bd5 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -425,7 +425,7 @@ OString PoEntry::genKeyId(const OString& rGenerator) nCRC >>= 6; } sKeyId[5] = '\0'; - return OString(sKeyId); + return sKeyId; } namespace @@ -437,7 +437,7 @@ namespace struct tm* pNow = localtime(&aNow); char pBuff[50]; strftime( pBuff, sizeof pBuff, "%Y-%m-%d %H:%M%z", pNow ); - return OString(pBuff); + return pBuff; } } -- cgit