Make Container::max_size() non-static member functions

... as is required by the standard.

We have already found that QAnyStringView::max_size() can also not be
static (because the size depends on the charset of the contained
data), so we have a second reason (besides STL compatibility) to
change the current static into non-static max_size() member functions:
Qt consistency.

Found in API-Review.

Amends 7ce6920aacfcba485cd8017e01c6aeb324292e75.

Pick-to: 6.8
Fixes: QTBUG-128450
Change-Id: Id5ee3fec82bc557bd83b6843838ccdd753442cd0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Marc Mutz 2024-08-29 15:02:23 +02:00 committed by Ivan Solovev
parent 6c15f99853
commit 6d5e39f475
8 changed files with 10 additions and 10 deletions

View File

@ -1420,7 +1420,7 @@ QByteArray &QByteArray::operator=(const char *str)
\sa isEmpty(), resize()
*/
/*! \fn qsizetype QByteArray::max_size()
/*! \fn qsizetype QByteArray::max_size() const
\fn qsizetype QByteArray::maxSize()
\since 6.8

View File

@ -482,8 +482,7 @@ public:
void shrink_to_fit() { squeeze(); }
iterator erase(const_iterator first, const_iterator last);
inline iterator erase(const_iterator it) { return erase(it, it + 1); }
static constexpr qsizetype max_size() noexcept
constexpr qsizetype max_size() const noexcept
{
return maxSize();
}

View File

@ -6412,7 +6412,7 @@ QString& QString::fill(QChar ch, qsizetype size)
*/
/*!
\fn qsizetype QString::max_size()
\fn qsizetype QString::max_size() const
\fn qsizetype QString::maxSize()
\since 6.8

View File

@ -969,7 +969,7 @@ public:
void shrink_to_fit() { squeeze(); }
iterator erase(const_iterator first, const_iterator last);
inline iterator erase(const_iterator it) { return erase(it, it + 1); }
static constexpr qsizetype max_size() noexcept
constexpr qsizetype max_size() const noexcept
{
return maxSize();
}

View File

@ -691,7 +691,7 @@ public:
inline reference back() { return last(); }
inline const_reference back() const noexcept { return last(); }
void shrink_to_fit() { squeeze(); }
static constexpr qsizetype max_size() noexcept
constexpr qsizetype max_size() const noexcept
{
return maxSize();
}

View File

@ -1332,7 +1332,7 @@
returns \c false.
*/
/*! \fn template <typename T> qsizetype QList<T>::max_size()
/*! \fn template <typename T> qsizetype QList<T>::max_size() const
\fn template <typename T> qsizetype QList<T>::maxSize()
\since 6.8

View File

@ -189,7 +189,7 @@ public:
// -1 to deal with the pointer one-past-the-end
return (QtPrivate::MaxAllocSize / sizeof(T)) - 1;
}
static constexpr qsizetype max_size() noexcept
constexpr qsizetype max_size() const noexcept
{
return maxSize();
}
@ -409,9 +409,10 @@ public:
#ifdef Q_QDOC
inline qsizetype size() const { return this->s; }
static constexpr qsizetype maxSize() noexcept { return QVLABase<T>::maxSize(); }
static constexpr qsizetype max_size() noexcept { return QVLABase<T>::max_size(); }
constexpr qsizetype max_size() const noexcept { return QVLABase<T>::max_size(); }
#endif
using Base::size;
using Base::max_size;
inline qsizetype count() const { return size(); }
inline qsizetype length() const { return size(); }
inline T &first()

View File

@ -140,7 +140,7 @@
\sa isEmpty(), resize()
*/
/*! \fn template<class T, qsizetype Prealloc> qsizetype QVarLengthArray<T, Prealloc>::max_size()
/*! \fn template<class T, qsizetype Prealloc> qsizetype QVarLengthArray<T, Prealloc>::max_size() const
\fn template<class T, qsizetype Prealloc> qsizetype QVarLengthArray<T, Prealloc>::maxSize()
\since 6.8