diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-19 12:53:38 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-26 20:12:45 -0700 |
commit | 764d82ceb541f5b0ca812fa451707311b6e6ccc0 (patch) | |
tree | 3c6e8e8e92ecf467f5dec973d37d9e77439394c0 /src/corelib/kernel/qmetatype.cpp | |
parent | 74fac865cf7c55d3afba1043072ba6cc932d161d (diff) |
QMetaType: add is{Default,Copy,Move}Constructible and isDestructible
Unit tests will come after I've fixed the flags themselves. At this point,
they are wrong.
[ChangeLog][QtCore][QMetaType] Added isDefaultConstructible(),
isCopyConstructible(), isMoveConstructible() and isDestructible().
Change-Id: I3859764fed084846bcb0fffd170353109378e34c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index ea7cd4a0c9..f2676fa48f 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -65,6 +65,8 @@ QT_BEGIN_NAMESPACE QT_IMPL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl, QPairVariantInterfaceImpl) +using QtMetaTypePrivate::isVoid; + namespace { struct QMetaTypeCustomRegistry @@ -554,9 +556,13 @@ int QMetaType::registerHelper(const QtPrivate::QMetaTypeInterface *iface) \fn constexpr TypeFlags QMetaType::flags() const \since 5.0 - Returns flags of the type for which this QMetaType instance was constructed. + Returns flags of the type for which this QMetaType instance was + constructed. To inspect specific type traits, prefer using one of the "is-" + functions rather than the flags directly. - \sa QMetaType::TypeFlags, QMetaType::flags() + \sa QMetaType::TypeFlags, QMetaType::flags(), isDefaultConstructible(), + isCopyConstructible(), isMoveConstructible(), isDestructible(), + isEqualityComparable(), isOrdered() */ /*! @@ -778,6 +784,68 @@ bool QMetaType::equals(const void *lhs, const void *rhs) const } /*! + \fn bool QMetaType::isDefaultConstructible() const noexcept + \since 6.5 + + Returns true if this type can be default-constructed. If it can be, then + construct() and create() can be used with a \c{copy} parameter that is + null. + + \sa flags(), isCopyConstructible(), isMoveConstructible(), isDestructible() + */ + +/*! + \fn bool QMetaType::isCopyConstructible() const noexcept + \since 6.5 + + Returns true if this type can be copy-constructed. If it can be, then + construct() and create() can be used with a \c{copy} parameter that is + not null. + + \sa flags(), isDefaultConstructible(), isMoveConstructible(), isDestructible() + */ + +/*! + \fn bool QMetaType::isMoveConstructible() const noexcept + \since 6.5 + + Returns true if this type can be move-constructed. QMetaType currently does + not have an API to make use of this trait. + + \sa flags(), isDefaultConstructible(), isCopyConstructible(), isDestructible() + */ + +/*! + \fn bool QMetaType::isDestructible() const noexcept + \since 6.5 + + Returns true if this type can be destroyed. If it can be, then destroy() + and destruct() can be called. + + \sa flags(), isDefaultConstructible(), isCopyConstructible(), isMoveConstructible() + */ + +bool QMetaType::isDefaultConstructible(const QtPrivate::QMetaTypeInterface *iface) noexcept +{ + return !isVoid(iface) && QtMetaTypePrivate::isDefaultConstructible(iface); +} + +bool QMetaType::isCopyConstructible(const QtPrivate::QMetaTypeInterface *iface) noexcept +{ + return !isVoid(iface) && QtMetaTypePrivate::isCopyConstructible(iface); +} + +bool QMetaType::isMoveConstructible(const QtPrivate::QMetaTypeInterface *iface) noexcept +{ + return !isVoid(iface) && QtMetaTypePrivate::isMoveConstructible(iface); +} + +bool QMetaType::isDestructible(const QtPrivate::QMetaTypeInterface *iface) noexcept +{ + return !isVoid(iface) && QtMetaTypePrivate::isDestructible(iface); +} + +/*! Returns \c true if a less than or equality operator for the type described by this metatype was visible to the metatype declaration, otherwise \c false. |