Use c++20 when available at compile time
Also std::end is constexpr where std::next sometimes isn't always with sanitizers active. Change-Id: Ibe4c11eb4945fb286247e841b6a7f6cc3ff1eaa6 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
01697c5f9b
commit
d3643d9690
@ -150,13 +150,12 @@ private:
|
||||
template <typename Char>
|
||||
static qsizetype lengthHelperPointer(const Char *str) noexcept
|
||||
{
|
||||
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
|
||||
if (__builtin_constant_p(*str)) {
|
||||
qsizetype result = 0;
|
||||
while (*str++)
|
||||
++result;
|
||||
return result;
|
||||
}
|
||||
#if defined(__cpp_lib_is_constant_evaluated)
|
||||
if (std::is_constant_evaluated())
|
||||
return std::char_traits<Char>::length(str);
|
||||
#elif defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
|
||||
if (__builtin_constant_p(*str))
|
||||
return std::char_traits<Char>::length(str);
|
||||
#endif
|
||||
return QtPrivate::qustrlen(reinterpret_cast<const char16_t *>(str));
|
||||
}
|
||||
@ -175,7 +174,7 @@ private:
|
||||
static constexpr qsizetype lengthHelperContainer(const Char (&str)[N]) noexcept
|
||||
{
|
||||
const auto it = std::char_traits<Char>::find(str, N, Char(0));
|
||||
const auto end = it ? it : std::next(str, N);
|
||||
const auto end = it ? it : std::end(str);
|
||||
return qsizetype(std::distance(str, end));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user