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>
This commit is contained in:
Marc Mutz 2020-05-15 22:43:43 +02:00
parent 7c070ac959
commit e1cab870cb

View File

@ -170,24 +170,20 @@ struct QTypeInfoQuery<T, typename std::enable_if<QTypeInfo<T>::isRelocatable ||
\snippet code/src_corelib_global_qglobal.cpp 51 \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 class QTypeInfoMerger
{ {
static_assert(sizeof...(Ts) > 0);
public: public:
enum { static constexpr bool isSpecialized = true;
isSpecialized = true, static constexpr bool isComplex = ((QTypeInfoQuery<Ts>::isComplex) || ...);
isComplex = QTypeInfoQuery<T1>::isComplex || QTypeInfoQuery<T2>::isComplex static constexpr bool isStatic = ((QTypeInfoQuery<Ts>::isStatic) || ...);
|| QTypeInfoQuery<T3>::isComplex || QTypeInfoQuery<T4>::isComplex, static constexpr bool isRelocatable = ((QTypeInfoQuery<Ts>::isRelocatable) && ...);
isStatic = QTypeInfoQuery<T1>::isStatic || QTypeInfoQuery<T2>::isStatic static constexpr bool isLarge = sizeof(T) > sizeof(void*);
|| QTypeInfoQuery<T3>::isStatic || QTypeInfoQuery<T4>::isStatic, static constexpr bool isPointer = false;
isRelocatable = QTypeInfoQuery<T1>::isRelocatable && QTypeInfoQuery<T2>::isRelocatable static constexpr bool isIntegral = false;
&& QTypeInfoQuery<T3>::isRelocatable && QTypeInfoQuery<T4>::isRelocatable, static constexpr bool isDummy = false;
isLarge = sizeof(T) > sizeof(void*), static constexpr std::size_t sizeOf = sizeof(T);
isPointer = false,
isIntegral = false,
isDummy = false,
sizeOf = sizeof(T)
};
}; };
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \ #define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \