diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2020-05-15 22:43:43 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2020-05-19 21:45:57 +0000 |
commit | e1cab870cbb9672e29aa713816e8dd8d2b15f024 (patch) | |
tree | d2af2c262649bc0c092cd82ecdc1689c6505d271 | |
parent | 7c070ac95979609e6ba33b829dc4a2a373ef26b5 (diff) |
Extend QTypeInfoMerger to more than four arguments
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 <marten.nordheim@qt.io>
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 26 |
1 files 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<T, typename std::enable_if<QTypeInfo<T>::isRelocatable || \snippet code/src_corelib_global_qglobal.cpp 51 */ -template <class T, class T1, class T2 = T1, class T3 = T1, class T4 = T1> +template <class T, class...Ts> class QTypeInfoMerger { + static_assert(sizeof...(Ts) > 0); public: - enum { - isSpecialized = true, - isComplex = QTypeInfoQuery<T1>::isComplex || QTypeInfoQuery<T2>::isComplex - || QTypeInfoQuery<T3>::isComplex || QTypeInfoQuery<T4>::isComplex, - isStatic = QTypeInfoQuery<T1>::isStatic || QTypeInfoQuery<T2>::isStatic - || QTypeInfoQuery<T3>::isStatic || QTypeInfoQuery<T4>::isStatic, - isRelocatable = QTypeInfoQuery<T1>::isRelocatable && QTypeInfoQuery<T2>::isRelocatable - && QTypeInfoQuery<T3>::isRelocatable && QTypeInfoQuery<T4>::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<Ts>::isComplex) || ...); + static constexpr bool isStatic = ((QTypeInfoQuery<Ts>::isStatic) || ...); + static constexpr bool isRelocatable = ((QTypeInfoQuery<Ts>::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) \ |