QVarLengthArray: Add explicit assertions for implicit assumptions

Change-Id: I4dfbf6174483b4af91f31a05c18cfec2aaec6e1f
Pick-to: 6.2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Robert Löhning 2021-10-26 21:07:16 +02:00
parent a6947853ee
commit ee487c6b89

View File

@ -619,6 +619,8 @@ template <typename...Args>
Q_OUTOFLINE_TEMPLATE auto QVarLengthArray<T, Prealloc>::emplace(const_iterator before, Args &&...args) -> iterator
{
Q_ASSERT_X(isValidIterator(before), "QVarLengthArray::insert", "The specified const_iterator argument 'before' is invalid");
Q_ASSERT(s <= a);
Q_ASSERT(a > 0);
qsizetype offset = qsizetype(before - ptr);
if (s == a)