diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index bcf365bdf61..6451c19d357 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -20,6 +20,18 @@ class QDebug; namespace QtPrivate { +// Helper for QTypeInfo::isComplex, which used to be simply +// !std::is_trivial_v but P3247 deprecated it for C++26. It used to be defined +// (since C++11) by [class]/7 as: "A trivial class is a class that is trivially +// copyable and has one or more default constructors, all of which are either +// trivial or deleted and at least one of which is not deleted. [ Note: In +// particular, a trivially copyable or trivial class does not have virtual +// functions or virtual base classes. — end note ]". + +template +inline constexpr bool qIsComplex = + !std::is_trivially_default_constructible_v || !std::is_trivially_copyable_v; + // A trivially copyable class must also have a trivial, non-deleted // destructor [class.prop/1.3], CWG1734. Some implementations don't // check for a trivial destructor, because of backwards compatibility @@ -53,7 +65,7 @@ public: enum { isPointer [[deprecated("Use std::is_pointer instead")]] = std::is_pointer_v, isIntegral [[deprecated("Use std::is_integral instead")]] = std::is_integral_v, - isComplex = !std::is_trivial_v, + isComplex = QtPrivate::qIsComplex, isRelocatable = QtPrivate::qIsRelocatable, isValueInitializationBitwiseZero = QtPrivate::qIsValueInitializationBitwiseZero, }; @@ -162,7 +174,7 @@ class QTypeInfo \ { \ public: \ enum { \ - isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0) && !std::is_trivial_v, \ + isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0) && QtPrivate::qIsComplex, \ isRelocatable = !isComplex || ((FLAGS) & Q_RELOCATABLE_TYPE) || QtPrivate::qIsRelocatable, \ isPointer [[deprecated("Use std::is_pointer instead")]] = std::is_pointer_v< TYPE >, \ isIntegral [[deprecated("Use std::is_integral instead")]] = std::is_integral< TYPE >::value, \ diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 6109e9d7f10..0b540f3d81d 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -180,7 +180,7 @@ struct ChildError int code; char function[_POSIX_PIPE_BUF - sizeof(code)]; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_copy_constructible_v); #ifdef PIPE_BUF static_assert(PIPE_BUF >= sizeof(ChildError)); // PIPE_BUF may be bigger #endif diff --git a/src/corelib/kernel/qobject_p_p.h b/src/corelib/kernel/qobject_p_p.h index 2277af04976..0265b2f8a57 100644 --- a/src/corelib/kernel/qobject_p_p.h +++ b/src/corelib/kernel/qobject_p_p.h @@ -64,7 +64,7 @@ struct QObjectPrivate::ConnectionOrSignalVector Connection *next; }; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_copyable_v); struct QObjectPrivate::Connection : public ConnectionOrSignalVector { @@ -130,8 +130,8 @@ struct QObjectPrivate::SignalVector : public ConnectionOrSignalVector } int count() const { return static_cast(allocated); } }; -static_assert( - std::is_trivial_v); // it doesn't need to be, but it helps +// it doesn't need to be, but it helps +static_assert(std::is_trivially_copyable_v); struct QObjectPrivate::ConnectionData { diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index a8c310ddfaa..3f09d01a687 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -89,7 +89,8 @@ struct ByteData QStringView asStringView() const{ return QStringView(utf16(), len / 2); } QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); } }; -static_assert(std::is_trivial::value); +static_assert(std::is_trivially_default_constructible::value); +static_assert(std::is_trivially_copyable::value); static_assert(std::is_standard_layout::value); } // namespace QtCbor