Port Q_STATIC_ASSERT(_X) to static_assert
There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
5b686e208f
commit
3e1d03b1ea
@ -231,7 +231,7 @@ template <typename T> static inline bool canConvertTo(double v)
|
||||
// integrals to floating-point with loss of precision has implementation-
|
||||
// defined behavior whether the next higher or next lower is returned;
|
||||
// converting FP to integral is UB if it can't be represented.;
|
||||
Q_STATIC_ASSERT(std::numeric_limits<T>::is_integer);
|
||||
static_assert(std::numeric_limits<T>::is_integer);
|
||||
|
||||
double supremum = ldexp(1, std::numeric_limits<T>::digits);
|
||||
if (v >= supremum)
|
||||
|
@ -88,10 +88,10 @@ Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept
|
||||
template<typename Enum>
|
||||
class QFlags
|
||||
{
|
||||
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
|
||||
static_assert((sizeof(Enum) <= sizeof(int)),
|
||||
"QFlags uses an int as storage, so an enum with underlying "
|
||||
"long long will overflow.");
|
||||
Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
|
||||
static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5,15)
|
||||
struct Private;
|
||||
|
@ -133,15 +133,15 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
|
||||
// in. The idea here is to error or warn if otherwise implicit Qt
|
||||
// assumptions are not fulfilled on new hardware or compilers
|
||||
// (if this list becomes too long, consider factoring into a separate file)
|
||||
Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
|
||||
Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits");
|
||||
Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly");
|
||||
Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits");
|
||||
Q_STATIC_ASSERT_X(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
|
||||
Q_STATIC_ASSERT_X(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<int>::radix == 2,
|
||||
static_assert(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
|
||||
static_assert(sizeof(int) == 4, "Qt assumes that int is 32 bits");
|
||||
static_assert(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly");
|
||||
static_assert(sizeof(float) == 4, "Qt assumes that float is 32 bits");
|
||||
static_assert(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
|
||||
static_assert(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
|
||||
static_assert(std::numeric_limits<int>::radix == 2,
|
||||
"Qt assumes binary integers");
|
||||
Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
|
||||
static_assert((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
|
||||
"Qt assumes two's complement integers");
|
||||
|
||||
// While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011
|
||||
@ -152,13 +152,13 @@ Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::l
|
||||
// On GHC the compiler reports std::numeric_limits<float>::is_iec559 as false.
|
||||
// This is all right according to our needs.
|
||||
#if !defined(Q_CC_GHS)
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<float>::is_iec559,
|
||||
static_assert(std::numeric_limits<float>::is_iec559,
|
||||
"Qt assumes IEEE 754 floating point");
|
||||
#endif
|
||||
|
||||
// Technically, presence of NaN and infinities are implied from the above check,
|
||||
// but double checking our environment doesn't hurt...
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity &&
|
||||
static_assert(std::numeric_limits<float>::has_infinity &&
|
||||
std::numeric_limits<float>::has_quiet_NaN &&
|
||||
std::numeric_limits<float>::has_signaling_NaN,
|
||||
"Qt assumes IEEE 754 floating point");
|
||||
@ -167,13 +167,13 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity &&
|
||||
// but that allows for a non-binary radix. We need to recheck that.
|
||||
// Note how __STDC_IEC_559__ would instead check for IEC 60559:1989, aka
|
||||
// ANSI/IEEE 754−1985, which specifically implies binary floating point numbers.
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2,
|
||||
static_assert(std::numeric_limits<float>::radix == 2,
|
||||
"Qt assumes binary IEEE 754 floating point");
|
||||
|
||||
// not required by the definition of size_t, but we depend on this
|
||||
Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
|
||||
Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
|
||||
Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
|
||||
static_assert(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
|
||||
static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
|
||||
static_assert((std::is_same<qsizetype, qptrdiff>::value));
|
||||
|
||||
/*!
|
||||
\class QFlag
|
||||
|
@ -70,7 +70,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
|
||||
18
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));
|
||||
static_assert(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -169,7 +169,7 @@ Q_CORE_EXPORT quint32 qFloatDistance(float a, float b)
|
||||
* IEE754 format.
|
||||
* Integers and floats have the same endian
|
||||
*/
|
||||
Q_STATIC_ASSERT(sizeof(quint32) == sizeof(float));
|
||||
static_assert(sizeof(quint32) == sizeof(float));
|
||||
Q_ASSERT(qIsFinite(a) && qIsFinite(b));
|
||||
if (a == b)
|
||||
return 0;
|
||||
@ -227,7 +227,7 @@ Q_CORE_EXPORT quint64 qFloatDistance(double a, double b)
|
||||
* IEE754 format double precision
|
||||
* Integers and floats have the same endian
|
||||
*/
|
||||
Q_STATIC_ASSERT(sizeof(quint64) == sizeof(double));
|
||||
static_assert(sizeof(quint64) == sizeof(double));
|
||||
Q_ASSERT(qIsFinite(a) && qIsFinite(b));
|
||||
if (a == b)
|
||||
return 0;
|
||||
|
@ -128,7 +128,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas
|
||||
|
||||
Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_infinity,
|
||||
static_assert(std::numeric_limits<double>::has_infinity,
|
||||
"platform has no definition for infinity for type double");
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
@ -136,7 +136,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
|
||||
#if QT_CONFIG(signaling_nan)
|
||||
Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_signaling_NaN,
|
||||
static_assert(std::numeric_limits<double>::has_signaling_NaN,
|
||||
"platform has no definition for signaling NaN for type double");
|
||||
return std::numeric_limits<double>::signaling_NaN();
|
||||
}
|
||||
@ -145,7 +145,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
|
||||
// Quiet NaN
|
||||
Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_quiet_NaN,
|
||||
static_assert(std::numeric_limits<double>::has_quiet_NaN,
|
||||
"platform has no definition for quiet NaN for type double");
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
@ -204,7 +204,7 @@ namespace {
|
||||
*/
|
||||
template <typename T> static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
|
||||
{
|
||||
Q_STATIC_ASSERT(std::numeric_limits<T>::is_integer);
|
||||
static_assert(std::numeric_limits<T>::is_integer);
|
||||
|
||||
// The [conv.fpint] (7.10 Floating-integral conversions) section of the C++
|
||||
// standard says only exact conversions are guaranteed. Converting
|
||||
|
@ -183,7 +183,7 @@ struct QRandomGenerator::SystemGenerator
|
||||
// other than quint32 (unsigned int) to fill their buffers.
|
||||
template <typename T> void generate(T *begin, T *end)
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(T) >= sizeof(quint32));
|
||||
static_assert(sizeof(T) >= sizeof(quint32));
|
||||
if (sizeof(T) == sizeof(quint32)) {
|
||||
// Microsoft Visual Studio uses unsigned long, but that's still 32-bit
|
||||
generate(reinterpret_cast<quint32 *>(begin), reinterpret_cast<quint32 *>(end));
|
||||
@ -377,14 +377,14 @@ struct QRandomGenerator::SystemAndGlobalGenerators
|
||||
|
||||
constexpr SystemAndGlobalGenerators g = {};
|
||||
Q_UNUSED(g);
|
||||
Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
|
||||
static_assert(std::is_literal_type<SystemAndGlobalGenerators>::value);
|
||||
#endif
|
||||
}
|
||||
|
||||
static SystemAndGlobalGenerators *self()
|
||||
{
|
||||
static SystemAndGlobalGenerators g;
|
||||
Q_STATIC_ASSERT(sizeof(g) > sizeof(QRandomGenerator64));
|
||||
static_assert(sizeof(g) > sizeof(QRandomGenerator64));
|
||||
return &g;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ private:
|
||||
const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); }
|
||||
#endif
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_trivially_destructible<RandomEngine>::value,
|
||||
static_assert(std::is_trivially_destructible<RandomEngine>::value,
|
||||
"std::mersenne_twister not trivially destructible as expected");
|
||||
Q_DECL_CONSTEXPR Storage();
|
||||
};
|
||||
|
@ -756,10 +756,10 @@ bool QFileDevice::unmap(uchar *address)
|
||||
|
||||
static inline QAbstractFileEngine::FileTime FileDeviceTimeToAbstractFileEngineTime(QFileDevice::FileTime time)
|
||||
{
|
||||
Q_STATIC_ASSERT(int(QFileDevice::FileAccessTime) == int(QAbstractFileEngine::AccessTime));
|
||||
Q_STATIC_ASSERT(int(QFileDevice::FileBirthTime) == int(QAbstractFileEngine::BirthTime));
|
||||
Q_STATIC_ASSERT(int(QFileDevice::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime));
|
||||
Q_STATIC_ASSERT(int(QFileDevice::FileModificationTime) == int(QAbstractFileEngine::ModificationTime));
|
||||
static_assert(int(QFileDevice::FileAccessTime) == int(QAbstractFileEngine::AccessTime));
|
||||
static_assert(int(QFileDevice::FileBirthTime) == int(QAbstractFileEngine::BirthTime));
|
||||
static_assert(int(QFileDevice::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime));
|
||||
static_assert(int(QFileDevice::FileModificationTime) == int(QAbstractFileEngine::ModificationTime));
|
||||
return QAbstractFileEngine::FileTime(time);
|
||||
}
|
||||
|
||||
|
@ -1492,10 +1492,10 @@ QDateTime QFileInfo::lastRead() const
|
||||
*/
|
||||
QDateTime QFileInfo::fileTime(QFile::FileTime time) const
|
||||
{
|
||||
Q_STATIC_ASSERT(int(QFile::FileAccessTime) == int(QAbstractFileEngine::AccessTime));
|
||||
Q_STATIC_ASSERT(int(QFile::FileBirthTime) == int(QAbstractFileEngine::BirthTime));
|
||||
Q_STATIC_ASSERT(int(QFile::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime));
|
||||
Q_STATIC_ASSERT(int(QFile::FileModificationTime) == int(QAbstractFileEngine::ModificationTime));
|
||||
static_assert(int(QFile::FileAccessTime) == int(QAbstractFileEngine::AccessTime));
|
||||
static_assert(int(QFile::FileBirthTime) == int(QAbstractFileEngine::BirthTime));
|
||||
static_assert(int(QFile::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime));
|
||||
static_assert(int(QFile::FileModificationTime) == int(QAbstractFileEngine::ModificationTime));
|
||||
|
||||
Q_D(const QFileInfo);
|
||||
auto fetime = QAbstractFileEngine::FileTime(time);
|
||||
|
@ -85,7 +85,7 @@ typedef unsigned int UnsignedIOType;
|
||||
#else
|
||||
typedef ssize_t SignedIOType;
|
||||
typedef size_t UnsignedIOType;
|
||||
Q_STATIC_ASSERT_X(sizeof(SignedIOType) == sizeof(UnsignedIOType),
|
||||
static_assert(sizeof(SignedIOType) == sizeof(UnsignedIOType),
|
||||
"Unsupported: read/write return a type with different size as the len parameter");
|
||||
#endif
|
||||
|
||||
|
@ -147,7 +147,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
|
||||
FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path)
|
||||
FOLDERID_LocalAppData, // AppConfigLocation ("Local" path)
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
|
||||
static_assert(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
|
||||
|
||||
// folders for low integrity processes
|
||||
static const GUID folderIds_li[] = {
|
||||
@ -169,7 +169,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
|
||||
FOLDERID_RoamingAppData, // AppDataLocation ("Roaming" path)
|
||||
FOLDERID_LocalAppDataLow,// AppConfigLocation ("Local" path)
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(folderIds_li) == sizeof(folderIds));
|
||||
static_assert(sizeof(folderIds_li) == sizeof(folderIds));
|
||||
|
||||
static bool low_integrity_process = isProcessLowIntegrity();
|
||||
if (size_t(type) < sizeof(folderIds) / sizeof(folderIds[0]))
|
||||
|
@ -190,7 +190,7 @@ bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs)
|
||||
*/
|
||||
bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds)
|
||||
{
|
||||
Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(QDeadlineTimerNanosecondsInT2);
|
||||
nsecs += t2;
|
||||
if (nsecs >= ugiga) {
|
||||
nsecs -= ugiga;
|
||||
@ -291,7 +291,7 @@ inline bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs)
|
||||
|
||||
inline bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds)
|
||||
{
|
||||
Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(!QDeadlineTimerNanosecondsInT2);
|
||||
Q_UNUSED(t2);
|
||||
Q_UNUSED(carrySeconds);
|
||||
|
||||
|
@ -156,7 +156,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept
|
||||
|
||||
QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(!QDeadlineTimerNanosecondsInT2);
|
||||
QDeadlineTimer result;
|
||||
result.type = timerType;
|
||||
result.t1 = absoluteToNSecs(mach_absolute_time());
|
||||
|
@ -252,7 +252,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept
|
||||
|
||||
QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(QDeadlineTimerNanosecondsInT2);
|
||||
QDeadlineTimer result;
|
||||
qint64 cursec, curnsec;
|
||||
do_gettime(&cursec, &curnsec);
|
||||
|
@ -162,7 +162,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept
|
||||
|
||||
QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(!QDeadlineTimerNanosecondsInT2);
|
||||
QDeadlineTimer result;
|
||||
result.t1 = ticksToNanoseconds(getTickCount());
|
||||
result.type = timerType;
|
||||
|
@ -171,7 +171,7 @@ public:
|
||||
static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
|
||||
{
|
||||
typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
return fromSignalImpl(&SignalType::Object::staticMetaObject,
|
||||
reinterpret_cast<void **>(&signal));
|
||||
@ -241,7 +241,7 @@ public:
|
||||
inline bool isValid() const { return name() != nullptr; }
|
||||
|
||||
template<typename T> static QMetaEnum fromType() {
|
||||
Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value,
|
||||
static_assert(QtPrivate::IsQEnumHelper<T>::Value,
|
||||
"QMetaEnum::fromType only works with enums declared as "
|
||||
"Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS");
|
||||
const QMetaObject *metaObject = qt_getEnumMetaObject(T());
|
||||
|
@ -1193,7 +1193,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
||||
- int(d->methods.size()) // return "parameters" don't have names
|
||||
- int(d->constructors.size()); // "this" parameters don't have names
|
||||
if (buf) {
|
||||
Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 9, "QMetaObjectBuilder should generate the same version as moc");
|
||||
static_assert(QMetaObjectPrivate::OutputRevision == 9, "QMetaObjectBuilder should generate the same version as moc");
|
||||
pmeta->revision = QMetaObjectPrivate::OutputRevision;
|
||||
pmeta->flags = d->flags;
|
||||
pmeta->className = 0; // Class name is always the first string.
|
||||
|
@ -1293,7 +1293,7 @@ class HasStreamOperator
|
||||
{
|
||||
struct Yes { char unused[1]; };
|
||||
struct No { char unused[2]; };
|
||||
Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No));
|
||||
static_assert(sizeof(Yes) != sizeof(No));
|
||||
|
||||
template<class C> static decltype(std::declval<QDataStream&>().operator>>(std::declval<C&>()), Yes()) load(int);
|
||||
template<class C> static decltype(operator>>(std::declval<QDataStream&>(), std::declval<C&>()), Yes()) load(int);
|
||||
@ -1310,9 +1310,9 @@ public:
|
||||
};
|
||||
|
||||
// Quick sanity checks
|
||||
Q_STATIC_ASSERT(HasStreamOperator<NS(QJsonDocument)>::Value);
|
||||
Q_STATIC_ASSERT(!HasStreamOperator<void*>::Value);
|
||||
Q_STATIC_ASSERT(HasStreamOperator<qint8>::Value);
|
||||
static_assert(HasStreamOperator<NS(QJsonDocument)>::Value);
|
||||
static_assert(!HasStreamOperator<void*>::Value);
|
||||
static_assert(HasStreamOperator<qint8>::Value);
|
||||
|
||||
template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted && HasStreamOperator<T>::Value>
|
||||
struct FilteredOperatorSwitch
|
||||
|
@ -580,7 +580,7 @@ public:
|
||||
template<typename T>
|
||||
static bool registerComparators()
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
"QMetaType::registerComparators: The type must be a custom type.");
|
||||
|
||||
const int typeId = qMetaTypeId<T>();
|
||||
@ -590,7 +590,7 @@ public:
|
||||
template<typename T>
|
||||
static bool registerEqualsComparator()
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
"QMetaType::registerEqualsComparator: The type must be a custom type.");
|
||||
const int typeId = qMetaTypeId<T>();
|
||||
static const QtPrivate::BuiltInEqualsComparatorFunction<T> f;
|
||||
@ -609,7 +609,7 @@ public:
|
||||
template<typename T>
|
||||
static bool registerDebugStreamOperator()
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<T>::IsBuiltIn),
|
||||
"QMetaType::registerDebugStreamOperator: The type must be a custom type.");
|
||||
|
||||
const int typeId = qMetaTypeId<T>();
|
||||
@ -643,7 +643,7 @@ public:
|
||||
template<typename From, typename To>
|
||||
static bool registerConverter(To(From::*function)() const)
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
"QMetaType::registerConverter: At least one of the types must be a custom type.");
|
||||
|
||||
const int fromTypeId = qMetaTypeId<From>();
|
||||
@ -656,7 +656,7 @@ public:
|
||||
template<typename From, typename To>
|
||||
static bool registerConverter(To(From::*function)(bool*) const)
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
"QMetaType::registerConverter: At least one of the types must be a custom type.");
|
||||
|
||||
const int fromTypeId = qMetaTypeId<From>();
|
||||
@ -669,7 +669,7 @@ public:
|
||||
template<typename From, typename To, typename UnaryFunction>
|
||||
static bool registerConverter(UnaryFunction function)
|
||||
{
|
||||
Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
|
||||
"QMetaType::registerConverter: At least one of the types must be a custom type.");
|
||||
|
||||
const int fromTypeId = qMetaTypeId<From>();
|
||||
@ -1444,7 +1444,7 @@ namespace QtPrivate
|
||||
static yes_type checkType(QObject* );
|
||||
#endif
|
||||
static no_type checkType(...);
|
||||
Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
|
||||
static_assert(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
|
||||
enum { Value = sizeof(checkType(static_cast<T*>(nullptr))) == sizeof(yes_type) };
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ public: \
|
||||
IsUnknown = !(IsCore || IsWidget || IsGui) \
|
||||
}; \
|
||||
static inline int module() { return MODULE; } \
|
||||
Q_STATIC_ASSERT((IsUnknown && !(IsCore || IsWidget || IsGui)) \
|
||||
static_assert((IsUnknown && !(IsCore || IsWidget || IsGui)) \
|
||||
|| (IsCore && !(IsUnknown || IsWidget || IsGui)) \
|
||||
|| (IsWidget && !(IsUnknown || IsCore || IsGui)) \
|
||||
|| (IsGui && !(IsUnknown || IsCore || IsWidget))); \
|
||||
|
@ -220,15 +220,15 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<Func2> SlotType;
|
||||
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
|
||||
//compilation error if the arguments does not match.
|
||||
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
"The slot requires more arguments than the signal provides.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
|
||||
const int *types = nullptr;
|
||||
@ -260,15 +260,15 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<Func2> SlotType;
|
||||
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
|
||||
//compilation error if the arguments does not match.
|
||||
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
"The slot requires more arguments than the signal provides.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
|
||||
const int *types = nullptr;
|
||||
@ -299,15 +299,15 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<Func2 , typename SignalType::Arguments>::Value;
|
||||
|
||||
Q_STATIC_ASSERT_X((FunctorArgumentCount >= 0),
|
||||
static_assert((FunctorArgumentCount >= 0),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
const int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
|
||||
typedef typename QtPrivate::FunctorReturnType<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value>::Value SlotReturnType;
|
||||
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value),
|
||||
static_assert((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
|
||||
const int *types = nullptr;
|
||||
@ -344,11 +344,11 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<Func2> SlotType;
|
||||
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
|
||||
//compilation error if the arguments does not match.
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
|
||||
return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot),
|
||||
@ -461,7 +461,7 @@ template <class T>
|
||||
inline T qobject_cast(QObject *object)
|
||||
{
|
||||
typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
|
||||
"qobject_cast requires the type to have a Q_OBJECT macro");
|
||||
return static_cast<T>(ObjType::staticMetaObject.cast(object));
|
||||
}
|
||||
@ -470,7 +470,7 @@ template <class T>
|
||||
inline T qobject_cast(const QObject *object)
|
||||
{
|
||||
typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
|
||||
"qobject_cast requires the type to have a Q_OBJECT macro");
|
||||
return static_cast<T>(ObjType::staticMetaObject.cast(object));
|
||||
}
|
||||
|
@ -457,15 +457,15 @@ inline QMetaObject::Connection QObjectPrivate::connect(const typename QtPrivate:
|
||||
{
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<Func2> SlotType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
|
||||
//compilation error if the arguments does not match.
|
||||
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
"The slot requires more arguments than the signal provides.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
|
||||
const int *types = nullptr;
|
||||
@ -485,10 +485,10 @@ bool QObjectPrivate::disconnect(const typename QtPrivate::FunctionPointer< Func1
|
||||
{
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<Func2> SlotType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
//compilation error if the arguments does not match.
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
return QObject::disconnectImpl(sender, reinterpret_cast<void **>(&signal),
|
||||
receiverPrivate->q_ptr, reinterpret_cast<void **>(&slot),
|
||||
|
@ -287,7 +287,7 @@ namespace QtPrivate {
|
||||
/*
|
||||
Logic that check if the arguments of the slot matches the argument of the signal.
|
||||
To be used like this:
|
||||
Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
|
||||
static_assert(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
|
||||
*/
|
||||
template<typename A1, typename A2> struct AreArgumentsCompatible {
|
||||
static int test(const typename RemoveRef<A2>::Type&);
|
||||
@ -296,7 +296,7 @@ namespace QtPrivate {
|
||||
enum { value = sizeof(test(dummy())) == sizeof(int) };
|
||||
#ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
|
||||
using AreArgumentsConvertibleWithoutNarrowing = AreArgumentsConvertibleWithoutNarrowingBase<std::decay_t<A1>, std::decay_t<A2>>;
|
||||
Q_STATIC_ASSERT_X(AreArgumentsConvertibleWithoutNarrowing::value, "Signal and slot arguments are not compatible (narrowing)");
|
||||
static_assert(AreArgumentsConvertibleWithoutNarrowing::value, "Signal and slot arguments are not compatible (narrowing)");
|
||||
#endif
|
||||
};
|
||||
template<typename A1, typename A2> struct AreArgumentsCompatible<A1, A2&> { enum { value = false }; };
|
||||
|
@ -52,7 +52,7 @@ class QVariant;
|
||||
template <class T>
|
||||
class QPointer
|
||||
{
|
||||
Q_STATIC_ASSERT_X(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
|
||||
static_assert(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
|
||||
|
||||
using QObjectType =
|
||||
typename std::conditional<std::is_const<T>::value, const QObject, QObject>::type;
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func1> SlotType;
|
||||
|
||||
//compilation error if the slot has arguments.
|
||||
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) == 0,
|
||||
static_assert(int(SlotType::ArgumentCount) == 0,
|
||||
"The slot must not have any arguments.");
|
||||
|
||||
singleShotImpl(interval, timerType, receiver,
|
||||
@ -152,7 +152,7 @@ public:
|
||||
{
|
||||
//compilation error if the slot has arguments.
|
||||
typedef QtPrivate::FunctionPointer<Func1> SlotType;
|
||||
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments.");
|
||||
static_assert(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments.");
|
||||
|
||||
singleShotImpl(interval, timerType, context,
|
||||
new QtPrivate::QFunctorSlotObject<Func1, 0,
|
||||
|
@ -1519,7 +1519,7 @@ const QVariant::Handler qt_custom_variant_handler = {
|
||||
|
||||
static HandlersManager handlerManager;
|
||||
|
||||
Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0");
|
||||
static_assert(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0");
|
||||
const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount]
|
||||
= { &qt_kernel_variant_handler, &qt_dummy_variant_handler,
|
||||
&qt_dummy_variant_handler, &qt_custom_variant_handler };
|
||||
|
@ -68,9 +68,9 @@ struct QVariantIntegrator
|
||||
&& ((QTypeInfoQuery<T>::isRelocatable) || std::is_enum<T>::value);
|
||||
typedef std::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t;
|
||||
};
|
||||
Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace);
|
||||
Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace);
|
||||
Q_STATIC_ASSERT(QVariantIntegrator<qulonglong>::CanUseInternalSpace);
|
||||
static_assert(QVariantIntegrator<double>::CanUseInternalSpace);
|
||||
static_assert(QVariantIntegrator<long int>::CanUseInternalSpace);
|
||||
static_assert(QVariantIntegrator<qulonglong>::CanUseInternalSpace);
|
||||
|
||||
#ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack
|
||||
|
||||
@ -267,7 +267,7 @@ class QVariantIsNull
|
||||
class HasIsNullMethod {
|
||||
struct Yes { char unused[1]; };
|
||||
struct No { char unused[2]; };
|
||||
Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No));
|
||||
static_assert(sizeof(Yes) != sizeof(No));
|
||||
|
||||
template<class C> static decltype(static_cast<const C*>(nullptr)->isNull(), Yes()) test(int);
|
||||
template<class C> static No test(...);
|
||||
@ -276,19 +276,19 @@ class QVariantIsNull
|
||||
};
|
||||
|
||||
// TODO This part should go to autotests during HasIsNullMethod generalization.
|
||||
Q_STATIC_ASSERT(!HasIsNullMethod<bool>::Value);
|
||||
static_assert(!HasIsNullMethod<bool>::Value);
|
||||
struct SelfTest1 { bool isNull() const; };
|
||||
Q_STATIC_ASSERT(HasIsNullMethod<SelfTest1>::Value);
|
||||
static_assert(HasIsNullMethod<SelfTest1>::Value);
|
||||
struct SelfTest2 {};
|
||||
Q_STATIC_ASSERT(!HasIsNullMethod<SelfTest2>::Value);
|
||||
static_assert(!HasIsNullMethod<SelfTest2>::Value);
|
||||
struct SelfTest3 : public SelfTest1 {};
|
||||
Q_STATIC_ASSERT(HasIsNullMethod<SelfTest3>::Value);
|
||||
static_assert(HasIsNullMethod<SelfTest3>::Value);
|
||||
struct SelfTestFinal1 final { bool isNull() const; };
|
||||
Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal1>::Value);
|
||||
static_assert(HasIsNullMethod<SelfTestFinal1>::Value);
|
||||
struct SelfTestFinal2 final {};
|
||||
Q_STATIC_ASSERT(!HasIsNullMethod<SelfTestFinal2>::Value);
|
||||
static_assert(!HasIsNullMethod<SelfTestFinal2>::Value);
|
||||
struct SelfTestFinal3 final : public SelfTest1 {};
|
||||
Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal3>::Value);
|
||||
static_assert(HasIsNullMethod<SelfTestFinal3>::Value);
|
||||
|
||||
template<typename T, bool HasIsNull = HasIsNullMethod<T>::Value>
|
||||
struct CallFilteredIsNull
|
||||
|
@ -630,10 +630,10 @@ static QString internalMimeFileName()
|
||||
QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum)
|
||||
: QMimeProviderBase(db, internalMimeFileName())
|
||||
{
|
||||
Q_STATIC_ASSERT_X(sizeof(mimetype_database), "Bundled MIME database is empty");
|
||||
Q_STATIC_ASSERT_X(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize,
|
||||
static_assert(sizeof(mimetype_database), "Bundled MIME database is empty");
|
||||
static_assert(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize,
|
||||
"Compressed MIME database is larger than the original size");
|
||||
Q_STATIC_ASSERT_X(MimeTypeDatabaseOriginalSize <= 16*1024*1024,
|
||||
static_assert(MimeTypeDatabaseOriginalSize <= 16*1024*1024,
|
||||
"Bundled MIME database is too big");
|
||||
const char *data = reinterpret_cast<const char *>(mimetype_database);
|
||||
qsizetype size = MimeTypeDatabaseOriginalSize;
|
||||
|
@ -207,10 +207,10 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin);
|
||||
#define Q_EXPORT_PLUGIN(PLUGIN) \
|
||||
Q_EXPORT_PLUGIN2(PLUGIN, PLUGIN)
|
||||
# define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS) \
|
||||
Q_STATIC_ASSERT_X(false, "Old plugin system used")
|
||||
static_assert(false, "Old plugin system used")
|
||||
|
||||
# define Q_EXPORT_STATIC_PLUGIN2(PLUGIN, PLUGINCLASS) \
|
||||
Q_STATIC_ASSERT_X(false, "Old plugin system used")
|
||||
static_assert(false, "Old plugin system used")
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -60,7 +60,7 @@ static Q_CONSTEXPR Base emptyObject = {
|
||||
|
||||
void MutableData::compact()
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(Value) == sizeof(offset));
|
||||
static_assert(sizeof(Value) == sizeof(offset));
|
||||
|
||||
Base *base = header->root();
|
||||
int reserve = 0;
|
||||
|
@ -271,50 +271,50 @@ QString QCborError::toString() const
|
||||
{
|
||||
switch (c) {
|
||||
case NoError:
|
||||
Q_STATIC_ASSERT(int(NoError) == int(CborNoError));
|
||||
static_assert(int(NoError) == int(CborNoError));
|
||||
return QString();
|
||||
|
||||
case UnknownError:
|
||||
Q_STATIC_ASSERT(int(UnknownError) == int(CborUnknownError));
|
||||
static_assert(int(UnknownError) == int(CborUnknownError));
|
||||
return QStringLiteral("Unknown error");
|
||||
case AdvancePastEnd:
|
||||
Q_STATIC_ASSERT(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF));
|
||||
static_assert(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF));
|
||||
return QStringLiteral("Read past end of buffer (more bytes needed)");
|
||||
case InputOutputError:
|
||||
Q_STATIC_ASSERT(int(InputOutputError) == int(CborErrorIO));
|
||||
static_assert(int(InputOutputError) == int(CborErrorIO));
|
||||
return QStringLiteral("Input/Output error");
|
||||
case GarbageAtEnd:
|
||||
Q_STATIC_ASSERT(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd));
|
||||
static_assert(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd));
|
||||
return QStringLiteral("Data found after the end of the stream");
|
||||
case EndOfFile:
|
||||
Q_STATIC_ASSERT(int(EndOfFile) == int(CborErrorUnexpectedEOF));
|
||||
static_assert(int(EndOfFile) == int(CborErrorUnexpectedEOF));
|
||||
return QStringLiteral("Unexpected end of input data (more bytes needed)");
|
||||
case UnexpectedBreak:
|
||||
Q_STATIC_ASSERT(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak));
|
||||
static_assert(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak));
|
||||
return QStringLiteral("Invalid CBOR stream: unexpected 'break' byte");
|
||||
case UnknownType:
|
||||
Q_STATIC_ASSERT(int(UnknownType) == int(CborErrorUnknownType));
|
||||
static_assert(int(UnknownType) == int(CborErrorUnknownType));
|
||||
return QStringLiteral("Invalid CBOR stream: unknown type");
|
||||
case IllegalType:
|
||||
Q_STATIC_ASSERT(int(IllegalType) == int(CborErrorIllegalType));
|
||||
static_assert(int(IllegalType) == int(CborErrorIllegalType));
|
||||
return QStringLiteral("Invalid CBOR stream: illegal type found");
|
||||
case IllegalNumber:
|
||||
Q_STATIC_ASSERT(int(IllegalNumber) == int(CborErrorIllegalNumber));
|
||||
static_assert(int(IllegalNumber) == int(CborErrorIllegalNumber));
|
||||
return QStringLiteral("Invalid CBOR stream: illegal number encoding (future extension)");
|
||||
case IllegalSimpleType:
|
||||
Q_STATIC_ASSERT(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType));
|
||||
static_assert(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType));
|
||||
return QStringLiteral("Invalid CBOR stream: illegal simple type");
|
||||
case InvalidUtf8String:
|
||||
Q_STATIC_ASSERT(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString));
|
||||
static_assert(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString));
|
||||
return QStringLiteral("Invalid CBOR stream: invalid UTF-8 text string");
|
||||
case DataTooLarge:
|
||||
Q_STATIC_ASSERT(int(DataTooLarge) == int(CborErrorDataTooLarge));
|
||||
static_assert(int(DataTooLarge) == int(CborErrorDataTooLarge));
|
||||
return QStringLiteral("Internal limitation: data set too large");
|
||||
case NestingTooDeep:
|
||||
Q_STATIC_ASSERT(int(NestingTooDeep) == int(CborErrorNestingTooDeep));
|
||||
static_assert(int(NestingTooDeep) == int(CborErrorNestingTooDeep));
|
||||
return QStringLiteral("Internal limitation: data nesting too deep");
|
||||
case UnsupportedType:
|
||||
Q_STATIC_ASSERT(int(UnsupportedType) == int(CborErrorUnsupportedType));
|
||||
static_assert(int(UnsupportedType) == int(CborErrorUnsupportedType));
|
||||
return QStringLiteral("Internal limitation: unsupported type");
|
||||
}
|
||||
|
||||
|
@ -80,17 +80,17 @@ static CborError Q_DECL_UNUSED cbor_value_get_half_float_as_float(const CborValu
|
||||
}
|
||||
|
||||
// confirm our constants match TinyCBOR's
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::UnsignedInteger) == CborIntegerType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::ByteString) == CborByteStringType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::TextString) == CborTextStringType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Array) == CborArrayType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Map) == CborMapType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Tag) == CborTagType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::SimpleType) == CborSimpleType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::HalfFloat) == CborHalfFloatType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Float) == CborFloatType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Double) == CborDoubleType);
|
||||
Q_STATIC_ASSERT(int(QCborStreamReader::Invalid) == CborInvalidType);
|
||||
static_assert(int(QCborStreamReader::UnsignedInteger) == CborIntegerType);
|
||||
static_assert(int(QCborStreamReader::ByteString) == CborByteStringType);
|
||||
static_assert(int(QCborStreamReader::TextString) == CborTextStringType);
|
||||
static_assert(int(QCborStreamReader::Array) == CborArrayType);
|
||||
static_assert(int(QCborStreamReader::Map) == CborMapType);
|
||||
static_assert(int(QCborStreamReader::Tag) == CborTagType);
|
||||
static_assert(int(QCborStreamReader::SimpleType) == CborSimpleType);
|
||||
static_assert(int(QCborStreamReader::HalfFloat) == CborHalfFloatType);
|
||||
static_assert(int(QCborStreamReader::Float) == CborFloatType);
|
||||
static_assert(int(QCborStreamReader::Double) == CborDoubleType);
|
||||
static_assert(int(QCborStreamReader::Invalid) == CborInvalidType);
|
||||
|
||||
/*!
|
||||
\class QCborStreamReader
|
||||
@ -708,8 +708,8 @@ static CborError qt_cbor_decoder_transfer_string(void *token, const void **userp
|
||||
{
|
||||
auto self = static_cast<QCborStreamReaderPrivate *>(token);
|
||||
Q_ASSERT(offset <= size_t(self->buffer.size()));
|
||||
Q_STATIC_ASSERT(sizeof(size_t) >= sizeof(QByteArray::size_type));
|
||||
Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype));
|
||||
static_assert(sizeof(size_t) >= sizeof(QByteArray::size_type));
|
||||
static_assert(sizeof(size_t) == sizeof(qsizetype));
|
||||
|
||||
// check that we will have enough data from the QIODevice before we advance
|
||||
// (otherwise, we'd lose the length information)
|
||||
|
@ -243,7 +243,7 @@ public:
|
||||
|
||||
void createContainer(CborError (*f)(CborEncoder *, CborEncoder *, size_t), quint64 len = IndefiniteLength)
|
||||
{
|
||||
Q_STATIC_ASSERT(size_t(IndefiniteLength) == CborIndefiniteLength);
|
||||
static_assert(size_t(IndefiniteLength) == CborIndefiniteLength);
|
||||
if (sizeof(len) != sizeof(size_t) && len != IndefiniteLength) {
|
||||
if (Q_UNLIKELY(len >= CborIndefiniteLength)) {
|
||||
// TinyCBOR can't do this in 32-bit mode
|
||||
|
@ -320,7 +320,7 @@ private:
|
||||
|
||||
double fp_helper() const
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(double) == sizeof(n));
|
||||
static_assert(sizeof(double) == sizeof(n));
|
||||
double d;
|
||||
memcpy(&d, &n, sizeof(d));
|
||||
return d;
|
||||
|
@ -95,7 +95,7 @@ struct Element
|
||||
}
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Element::ValueFlags)
|
||||
Q_STATIC_ASSERT(sizeof(Element) == 16);
|
||||
static_assert(sizeof(Element) == 16);
|
||||
|
||||
struct ByteData
|
||||
{
|
||||
@ -115,8 +115,8 @@ struct ByteData
|
||||
QStringView asStringView() const{ return QStringView(utf16(), len / 2); }
|
||||
QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); }
|
||||
};
|
||||
Q_STATIC_ASSERT(std::is_trivial<ByteData>::value);
|
||||
Q_STATIC_ASSERT(std::is_standard_layout<ByteData>::value);
|
||||
static_assert(std::is_trivial<ByteData>::value);
|
||||
static_assert(std::is_standard_layout<ByteData>::value);
|
||||
} // namespace QtCbor
|
||||
|
||||
Q_DECLARE_TYPEINFO(QtCbor::Element, Q_PRIMITIVE_TYPE);
|
||||
|
@ -152,8 +152,8 @@ private:
|
||||
QCborValue::Type t;
|
||||
|
||||
// Assert binary compatibility with pre-5.15 QJsonValue
|
||||
Q_STATIC_ASSERT(sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) == sizeof(void *));
|
||||
Q_STATIC_ASSERT(sizeof(QCborValue::Type) == sizeof(QJsonValue::Type));
|
||||
static_assert(sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) == sizeof(void *));
|
||||
static_assert(sizeof(QCborValue::Type) == sizeof(QJsonValue::Type));
|
||||
};
|
||||
|
||||
class Q_CORE_EXPORT QJsonValueRef
|
||||
|
@ -138,7 +138,7 @@ template <uint N>
|
||||
class QStaticByteArrayMatcher : QStaticByteArrayMatcherBase
|
||||
{
|
||||
char m_pattern[N];
|
||||
Q_STATIC_ASSERT_X(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern");
|
||||
static_assert(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern");
|
||||
public:
|
||||
explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept
|
||||
: QStaticByteArrayMatcherBase(patternToMatch, N - 1), m_pattern()
|
||||
|
@ -2154,10 +2154,10 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
||||
// sets lastStable to the position of the last stable code point
|
||||
static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, int from, int *lastStable)
|
||||
{
|
||||
Q_STATIC_ASSERT(QString::NormalizationForm_D == 0);
|
||||
Q_STATIC_ASSERT(QString::NormalizationForm_C == 1);
|
||||
Q_STATIC_ASSERT(QString::NormalizationForm_KD == 2);
|
||||
Q_STATIC_ASSERT(QString::NormalizationForm_KC == 3);
|
||||
static_assert(QString::NormalizationForm_D == 0);
|
||||
static_assert(QString::NormalizationForm_C == 1);
|
||||
static_assert(QString::NormalizationForm_KD == 2);
|
||||
static_assert(QString::NormalizationForm_KC == 3);
|
||||
|
||||
enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
|
||||
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
Q_DECL_CONSTEXPR QChar(char16_t ch) noexcept : ucs(ch) {} // implicit
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(char16_t));
|
||||
static_assert(sizeof(wchar_t) == sizeof(char16_t));
|
||||
#endif
|
||||
#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
|
||||
# if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
|
@ -116,19 +116,19 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) noexcept
|
||||
if (uc3 == 0) {
|
||||
// legacy codes
|
||||
if (uc1 == 'n' && uc2 == 'o') { // no -> nb
|
||||
Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
static_assert(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
return QLocale::Norwegian;
|
||||
}
|
||||
if (uc1 == 't' && uc2 == 'l') { // tl -> fil
|
||||
Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino);
|
||||
static_assert(QLocale::Tagalog == QLocale::Filipino);
|
||||
return QLocale::Tagalog;
|
||||
}
|
||||
if (uc1 == 's' && uc2 == 'h') { // sh -> sr[_Latn]
|
||||
Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian);
|
||||
static_assert(QLocale::SerboCroatian == QLocale::Serbian);
|
||||
return QLocale::SerboCroatian;
|
||||
}
|
||||
if (uc1 == 'm' && uc2 == 'o') { // mo -> ro
|
||||
Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian);
|
||||
static_assert(QLocale::Moldavian == QLocale::Romanian);
|
||||
return QLocale::Moldavian;
|
||||
}
|
||||
// Android uses the following deprecated codes
|
||||
|
@ -498,19 +498,19 @@ Q_DECL_CONSTEXPR inline bool ascii_isspace(uchar c)
|
||||
}
|
||||
|
||||
#if defined(Q_COMPILER_CONSTEXPR)
|
||||
Q_STATIC_ASSERT(ascii_isspace(' '));
|
||||
Q_STATIC_ASSERT(ascii_isspace('\t'));
|
||||
Q_STATIC_ASSERT(ascii_isspace('\n'));
|
||||
Q_STATIC_ASSERT(ascii_isspace('\v'));
|
||||
Q_STATIC_ASSERT(ascii_isspace('\f'));
|
||||
Q_STATIC_ASSERT(ascii_isspace('\r'));
|
||||
Q_STATIC_ASSERT(!ascii_isspace('\0'));
|
||||
Q_STATIC_ASSERT(!ascii_isspace('\a'));
|
||||
Q_STATIC_ASSERT(!ascii_isspace('a'));
|
||||
Q_STATIC_ASSERT(!ascii_isspace('\177'));
|
||||
Q_STATIC_ASSERT(!ascii_isspace(uchar('\200')));
|
||||
Q_STATIC_ASSERT(!ascii_isspace(uchar('\xA0')));
|
||||
Q_STATIC_ASSERT(!ascii_isspace(uchar('\377')));
|
||||
static_assert(ascii_isspace(' '));
|
||||
static_assert(ascii_isspace('\t'));
|
||||
static_assert(ascii_isspace('\n'));
|
||||
static_assert(ascii_isspace('\v'));
|
||||
static_assert(ascii_isspace('\f'));
|
||||
static_assert(ascii_isspace('\r'));
|
||||
static_assert(!ascii_isspace('\0'));
|
||||
static_assert(!ascii_isspace('\a'));
|
||||
static_assert(!ascii_isspace('a'));
|
||||
static_assert(!ascii_isspace('\177'));
|
||||
static_assert(!ascii_isspace(uchar('\200')));
|
||||
static_assert(!ascii_isspace(uchar('\xA0')));
|
||||
static_assert(!ascii_isspace(uchar('\377')));
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -433,7 +433,7 @@ QString qulltoa(qulonglong number, int base, const QStringView zero)
|
||||
// Length of MAX_ULLONG in base 2 is 64; and we may need a surrogate pair
|
||||
// per digit. We do not need a terminator.
|
||||
const unsigned maxlen = 128;
|
||||
Q_STATIC_ASSERT(CHAR_BIT * sizeof(number) <= maxlen);
|
||||
static_assert(CHAR_BIT * sizeof(number) <= maxlen);
|
||||
ushort buff[maxlen];
|
||||
ushort *const end = buff + maxlen, *p = end;
|
||||
|
||||
|
@ -909,7 +909,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
|
||||
return 0;
|
||||
#else
|
||||
#if defined(__mips_dsp)
|
||||
Q_STATIC_ASSERT(sizeof(uint) == sizeof(size_t));
|
||||
static_assert(sizeof(uint) == sizeof(size_t));
|
||||
if (l >= 8) {
|
||||
return qt_ucstrncmp_mips_dsp_asm(reinterpret_cast<const char16_t*>(a),
|
||||
reinterpret_cast<const char16_t*>(b),
|
||||
|
@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QStringIterator
|
||||
{
|
||||
QString::const_iterator i, pos, e;
|
||||
Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
|
||||
static_assert((std::is_same<QString::const_iterator, const QChar *>::value));
|
||||
public:
|
||||
explicit QStringIterator(QStringView string, qsizetype idx = 0)
|
||||
: i(string.begin()),
|
||||
|
@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef char16_t qunicodechar;
|
||||
|
||||
Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2,
|
||||
static_assert(sizeof(qunicodechar) == 2,
|
||||
"qunicodechar must typedef an integral type of size 2");
|
||||
|
||||
#define QT_UNICODE_LITERAL(str) u"" str
|
||||
|
@ -101,7 +101,7 @@ struct Properties {
|
||||
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(char32_t ucs4) noexcept;
|
||||
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(char16_t ucs2) noexcept;
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(Properties) == 20);
|
||||
static_assert(sizeof(Properties) == 20);
|
||||
|
||||
enum GraphemeBreakClass {
|
||||
GraphemeBreak_Any,
|
||||
|
@ -1750,33 +1750,33 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// The following specializations must always be defined
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<long>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned long>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<quintptr>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<qptrdiff>));
|
||||
static_assert(sizeof(QAtomicInteger<unsigned>));
|
||||
static_assert(sizeof(QAtomicInteger<long>));
|
||||
static_assert(sizeof(QAtomicInteger<unsigned long>));
|
||||
static_assert(sizeof(QAtomicInteger<quintptr>));
|
||||
static_assert(sizeof(QAtomicInteger<qptrdiff>));
|
||||
#ifdef Q_COMPILER_UNICODE_STRINGS
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<char32_t>));
|
||||
static_assert(sizeof(QAtomicInteger<char32_t>));
|
||||
#endif
|
||||
|
||||
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<short>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned short>));
|
||||
static_assert(sizeof(QAtomicInteger<short>));
|
||||
static_assert(sizeof(QAtomicInteger<unsigned short>));
|
||||
# if WCHAR_MAX < 0x10000
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
|
||||
static_assert(sizeof(QAtomicInteger<wchar_t>));
|
||||
# endif
|
||||
# ifdef Q_COMPILER_UNICODE_STRINGS
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<char16_t>));
|
||||
static_assert(sizeof(QAtomicInteger<char16_t>));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<qint64>));
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<quint64>));
|
||||
static_assert(sizeof(QAtomicInteger<qint64>));
|
||||
static_assert(sizeof(QAtomicInteger<quint64>));
|
||||
#endif
|
||||
|
||||
#if WCHAR_MAX == INT_MAX
|
||||
Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
|
||||
static_assert(sizeof(QAtomicInteger<wchar_t>));
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -291,9 +291,9 @@ template <int N> struct QAtomicOpsBySize : QGenericAtomicOps<QAtomicOpsBySize<N>
|
||||
private:
|
||||
typedef typename QAtomicWindowsType<N>::Type Type;
|
||||
template <typename T> static inline Type *atomic(T *t)
|
||||
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
|
||||
{ static_assert(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
|
||||
template <typename T> static inline Type value(T t)
|
||||
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); }
|
||||
{ static_assert(sizeof(T) == sizeof(Type)); return Type(t); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -93,8 +93,8 @@ public:
|
||||
typedef T Type;
|
||||
typedef QAtomicOps<T> Ops;
|
||||
// static check that this is a valid integer
|
||||
Q_STATIC_ASSERT_X(QTypeInfo<T>::isIntegral, "template parameter is not an integral type");
|
||||
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
|
||||
static_assert(QTypeInfo<T>::isIntegral, "template parameter is not an integral type");
|
||||
static_assert(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
|
||||
|
||||
typename Ops::Type _q_value;
|
||||
|
||||
|
@ -253,7 +253,7 @@ QThread *QThread::create(Function &&f)
|
||||
inline Qt::HANDLE QThread::currentThreadId() noexcept
|
||||
{
|
||||
Qt::HANDLE tid; // typedef to void*
|
||||
Q_STATIC_ASSERT(sizeof(tid) == sizeof(void*));
|
||||
static_assert(sizeof(tid) == sizeof(void*));
|
||||
// See https://akkadia.org/drepper/tls.pdf for x86 ABI
|
||||
#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) // x86 32-bit always uses GS
|
||||
__asm__("movl %%gs:0, %0" : "=r" (tid) : : );
|
||||
|
@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
|
||||
static_assert(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
|
||||
|
||||
enum { ThreadPriorityResetFlag = 0x80000000 };
|
||||
|
||||
|
@ -108,7 +108,7 @@ void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline)
|
||||
normalizedTimespec(*ts);
|
||||
#else
|
||||
// depends on QDeadlineTimer's internals!!
|
||||
Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
|
||||
static_assert(QDeadlineTimerNanosecondsInT2);
|
||||
ts->tv_sec = deadline._q_data().first;
|
||||
ts->tv_nsec = deadline._q_data().second;
|
||||
#endif
|
||||
|
@ -259,7 +259,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
|
||||
brackets the correct time and at most one DST transition.
|
||||
*/
|
||||
const qint64 sixteenHoursInMSecs(16 * 3600 * 1000);
|
||||
Q_STATIC_ASSERT(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs
|
||||
static_assert(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs
|
||||
&& sixteenHoursInMSecs / 1000 > QTimeZone::MaxUtcOffsetSecs);
|
||||
const qint64 recent = forLocalMSecs - sixteenHoursInMSecs;
|
||||
const qint64 imminent = forLocalMSecs + sixteenHoursInMSecs;
|
||||
|
@ -206,7 +206,7 @@ struct QTypedArrayData
|
||||
Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity,
|
||||
ArrayOptions options = DefaultAllocationFlags)
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
QArrayData *d;
|
||||
void *result = QArrayData::allocate(&d, sizeof(T), alignof(AlignmentDummy), capacity, options);
|
||||
#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned)
|
||||
@ -219,7 +219,7 @@ struct QTypedArrayData
|
||||
reallocateUnaligned(QTypedArrayData *data, T *dataPointer, size_t capacity,
|
||||
ArrayOptions options = DefaultAllocationFlags)
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
QPair<QArrayData *, void *> pair =
|
||||
QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, options);
|
||||
return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second));
|
||||
@ -227,14 +227,14 @@ struct QTypedArrayData
|
||||
|
||||
static void deallocate(QArrayData *data)
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy));
|
||||
}
|
||||
|
||||
static QArrayDataPointerRef<T> fromRawData(const T *data, size_t n,
|
||||
ArrayOptions options = DefaultRawFlags)
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
QArrayDataPointerRef<T> result = {
|
||||
static_cast<QTypedArrayData *>(prepareRawData(options)), const_cast<T *>(data), uint(n)
|
||||
};
|
||||
@ -246,19 +246,19 @@ struct QTypedArrayData
|
||||
|
||||
static QTypedArrayData *sharedNull() noexcept
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
return static_cast<QTypedArrayData *>(QArrayData::sharedNull());
|
||||
}
|
||||
|
||||
static QTypedArrayData *sharedEmpty()
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
return allocate(/* capacity */ 0);
|
||||
}
|
||||
|
||||
static T *sharedNullData()
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
return static_cast<T *>(QArrayData::sharedNullData());
|
||||
}
|
||||
};
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
explicit QTaggedPointer(T *pointer, Tag tag = Tag()) noexcept
|
||||
: d(quintptr(pointer))
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(Type*) == sizeof(QTaggedPointer));
|
||||
static_assert(sizeof(Type*) == sizeof(QTaggedPointer));
|
||||
|
||||
Q_ASSERT_X((quintptr(pointer) & tagMask()) == 0,
|
||||
"QTaggedPointer<T, Tag>", "Pointer is not aligned");
|
||||
|
@ -275,7 +275,7 @@ QVarLengthArray(InputIterator, InputIterator) -> QVarLengthArray<ValueType>;
|
||||
template <class T, qsizetype Prealloc>
|
||||
Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(qsizetype asize)
|
||||
: s(asize) {
|
||||
Q_STATIC_ASSERT_X(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0.");
|
||||
static_assert(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0.");
|
||||
Q_ASSERT_X(s >= 0, "QVarLengthArray::QVarLengthArray()", "Size must be greater than or equal to 0.");
|
||||
if (s > Prealloc) {
|
||||
ptr = reinterpret_cast<T *>(malloc(s * sizeof(T)));
|
||||
|
@ -75,7 +75,7 @@ class QVersionNumber
|
||||
InlineSegmentStartIdx = !InlineSegmentMarker, // 0 for BE, 1 for LE
|
||||
InlineSegmentCount = sizeof(void*) - 1
|
||||
};
|
||||
Q_STATIC_ASSERT(InlineSegmentCount >= 3); // at least major, minor, micro
|
||||
static_assert(InlineSegmentCount >= 3); // at least major, minor, micro
|
||||
|
||||
struct SegmentStorage {
|
||||
// Note: we alias the use of dummy and inline_segments in the use of the
|
||||
@ -454,7 +454,7 @@ inline constexpr bool operator>=(QTypeRevision lhs, QTypeRevision rhs)
|
||||
return lhs == rhs || !(lhs < rhs);
|
||||
}
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(QTypeRevision) == 2);
|
||||
static_assert(sizeof(QTypeRevision) == 2);
|
||||
Q_DECLARE_TYPEINFO(QTypeRevision, Q_MOVABLE_TYPE);
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
@ -78,7 +78,7 @@ Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager)
|
||||
|
||||
QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::BusType type)
|
||||
{
|
||||
Q_STATIC_ASSERT(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1);
|
||||
static_assert(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1);
|
||||
Q_ASSERT(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus);
|
||||
|
||||
if (!qdbus_loadLibDBus())
|
||||
|
@ -56,11 +56,11 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_STATIC_ASSERT(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID);
|
||||
Q_STATIC_ASSERT(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL);
|
||||
Q_STATIC_ASSERT(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN);
|
||||
Q_STATIC_ASSERT(QDBusMessage::ErrorMessage == DBUS_MESSAGE_TYPE_ERROR);
|
||||
Q_STATIC_ASSERT(QDBusMessage::SignalMessage == DBUS_MESSAGE_TYPE_SIGNAL);
|
||||
static_assert(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID);
|
||||
static_assert(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL);
|
||||
static_assert(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN);
|
||||
static_assert(QDBusMessage::ErrorMessage == DBUS_MESSAGE_TYPE_ERROR);
|
||||
static_assert(QDBusMessage::SignalMessage == DBUS_MESSAGE_TYPE_SIGNAL);
|
||||
|
||||
static inline const char *data(const QByteArray &arr)
|
||||
{
|
||||
|
@ -416,7 +416,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
- methods.count(); // ditto
|
||||
|
||||
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
|
||||
Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 9, "QtDBus meta-object generator should generate the same version as moc");
|
||||
static_assert(QMetaObjectPrivate::OutputRevision == 9, "QtDBus meta-object generator should generate the same version as moc");
|
||||
header->revision = QMetaObjectPrivate::OutputRevision;
|
||||
header->className = 0;
|
||||
header->classInfoCount = 0;
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
template<int Index> inline
|
||||
const typename Select<Index>::Type argumentAt() const
|
||||
{
|
||||
Q_STATIC_ASSERT_X(Index >= 0 && Index < Count, "Index out of bounds");
|
||||
static_assert(Index >= 0 && Index < Count, "Index out of bounds");
|
||||
typedef typename Select<Index>::Type ResultType;
|
||||
return qdbus_cast<ResultType>(argumentAt(Index), nullptr);
|
||||
}
|
||||
|
@ -5265,7 +5265,7 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = {
|
||||
/*INTERPRETATION*/ QPixelFormat::UnsignedByte,
|
||||
/*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats);
|
||||
static_assert(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats);
|
||||
|
||||
/*!
|
||||
Returns the QImage::Format as a QPixelFormat
|
||||
|
@ -118,7 +118,7 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
|
||||
{"xpm", "x-xpixmap"},
|
||||
#endif
|
||||
};
|
||||
Q_STATIC_ASSERT(_qt_NumFormats == sizeof _qt_BuiltInFormats / sizeof *_qt_BuiltInFormats);
|
||||
static_assert(_qt_NumFormats == sizeof _qt_BuiltInFormats / sizeof *_qt_BuiltInFormats);
|
||||
|
||||
#ifndef QT_NO_IMAGEFORMATPLUGIN
|
||||
QSharedPointer<QFactoryLoader> pluginLoader();
|
||||
|
@ -851,7 +851,7 @@ QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat form
|
||||
assign(key, format);
|
||||
}
|
||||
|
||||
Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl below");
|
||||
static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl below");
|
||||
/*!
|
||||
Constructs a key sequence with up to 4 keys \a k1, \a k2,
|
||||
\a k3 and \a k4.
|
||||
@ -915,7 +915,7 @@ void QKeySequence::setKey(int key, int index)
|
||||
d->key[index] = key;
|
||||
}
|
||||
|
||||
Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs below");
|
||||
static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Change docs below");
|
||||
/*!
|
||||
Returns the number of keys in the key sequence.
|
||||
The maximum is 4.
|
||||
@ -1609,7 +1609,7 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm
|
||||
*/
|
||||
QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
|
||||
{
|
||||
Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");
|
||||
static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");
|
||||
const bool extended = s.version() >= 5 && keysequence.count() > 1;
|
||||
s << quint32(extended ? 4 : 1) << quint32(keysequence.d->key[0]);
|
||||
if (extended) {
|
||||
|
@ -61,7 +61,7 @@ static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGro
|
||||
return colorRole + colorRoleOffset(colorGroup);
|
||||
}
|
||||
|
||||
Q_STATIC_ASSERT_X(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1),
|
||||
static_assert(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1),
|
||||
QPalette::ColorRole(QPalette::NColorRoles - 1))
|
||||
< sizeof(QPalette::ResolveMask) * CHAR_BIT,
|
||||
"The resolve mask type is not wide enough to fit the entire bit mask.");
|
||||
|
@ -521,7 +521,7 @@ QT_BEGIN_NAMESPACE
|
||||
\internal
|
||||
*/
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(QPixelFormat) == sizeof(quint64));
|
||||
static_assert(sizeof(QPixelFormat) == sizeof(quint64));
|
||||
|
||||
|
||||
namespace QtPrivate {
|
||||
|
@ -92,8 +92,8 @@ class QPixelFormat
|
||||
TotalFieldWidthByOffsets = UnusedField + UnusedFieldWidth
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == uint(TotalFieldWidthByOffsets));
|
||||
Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == 8 * sizeof(quint64));
|
||||
static_assert(uint(TotalFieldWidthByWidths) == uint(TotalFieldWidthByOffsets));
|
||||
static_assert(uint(TotalFieldWidthByWidths) == 8 * sizeof(quint64));
|
||||
|
||||
Q_DECL_CONSTEXPR inline uchar get(Field offset, FieldWidth width) const noexcept
|
||||
{ return uchar((data >> uint(offset)) & ((Q_UINT64_C(1) << uint(width)) - Q_UINT64_C(1))); }
|
||||
@ -228,7 +228,7 @@ private:
|
||||
friend Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline bool operator!=(QPixelFormat fmt1, QPixelFormat fmt2)
|
||||
{ return !(fmt1 == fmt2); }
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(QPixelFormat) == sizeof(quint64));
|
||||
static_assert(sizeof(QPixelFormat) == sizeof(quint64));
|
||||
Q_DECLARE_TYPEINFO(QPixelFormat, Q_PRIMITIVE_TYPE);
|
||||
|
||||
|
||||
|
@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_VECTOR2D
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2D>::value, "QVector2D is supposed to be standard layout");
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector2D) == sizeof(float) * 2, "QVector2D is not supposed to have padding at the end");
|
||||
static_assert(std::is_standard_layout<QVector2D>::value, "QVector2D is supposed to be standard layout");
|
||||
static_assert(sizeof(QVector2D) == sizeof(float) * 2, "QVector2D is not supposed to have padding at the end");
|
||||
|
||||
// QVector2D used to be defined as class QVector2D { float x, y; };,
|
||||
// now instead it is defined as classs QVector2D { float v[2]; };.
|
||||
@ -69,15 +69,15 @@ struct QVector2DNew
|
||||
float v[2];
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2DOld>::value, "Binary compatibility break in QVector2D");
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2DNew>::value, "Binary compatibility break in QVector2D");
|
||||
static_assert(std::is_standard_layout<QVector2DOld>::value, "Binary compatibility break in QVector2D");
|
||||
static_assert(std::is_standard_layout<QVector2DNew>::value, "Binary compatibility break in QVector2D");
|
||||
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector2DOld) == sizeof(QVector2DNew), "Binary compatibility break in QVector2D");
|
||||
static_assert(sizeof(QVector2DOld) == sizeof(QVector2DNew), "Binary compatibility break in QVector2D");
|
||||
|
||||
// requires a constexpr offsetof
|
||||
#if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910)
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector2DOld, x) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 0, "Binary compatibility break in QVector2D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector2DOld, y) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 1, "Binary compatibility break in QVector2D");
|
||||
static_assert(offsetof(QVector2DOld, x) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 0, "Binary compatibility break in QVector2D");
|
||||
static_assert(offsetof(QVector2DOld, y) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 1, "Binary compatibility break in QVector2D");
|
||||
#endif
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_VECTOR3D
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3D>::value, "QVector3D is supposed to be standard layout");
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector3D) == sizeof(float) * 3, "QVector3D is not supposed to have padding at the end");
|
||||
static_assert(std::is_standard_layout<QVector3D>::value, "QVector3D is supposed to be standard layout");
|
||||
static_assert(sizeof(QVector3D) == sizeof(float) * 3, "QVector3D is not supposed to have padding at the end");
|
||||
|
||||
// QVector3D used to be defined as class QVector3D { float x, y, z; };,
|
||||
// now instead it is defined as classs QVector3D { float v[3]; };.
|
||||
@ -71,16 +71,16 @@ struct QVector3DNew
|
||||
float v[3];
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3DOld>::value, "Binary compatibility break in QVector3D");
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3DNew>::value, "Binary compatibility break in QVector3D");
|
||||
static_assert(std::is_standard_layout<QVector3DOld>::value, "Binary compatibility break in QVector3D");
|
||||
static_assert(std::is_standard_layout<QVector3DNew>::value, "Binary compatibility break in QVector3D");
|
||||
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector3DOld) == sizeof(QVector3DNew), "Binary compatibility break in QVector3D");
|
||||
static_assert(sizeof(QVector3DOld) == sizeof(QVector3DNew), "Binary compatibility break in QVector3D");
|
||||
|
||||
// requires a constexpr offsetof
|
||||
#if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910)
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector3DOld, x) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 0, "Binary compatibility break in QVector3D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector3DOld, y) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 1, "Binary compatibility break in QVector3D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector3DOld, z) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 2, "Binary compatibility break in QVector3D");
|
||||
static_assert(offsetof(QVector3DOld, x) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 0, "Binary compatibility break in QVector3D");
|
||||
static_assert(offsetof(QVector3DOld, y) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 1, "Binary compatibility break in QVector3D");
|
||||
static_assert(offsetof(QVector3DOld, z) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 2, "Binary compatibility break in QVector3D");
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_VECTOR4D
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4D>::value, "QVector4D is supposed to be standard layout");
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector4D) == sizeof(float) * 4, "QVector4D is not supposed to have padding at the end");
|
||||
static_assert(std::is_standard_layout<QVector4D>::value, "QVector4D is supposed to be standard layout");
|
||||
static_assert(sizeof(QVector4D) == sizeof(float) * 4, "QVector4D is not supposed to have padding at the end");
|
||||
|
||||
// QVector4D used to be defined as class QVector4D { float x, y, z, w; };,
|
||||
// now instead it is defined as classs QVector4D { float v[4]; };.
|
||||
@ -69,17 +69,17 @@ struct QVector4DNew
|
||||
float v[4];
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4DOld>::value, "Binary compatibility break in QVector4D");
|
||||
Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4DNew>::value, "Binary compatibility break in QVector4D");
|
||||
static_assert(std::is_standard_layout<QVector4DOld>::value, "Binary compatibility break in QVector4D");
|
||||
static_assert(std::is_standard_layout<QVector4DNew>::value, "Binary compatibility break in QVector4D");
|
||||
|
||||
Q_STATIC_ASSERT_X(sizeof(QVector4DOld) == sizeof(QVector4DNew), "Binary compatibility break in QVector4D");
|
||||
static_assert(sizeof(QVector4DOld) == sizeof(QVector4DNew), "Binary compatibility break in QVector4D");
|
||||
|
||||
// requires a constexpr offsetof
|
||||
#if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910)
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector4DOld, x) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 0, "Binary compatibility break in QVector4D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector4DOld, y) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 1, "Binary compatibility break in QVector4D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector4DOld, z) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 2, "Binary compatibility break in QVector4D");
|
||||
Q_STATIC_ASSERT_X(offsetof(QVector4DOld, w) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 3, "Binary compatibility break in QVector4D");
|
||||
static_assert(offsetof(QVector4DOld, x) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 0, "Binary compatibility break in QVector4D");
|
||||
static_assert(offsetof(QVector4DOld, y) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 1, "Binary compatibility break in QVector4D");
|
||||
static_assert(offsetof(QVector4DOld, z) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 2, "Binary compatibility break in QVector4D");
|
||||
static_assert(offsetof(QVector4DOld, w) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 3, "Binary compatibility break in QVector4D");
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -487,7 +487,7 @@ static const QRgba64 *QT_FASTCALL fetchUntransformedRGBA64PM(QRgba64 *, const Op
|
||||
template<TextureBlendType blendType>
|
||||
inline void fetchTransformed_pixelBounds(int max, int l1, int l2, int &v)
|
||||
{
|
||||
Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
if (blendType == BlendTransformedTiled) {
|
||||
if (v < 0 || v >= max) {
|
||||
v %= max;
|
||||
@ -519,7 +519,7 @@ template<TextureBlendType blendType, QPixelLayout::BPP bpp, typename T>
|
||||
static void QT_FASTCALL fetchTransformed_fetcher(T *buffer, const QSpanData *data,
|
||||
int y, int x, int length)
|
||||
{
|
||||
Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
const QTextureData &image = data->texture;
|
||||
|
||||
const qreal cx = x + qreal(0.5);
|
||||
@ -683,7 +683,7 @@ template<TextureBlendType blendType, QPixelLayout::BPP bpp>
|
||||
static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data,
|
||||
int y, int x, int length)
|
||||
{
|
||||
Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled);
|
||||
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
|
||||
fetchTransformed_fetcher<blendType, bpp, uint>(buffer, data, y, x, length);
|
||||
layout->convertToARGB32PM(buffer, length, data->texture.colorTable);
|
||||
|
@ -385,7 +385,7 @@ static const StandardPageSize qt_pageSizes[] = {
|
||||
};
|
||||
|
||||
static const int pageSizesCount = int(sizeof(qt_pageSizes) / sizeof(qt_pageSizes[0]));
|
||||
Q_STATIC_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
|
||||
static_assert(pageSizesCount == QPageSize::LastPageSize + 1);
|
||||
|
||||
// Return key name for PageSize
|
||||
static QString qt_keyForPageSizeId(QPageSize::PageSizeId id)
|
||||
|
@ -512,7 +512,7 @@ static void QT_FASTCALL rbSwap(uchar *dst, const uchar *src, int count)
|
||||
Q_CONSTEXPR uchar bWidth = blueWidth<Format>();
|
||||
Q_CONSTEXPR uchar bShift = blueShift<Format>();
|
||||
#ifdef Q_COMPILER_CONSTEXPR
|
||||
Q_STATIC_ASSERT(rWidth == bWidth);
|
||||
static_assert(rWidth == bWidth);
|
||||
#endif
|
||||
Q_CONSTEXPR uint redBlueMask = (1 << rWidth) - 1;
|
||||
Q_CONSTEXPR uint alphaGreenMask = (((1 << aWidth) - 1) << aShift)
|
||||
@ -1426,7 +1426,7 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
|
||||
pixelLayoutRGB<QImage::Format_BGR888>(),
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(qPixelLayouts) / sizeof(*qPixelLayouts) == QImage::NImageFormats);
|
||||
static_assert(sizeof(qPixelLayouts) / sizeof(*qPixelLayouts) == QImage::NImageFormats);
|
||||
|
||||
static void QT_FASTCALL convertFromRgb64(uint *dest, const QRgba64 *src, int length)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ static const int scriptForWritingSystem[] = {
|
||||
QChar::Script_Nko // Nko
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);
|
||||
static_assert(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);
|
||||
|
||||
Q_GUI_EXPORT int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
|
||||
{
|
||||
@ -1328,7 +1328,7 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const
|
||||
QT_PREPEND_NAMESPACE(load)();
|
||||
|
||||
quint64 writingSystemsFound = 0;
|
||||
Q_STATIC_ASSERT(WritingSystemsCount < 64);
|
||||
static_assert(WritingSystemsCount < 64);
|
||||
|
||||
for (int i = 0; i < d->count; ++i) {
|
||||
QtFontFamily *family = d->families[i];
|
||||
|
@ -239,7 +239,7 @@ static const hb_script_t _qtscript_to_hbscript[] = {
|
||||
hb_script_t(HB_TAG('K', 'h', 'i', 't')), // Script_KhitanSmallScript
|
||||
hb_script_t(HB_TAG('Y', 'e', 'z', 'i')), // Script_Yezidi
|
||||
};
|
||||
Q_STATIC_ASSERT(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0]));
|
||||
static_assert(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0]));
|
||||
|
||||
hb_script_t hb_qt_script_to_script(QChar::Script script)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ struct QGlyphAttributes {
|
||||
uchar justification : 4;
|
||||
uchar reserved : 2;
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(QGlyphAttributes) == 1);
|
||||
static_assert(sizeof(QGlyphAttributes) == 1);
|
||||
Q_DECLARE_TYPEINFO(QGlyphAttributes, Q_PRIMITIVE_TYPE);
|
||||
|
||||
struct QGlyphLayout
|
||||
|
@ -319,7 +319,7 @@ static const struct QTextHtmlEntity { const char name[9]; char16_t code; } entit
|
||||
{ "zwj", 0x200d },
|
||||
{ "zwnj", 0x200c }
|
||||
};
|
||||
Q_STATIC_ASSERT(MAX_ENTITY == sizeof entities / sizeof *entities);
|
||||
static_assert(MAX_ENTITY == sizeof entities / sizeof *entities);
|
||||
|
||||
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
|
||||
bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2)
|
||||
|
@ -60,21 +60,21 @@ static const QChar Space = QLatin1Char(' ');
|
||||
// TODO maybe eliminate the margins after all views recognize BlockQuoteLevel, CSS can format it, etc.
|
||||
static const int BlockQuoteIndent = 40; // pixels, same as in QTextHtmlParserNode::initializeProperties
|
||||
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureCollapseWhitespace) == MD_FLAG_COLLAPSEWHITESPACE);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveATXHeaders) == MD_FLAG_PERMISSIVEATXHEADERS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveURLAutoLinks) == MD_FLAG_PERMISSIVEURLAUTOLINKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveMailAutoLinks) == MD_FLAG_PERMISSIVEEMAILAUTOLINKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoIndentedCodeBlocks) == MD_FLAG_NOINDENTEDCODEBLOCKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTMLBlocks) == MD_FLAG_NOHTMLBLOCKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTMLSpans) == MD_FLAG_NOHTMLSPANS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureTables) == MD_FLAG_TABLES);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureStrikeThrough) == MD_FLAG_STRIKETHROUGH);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveWWWAutoLinks) == MD_FLAG_PERMISSIVEWWWAUTOLINKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveAutoLinks) == MD_FLAG_PERMISSIVEAUTOLINKS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureTasklists) == MD_FLAG_TASKLISTS);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTML) == MD_FLAG_NOHTML);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::DialectCommonMark) == MD_DIALECT_COMMONMARK);
|
||||
Q_STATIC_ASSERT(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureCollapseWhitespace) == MD_FLAG_COLLAPSEWHITESPACE);
|
||||
static_assert(int(QTextMarkdownImporter::FeaturePermissiveATXHeaders) == MD_FLAG_PERMISSIVEATXHEADERS);
|
||||
static_assert(int(QTextMarkdownImporter::FeaturePermissiveURLAutoLinks) == MD_FLAG_PERMISSIVEURLAUTOLINKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeaturePermissiveMailAutoLinks) == MD_FLAG_PERMISSIVEEMAILAUTOLINKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureNoIndentedCodeBlocks) == MD_FLAG_NOINDENTEDCODEBLOCKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureNoHTMLBlocks) == MD_FLAG_NOHTMLBLOCKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureNoHTMLSpans) == MD_FLAG_NOHTMLSPANS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureTables) == MD_FLAG_TABLES);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureStrikeThrough) == MD_FLAG_STRIKETHROUGH);
|
||||
static_assert(int(QTextMarkdownImporter::FeaturePermissiveWWWAutoLinks) == MD_FLAG_PERMISSIVEWWWAUTOLINKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeaturePermissiveAutoLinks) == MD_FLAG_PERMISSIVEAUTOLINKS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureTasklists) == MD_FLAG_TASKLISTS);
|
||||
static_assert(int(QTextMarkdownImporter::FeatureNoHTML) == MD_FLAG_NOHTML);
|
||||
static_assert(int(QTextMarkdownImporter::DialectCommonMark) == MD_DIALECT_COMMONMARK);
|
||||
static_assert(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB);
|
||||
|
||||
// --------------------------------------------------------
|
||||
// MD4C callback function wrappers
|
||||
|
@ -279,7 +279,7 @@ static const char specialLanguages[][6] = {
|
||||
"", // KhitanSmallScript
|
||||
"" // Yezidi
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof specialLanguages / sizeof *specialLanguages == QChar::ScriptCount);
|
||||
static_assert(sizeof specialLanguages / sizeof *specialLanguages == QChar::ScriptCount);
|
||||
|
||||
// this could become a list of all languages used for each writing
|
||||
// system, instead of using the single most common language.
|
||||
@ -319,7 +319,7 @@ static const char languageForWritingSystem[][6] = {
|
||||
"non", // Runic
|
||||
"man" // N'Ko
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof languageForWritingSystem / sizeof *languageForWritingSystem == QFontDatabase::WritingSystemsCount);
|
||||
static_assert(sizeof languageForWritingSystem / sizeof *languageForWritingSystem == QFontDatabase::WritingSystemsCount);
|
||||
|
||||
#if FC_VERSION >= 20297
|
||||
// Newer FontConfig let's us sort out fonts that report certain scripts support,
|
||||
@ -361,7 +361,7 @@ static const char capabilityForWritingSystem[][5] = {
|
||||
"", // Runic
|
||||
"nko " // N'Ko
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount);
|
||||
static_assert(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount);
|
||||
#endif
|
||||
|
||||
static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
|
||||
|
@ -105,8 +105,8 @@ template <typename T>
|
||||
class QHVContainer {
|
||||
T m_data[2];
|
||||
|
||||
Q_STATIC_ASSERT(Qt::Horizontal == 0x1);
|
||||
Q_STATIC_ASSERT(Qt::Vertical == 0x2);
|
||||
static_assert(Qt::Horizontal == 0x1);
|
||||
static_assert(Qt::Vertical == 0x2);
|
||||
static constexpr int map(Qt::Orientation o) noexcept
|
||||
{
|
||||
return int(o) - 1;
|
||||
|
@ -106,12 +106,12 @@ public:
|
||||
typedef QtPrivate::FunctionPointer<Func> SlotType;
|
||||
|
||||
typedef QtPrivate::FunctionPointer<void (*)(QHostInfo)> SignalType;
|
||||
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
|
||||
"The slot requires more arguments than the signal provides.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments,
|
||||
static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments,
|
||||
typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType,
|
||||
static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType,
|
||||
typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible "
|
||||
"with the return type of the signal.");
|
||||
@ -137,7 +137,7 @@ public:
|
||||
{
|
||||
typedef QtPrivate::FunctionPointer<Func1> SlotType;
|
||||
|
||||
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 1,
|
||||
static_assert(int(SlotType::ArgumentCount) <= 1,
|
||||
"The slot must not require more than one argument");
|
||||
|
||||
auto slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1,
|
||||
|
@ -151,8 +151,8 @@ template <typename Lambda> struct ProcessNetlinkRequest
|
||||
|
||||
static int expectedTypeForRequest(int rtype)
|
||||
{
|
||||
Q_STATIC_ASSERT(RTM_NEWADDR == RTM_GETADDR - 2);
|
||||
Q_STATIC_ASSERT(RTM_NEWLINK == RTM_GETLINK - 2);
|
||||
static_assert(RTM_NEWADDR == RTM_GETADDR - 2);
|
||||
static_assert(RTM_NEWLINK == RTM_GETLINK - 2);
|
||||
Q_ASSERT(rtype == RTM_GETADDR || rtype == RTM_GETLINK);
|
||||
return rtype - 2;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
|
||||
memset(&mediareq, 0, sizeof(mediareq));
|
||||
|
||||
// ensure both structs start with the name field, of size IFNAMESIZ
|
||||
Q_STATIC_ASSERT(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name));
|
||||
static_assert(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name));
|
||||
Q_ASSERT(&mediareq.ifm_name == &req.ifr_name);
|
||||
|
||||
// on NetBSD we use AF_LINK and sockaddr_dl
|
||||
|
@ -84,7 +84,7 @@ static bool containsTLDEntry(QStringView entry, TLDMatchType match)
|
||||
Q_ASSERT(tldGroupOffset <= tldIndices[index + 1]);
|
||||
// The last extra entry in tldIndices
|
||||
// should be equal to the total of all chunks' lengths.
|
||||
Q_STATIC_ASSERT(tldIndices[tldCount] == tldChunks[tldChunkCount - 1]);
|
||||
static_assert(tldIndices[tldCount] == tldChunks[tldChunkCount - 1]);
|
||||
|
||||
// Find which chunk contains the tldGroupOffset
|
||||
while (tldGroupOffset >= tldChunks[chunk]) {
|
||||
|
@ -1044,7 +1044,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
|
||||
if (cmsgptr->cmsg_len == CMSG_LEN(sizeof(int))
|
||||
&& ((cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_HOPLIMIT)
|
||||
|| (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) {
|
||||
Q_STATIC_ASSERT(sizeof(header->hopLimit) == sizeof(int));
|
||||
static_assert(sizeof(header->hopLimit) == sizeof(int));
|
||||
memcpy(&header->hopLimit, CMSG_DATA(cmsgptr), sizeof(header->hopLimit));
|
||||
}
|
||||
|
||||
|
@ -1617,7 +1617,7 @@ QList<QSslCipher> QSslSocketBackendPrivate::defaultCiphers()
|
||||
const QSsl::SslProtocol protocols[] = { QSsl::TlsV1_0, QSsl::TlsV1_1,
|
||||
QSsl::TlsV1_2, QSsl::TlsV1_3 };
|
||||
const int size = ARRAYSIZE(protocols);
|
||||
Q_STATIC_ASSERT(size == ARRAYSIZE(protocolStrings));
|
||||
static_assert(size == ARRAYSIZE(protocolStrings));
|
||||
ciphers.reserve(size);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
QSslCipher cipher;
|
||||
|
@ -104,7 +104,7 @@ QOscMessage::QOscMessage(const QByteArray &data)
|
||||
if (parsedBytes > (quint32)data.size() || data.size() - parsedBytes < sizeof(quint32))
|
||||
return;
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(float) == sizeof(quint32));
|
||||
static_assert(sizeof(float) == sizeof(quint32));
|
||||
union {
|
||||
quint32 u;
|
||||
float f;
|
||||
|
@ -540,7 +540,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = {
|
||||
Qt::NoModifier, // Fall-back to raw Key_*
|
||||
};
|
||||
static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl;
|
||||
Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys));
|
||||
static_assert((NumMods == KeyboardLayoutItem::NumQtKeys));
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug d, const KeyboardLayoutItem &k)
|
||||
|
@ -840,7 +840,7 @@ class FakePointer
|
||||
{
|
||||
public:
|
||||
|
||||
Q_STATIC_ASSERT_X(sizeof(T) <= sizeof(void *), "FakePointers can only go that far.");
|
||||
static_assert(sizeof(T) <= sizeof(void *), "FakePointers can only go that far.");
|
||||
|
||||
static FakePointer *create(T thing)
|
||||
{
|
||||
|
@ -3238,7 +3238,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
|
||||
static const CFStringRef keys[] = { kCTFontAttributeName, kCTForegroundColorAttributeName };
|
||||
static const int numValues = sizeof(keys) / sizeof(keys[0]);
|
||||
const CFTypeRef values[] = { (CFTypeRef)checkmarkFont, (CFTypeRef)checkmarkColor };
|
||||
Q_STATIC_ASSERT((sizeof(values) / sizeof(values[0])) == numValues);
|
||||
static_assert((sizeof(values) / sizeof(values[0])) == numValues);
|
||||
QCFType<CFDictionaryRef> attributes = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)values,
|
||||
numValues, NULL, NULL);
|
||||
// U+2713: CHECK MARK
|
||||
|
@ -124,7 +124,7 @@ do {\
|
||||
* in their code.
|
||||
*/
|
||||
# define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) \
|
||||
Q_STATIC_ASSERT_X(false, "Support of exceptions is disabled")
|
||||
static_assert(false, "Support of exceptions is disabled")
|
||||
|
||||
#endif // !QT_NO_EXCEPTIONS
|
||||
|
||||
@ -342,7 +342,7 @@ namespace QTest
|
||||
inline void addColumn(const char *name, T * = nullptr)
|
||||
{
|
||||
using QIsSameTConstChar = std::is_same<T, const char*>;
|
||||
Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
|
||||
static_assert(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
|
||||
addColumnInternal(qMetaTypeId<T>(), name);
|
||||
}
|
||||
Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag);
|
||||
|
@ -163,11 +163,11 @@ static bool metFatal = false;
|
||||
|
||||
static QString msgType2i18nString(QtMsgType t)
|
||||
{
|
||||
Q_STATIC_ASSERT(QtDebugMsg == 0);
|
||||
Q_STATIC_ASSERT(QtWarningMsg == 1);
|
||||
Q_STATIC_ASSERT(QtCriticalMsg == 2);
|
||||
Q_STATIC_ASSERT(QtFatalMsg == 3);
|
||||
Q_STATIC_ASSERT(QtInfoMsg == 4);
|
||||
static_assert(QtDebugMsg == 0);
|
||||
static_assert(QtWarningMsg == 1);
|
||||
static_assert(QtCriticalMsg == 2);
|
||||
static_assert(QtFatalMsg == 3);
|
||||
static_assert(QtInfoMsg == 4);
|
||||
|
||||
// adjust the array below if any of the above fire...
|
||||
|
||||
|
@ -163,7 +163,7 @@ static const char *changed_signal(int which)
|
||||
case 5: return SIGNAL(currentRowChanged(int));
|
||||
case 6: return SIGNAL(valueChanged(int));
|
||||
};
|
||||
Q_STATIC_ASSERT(7 == NFallbackDefaultProperties);
|
||||
static_assert(7 == NFallbackDefaultProperties);
|
||||
Q_UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -10869,7 +10869,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
|
||||
return;
|
||||
|
||||
Q_D(QWidget);
|
||||
Q_STATIC_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
|
||||
static_assert(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
|
||||
"QWidget::setAttribute(WidgetAttribute, bool): "
|
||||
"QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here
|
||||
static_assert(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here
|
||||
|
||||
void QKeySequenceEditPrivate::init()
|
||||
{
|
||||
|
@ -135,10 +135,10 @@ void tst_QFlags::signedness()
|
||||
// underlying type is implementation-defined, we need to allow for
|
||||
// a different signedness, so we only check that the relative
|
||||
// signedness of the types matches:
|
||||
Q_STATIC_ASSERT((std::is_unsigned<typename std::underlying_type<Qt::MouseButton>::type>::value ==
|
||||
static_assert((std::is_unsigned<typename std::underlying_type<Qt::MouseButton>::type>::value ==
|
||||
std::is_unsigned<Qt::MouseButtons::Int>::value));
|
||||
|
||||
Q_STATIC_ASSERT((std::is_signed<typename std::underlying_type<Qt::AlignmentFlag>::type>::value ==
|
||||
static_assert((std::is_signed<typename std::underlying_type<Qt::AlignmentFlag>::type>::value ==
|
||||
std::is_signed<Qt::Alignment::Int>::value));
|
||||
}
|
||||
|
||||
@ -149,9 +149,9 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( MyStrictFlags )
|
||||
enum class MyStrictNoOpEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
|
||||
Q_DECLARE_FLAGS( MyStrictNoOpFlags, MyStrictNoOpEnum )
|
||||
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isComplex );
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isStatic );
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isPointer );
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isComplex );
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isStatic );
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isPointer );
|
||||
|
||||
void tst_QFlags::classEnum()
|
||||
{
|
||||
@ -319,9 +319,9 @@ enum MyEnum { Zero, One, Two, Four=4 };
|
||||
Q_DECLARE_FLAGS( MyFlags, MyEnum )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags )
|
||||
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyFlags>::isComplex );
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyFlags>::isStatic );
|
||||
Q_STATIC_ASSERT( !QTypeInfo<MyFlags>::isPointer );
|
||||
static_assert( !QTypeInfo<MyFlags>::isComplex );
|
||||
static_assert( !QTypeInfo<MyFlags>::isStatic );
|
||||
static_assert( !QTypeInfo<MyFlags>::isPointer );
|
||||
|
||||
QTEST_MAIN(tst_QFlags)
|
||||
#include "tst_qflags.moc"
|
||||
|
@ -106,6 +106,12 @@ Q_STATIC_ASSERT(!0);
|
||||
Q_STATIC_ASSERT(!!true);
|
||||
Q_STATIC_ASSERT(!!1);
|
||||
|
||||
#ifdef __COUNTER__
|
||||
// if the compiler supports __COUNTER__, multiple
|
||||
// Q_STATIC_ASSERT's on a single line should compile:
|
||||
Q_STATIC_ASSERT(true); Q_STATIC_ASSERT_X(!false, "");
|
||||
#endif // __COUNTER__
|
||||
|
||||
#ifdef Q_COMPILER_THREAD_LOCAL
|
||||
static thread_local int gt_var;
|
||||
void thread_local_test()
|
||||
|
@ -345,6 +345,9 @@ struct MyTemplate
|
||||
|
||||
void tst_QGlobal::qstaticassert()
|
||||
{
|
||||
// Test multiple Q_STATIC_ASSERT on a single line
|
||||
Q_STATIC_ASSERT(true); Q_STATIC_ASSERT_X(!false, "");
|
||||
|
||||
// Force compilation of these classes
|
||||
MyTrue tmp1;
|
||||
MyExpresion tmp2;
|
||||
@ -352,11 +355,6 @@ void tst_QGlobal::qstaticassert()
|
||||
Q_UNUSED(tmp1);
|
||||
Q_UNUSED(tmp2);
|
||||
Q_UNUSED(tmp3);
|
||||
#ifdef __COUNTER__
|
||||
// if the compiler supports __COUNTER__, multiple
|
||||
// Q_STATIC_ASSERT's on a single line should compile:
|
||||
Q_STATIC_ASSERT(true); Q_STATIC_ASSERT_X(!false, "");
|
||||
#endif // __COUNTER__
|
||||
QVERIFY(true); // if the test compiles it has passed.
|
||||
}
|
||||
|
||||
@ -433,15 +431,15 @@ typedef int (Empty::*memFun) ();
|
||||
void tst_QGlobal::integerForSize()
|
||||
{
|
||||
// compile-only test:
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Signed) == 1);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Signed) == 2);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Signed) == 4);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Signed) == 8);
|
||||
static_assert(sizeof(QIntegerForSize<1>::Signed) == 1);
|
||||
static_assert(sizeof(QIntegerForSize<2>::Signed) == 2);
|
||||
static_assert(sizeof(QIntegerForSize<4>::Signed) == 4);
|
||||
static_assert(sizeof(QIntegerForSize<8>::Signed) == 8);
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Unsigned) == 1);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Unsigned) == 2);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Unsigned) == 4);
|
||||
Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Unsigned) == 8);
|
||||
static_assert(sizeof(QIntegerForSize<1>::Unsigned) == 1);
|
||||
static_assert(sizeof(QIntegerForSize<2>::Unsigned) == 2);
|
||||
static_assert(sizeof(QIntegerForSize<4>::Unsigned) == 4);
|
||||
static_assert(sizeof(QIntegerForSize<8>::Unsigned) == 8);
|
||||
}
|
||||
|
||||
typedef QPair<const char *, const char *> stringpair;
|
||||
|
@ -228,7 +228,7 @@ void tst_QNumeric::distinctNaNF() {
|
||||
template<typename F, typename Whole>
|
||||
void tst_QNumeric::generalNaN_data()
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(F) == sizeof(Whole));
|
||||
static_assert(sizeof(F) == sizeof(Whole));
|
||||
QTest::addColumn<Whole>("whole");
|
||||
// Every value with every bit of the exponent set is a NaN.
|
||||
// Sign and mantissa can be anything without interfering with that.
|
||||
@ -251,7 +251,7 @@ void tst_QNumeric::generalNaN_data()
|
||||
template<typename F, typename Whole>
|
||||
void tst_QNumeric::generalNaN()
|
||||
{
|
||||
Q_STATIC_ASSERT(sizeof(F) == sizeof(Whole));
|
||||
static_assert(sizeof(F) == sizeof(Whole));
|
||||
QFETCH(const Whole, whole);
|
||||
F nan;
|
||||
memcpy(&nan, &whole, sizeof(F));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user