diff options
author | Dennis Oberst <dennis.oberst@qt.io> | 2023-04-26 15:53:23 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-05-03 15:07:13 +0000 |
commit | 4d404c2936627d98e996cb5750379438a084b53f (patch) | |
tree | e3face03c905ecc53fd3670554b5aa3f1d3e096e | |
parent | 6e2bba71bb8e51cecaeeacdf9c2b0f45fe1543d4 (diff) |
QVarLengthArray: remove unnecessary exception check
The previous check for a non-throwing copy constructor at:
if constexpr (IsFwdIt && noexcept(T(*first)))
is not necessary as std::uninitialized_copy provides strong exception
safety.
Additionally, change the phrasing of the overload-resolution \note,
since we're not requiring C++20 std::input_iterator, but the older
C++17 definition.
Amends 7cbdc8abbda12488f51317313347bbc220b42fe0.
Amends 2457dd8bd0a0a2be567173e3bb9dbfeb1318a02b.
Change-Id: Ie36c8d70dc61aa8cc2a30c9d4110d1beb0d1c2fe
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.qdoc | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 44c5d8beac..b4b9c96fb3 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -796,8 +796,8 @@ Q_OUTOFLINE_TEMPLATE void QVLABase<T>::assign_impl(qsizetype prealloc, void *arr ++first; } - qsizetype n = 0; - if constexpr (IsFwdIt && noexcept(T(*first))) { + qsizetype n; + if constexpr (IsFwdIt) { dst = std::uninitialized_copy(first, last, dst); n = dst - begin(); if (n > s) // otherwise: readjust 's' in erase() later diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 3ad8a82857..2e727c5d4a 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -109,7 +109,8 @@ Constructs an array with the contents in the iterator range [\a first, \a last). This constructor only participates in overload resolution if - \c InputIterator models the \c std::input_iterator concept. + \c InputIterator meets the requirements of an + \l {https://en.cppreference.com/w/cpp/named_req/InputIterator} {LegacyInputIterator}. The value type of \c InputIterator must be convertible to \c T. */ @@ -1016,7 +1017,9 @@ number of elements in the range exceeds the capacity of the container. This function overload only participates in overload resolution if - \c InputIterator models the \c std::input_iterator concept. + \c InputIterator meets the requirements of an + \l {https://en.cppreference.com/w/cpp/named_req/InputIterator} {LegacyInputIterator}. + The behavior is undefined if either argument is an iterator into *this. */ |