summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-04-11 21:35:24 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-04-13 01:16:22 +0200
commitb36de79ffdcb84c24a09daae762c4169e87eb805 (patch)
tree7b43b550f08425218579ce91be2069b3722ae607 /src/corelib/tools
parentacb9633efa7e89fe5343da36f878a39b6095d92f (diff)
QVarLengthArray: simplify SFINAE on resize(n, v)
Use our usual if_x<> = true pattern to move the constraint to where it belongs (absent C++20 requires-clauses): into the template argument list. Amends a00a1d8806cfbf17e04b88d1b4ff4a9cf5b6294a. Change-Id: I846b96bdeec3def221346897181d3d4d3a55316d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qvarlengtharray.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 2c9d0dd975..72f76dad18 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -260,6 +260,9 @@ class QVarLengthArray
using Storage = QVLAStorage<sizeof(T), alignof(T), Prealloc>;
static_assert(std::is_nothrow_destructible_v<T>, "Types with throwing destructors are not supported in Qt containers.");
using Base::verify;
+
+ template <typename U>
+ using if_copyable = std::enable_if_t<std::is_copy_constructible_v<U>, bool>;
public:
using size_type = typename Base::size_type;
using value_type = typename Base::value_type;
@@ -393,13 +396,10 @@ public:
}
bool isEmpty() const { return empty(); }
void resize(qsizetype sz) { Base::resize_impl(Prealloc, this->array, sz); }
-#ifdef Q_QDOC
- void
-#else
- template <typename U = T>
- std::enable_if_t<std::is_copy_constructible_v<U>>
+#ifndef Q_QDOC
+ template <typename U = T, if_copyable<U> = true>
#endif
- resize(qsizetype sz, const T &v)
+ void resize(qsizetype sz, const T &v)
{ Base::resize_impl(Prealloc, this->array, sz, &v); }
inline void clear() { resize(0); }
void squeeze() { reallocate(size(), size()); }