From dd4e96df528a64bd994bf44e9b618463e0562ab0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 8 May 2020 11:02:58 +0200 Subject: [PATCH] tst_qstringview: modernize functions in help namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They don't work with std::span, since std::span has neither const_iterator nor cbegin()/cend(). To fix, perfectly forward the return type with decltype(auto) instead of mentioning T::const_iterator, and rely on the const-qualfication of the help::c{r,}{begin,end}() functions' arguments to select the correct T::{r,}{begin,end}() overload. Change-Id: I4992d4bd521d2dc0f9ea51ae70cde8286ae543a5 Reviewed-by: MÃ¥rten Nordheim --- tests/auto/corelib/text/qstringview/tst_qstringview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index 631bcce508..5b9eb03fe3 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -575,22 +575,22 @@ size_t size(const QChar *t) } template -typename T::const_iterator cbegin(const T &t) { return t.cbegin(); } +decltype(auto) cbegin(const T &t) { return t.begin(); } template const T * cbegin(const T *t) { return t; } template -typename T::const_iterator cend(const T &t) { return t.cend(); } +decltype(auto) cend(const T &t) { return t.end(); } template const T * cend(const T *t) { return t + size(t); } template -typename T::const_reverse_iterator crbegin(const T &t) { return t.crbegin(); } +decltype(auto) crbegin(const T &t) { return t.rbegin(); } template std::reverse_iterator crbegin(const T *t) { return std::reverse_iterator(cend(t)); } template -typename T::const_reverse_iterator crend(const T &t) { return t.crend(); } +decltype(auto) crend(const T &t) { return t.rend(); } template std::reverse_iterator crend(const T *t) { return std::reverse_iterator(cbegin(t)); }