tst_qstringview: modernize functions in help namespace
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 <marten.nordheim@qt.io>
This commit is contained in:
parent
d67551ff5b
commit
dd4e96df52
@ -575,22 +575,22 @@ size_t size(const QChar *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename T::const_iterator cbegin(const T &t) { return t.cbegin(); }
|
decltype(auto) cbegin(const T &t) { return t.begin(); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T * cbegin(const T *t) { return t; }
|
const T * cbegin(const T *t) { return t; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename T::const_iterator cend(const T &t) { return t.cend(); }
|
decltype(auto) cend(const T &t) { return t.end(); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T * cend(const T *t) { return t + size(t); }
|
const T * cend(const T *t) { return t + size(t); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename T::const_reverse_iterator crbegin(const T &t) { return t.crbegin(); }
|
decltype(auto) crbegin(const T &t) { return t.rbegin(); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::reverse_iterator<const T*> crbegin(const T *t) { return std::reverse_iterator<const T*>(cend(t)); }
|
std::reverse_iterator<const T*> crbegin(const T *t) { return std::reverse_iterator<const T*>(cend(t)); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename T::const_reverse_iterator crend(const T &t) { return t.crend(); }
|
decltype(auto) crend(const T &t) { return t.rend(); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::reverse_iterator<const T*> crend(const T *t) { return std::reverse_iterator<const T*>(cbegin(t)); }
|
std::reverse_iterator<const T*> crend(const T *t) { return std::reverse_iterator<const T*>(cbegin(t)); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user