From e1cab870cbb9672e29aa713816e8dd8d2b15f024 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 15 May 2020 22:43:43 +0200 Subject: [PATCH] Extend QTypeInfoMerger to more than four arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use template argument pack and C++17 fold expressions. Because MSVC doesn't grok fold expressions in enumerator-definition contexts, use static constexpr bool variables. Change-Id: I13a676d9be687679ef41f7b003e50116c4cd533c Reviewed-by: MÃ¥rten Nordheim --- src/corelib/global/qtypeinfo.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 34cf1de4f5..e16ffb08ee 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -170,24 +170,20 @@ struct QTypeInfoQuery::isRelocatable || \snippet code/src_corelib_global_qglobal.cpp 51 */ -template +template class QTypeInfoMerger { + static_assert(sizeof...(Ts) > 0); public: - enum { - isSpecialized = true, - isComplex = QTypeInfoQuery::isComplex || QTypeInfoQuery::isComplex - || QTypeInfoQuery::isComplex || QTypeInfoQuery::isComplex, - isStatic = QTypeInfoQuery::isStatic || QTypeInfoQuery::isStatic - || QTypeInfoQuery::isStatic || QTypeInfoQuery::isStatic, - isRelocatable = QTypeInfoQuery::isRelocatable && QTypeInfoQuery::isRelocatable - && QTypeInfoQuery::isRelocatable && QTypeInfoQuery::isRelocatable, - isLarge = sizeof(T) > sizeof(void*), - isPointer = false, - isIntegral = false, - isDummy = false, - sizeOf = sizeof(T) - }; + static constexpr bool isSpecialized = true; + static constexpr bool isComplex = ((QTypeInfoQuery::isComplex) || ...); + static constexpr bool isStatic = ((QTypeInfoQuery::isStatic) || ...); + static constexpr bool isRelocatable = ((QTypeInfoQuery::isRelocatable) && ...); + static constexpr bool isLarge = sizeof(T) > sizeof(void*); + static constexpr bool isPointer = false; + static constexpr bool isIntegral = false; + static constexpr bool isDummy = false; + static constexpr std::size_t sizeOf = sizeof(T); }; #define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \