From b36de79ffdcb84c24a09daae762c4169e87eb805 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Apr 2022 21:35:24 +0200 Subject: [PATCH] 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 Reviewed-by: Sona Kurazyan --- src/corelib/tools/qvarlengtharray.h | 12 ++++++------ 1 file 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; static_assert(std::is_nothrow_destructible_v, "Types with throwing destructors are not supported in Qt containers."); using Base::verify; + + template + using if_copyable = std::enable_if_t, 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 - std::enable_if_t> +#ifndef Q_QDOC + template = 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()); }