Q_ARRAY_LITERAL: fix the checks on the payload's datatype
The check was a misnomer -- non-POD types can go in unions since C++11. And we may want them, e.g. types without a trivial default constructor. What we really want is to check for a literal type (so that the array payload can be built entirely at compile time, and put in .rodata). So, amend the check. Also, make the dummy array constexpr, to be sure that we are indeed building the payload using constexpr constructors. That would make the first check redundant, but the fact that we're still using a macro for constexpr makes me think that not all compilers support it, so I'm leaving the first check in... Change-Id: I9f1473aa74dff5b6b6535ae4cd8325451c0b18e6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
parent
620f121206
commit
ff88c3bc55
|
|
@ -324,10 +324,10 @@ struct QArrayDataPointerRef
|
|||
/**/
|
||||
|
||||
#define Q_ARRAY_LITERAL_IMPL(Type, ...) \
|
||||
union { Type type_must_be_POD; } dummy; Q_UNUSED(dummy) \
|
||||
Q_STATIC_ASSERT(std::is_literal_type<Type>::value); \
|
||||
\
|
||||
/* Portable compile-time array size computation */ \
|
||||
Type data[] = { __VA_ARGS__ }; Q_UNUSED(data) \
|
||||
Q_CONSTEXPR Type data[] = { __VA_ARGS__ }; Q_UNUSED(data); \
|
||||
enum { Size = sizeof(data) / sizeof(data[0]) }; \
|
||||
\
|
||||
static const QStaticArrayData<Type, Size> literal = { \
|
||||
|
|
|
|||
Loading…
Reference in New Issue