Fix usage of std::enable_if_t to SFINAE out QProperty APIs

Declare an IfUntypedPropertyData alias and use that consistently.

Amends 311f8896322bcd39d33369c8311a8c89ccdad449.

Change-Id: If36ef8e2f9ce25e0ffe7b4b448c31ea5866acfc3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 216af5d7f9675a408e22167b097f221beeeb88db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-02-02 14:34:54 +01:00 committed by Qt Cherry-pick Bot
parent 78e2a49a48
commit bd179a8d2f
2 changed files with 9 additions and 15 deletions

View File

@ -263,8 +263,7 @@ public:
QPropertyObserver &operator=(QPropertyObserver &&other) noexcept;
~QPropertyObserver();
template <typename Property,
typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
template <typename Property, QtPrivate::IsUntypedPropertyData<Property> = true>
void setSource(const Property &property)
{ setSource(property.bindingData()); }
void setSource(const QtPrivate::QPropertyBindingData &property);
@ -303,8 +302,7 @@ public:
{
}
template <typename Property,
typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
template <typename Property, QtPrivate::IsUntypedPropertyData<Property> = true>
Q_NODISCARD_CTOR
QPropertyChangeHandler(const Property &property, Functor handler)
: QPropertyObserver([](QPropertyObserver *self, QUntypedPropertyData *) {
@ -335,7 +333,7 @@ public:
}
template <typename Functor, typename Property,
typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
QtPrivate::IsUntypedPropertyData<Property> = true>
Q_NODISCARD_CTOR
QPropertyNotifier(const Property &property, Functor handler)
: QPropertyObserver([](QPropertyObserver *self, QUntypedPropertyData *) {
@ -909,8 +907,7 @@ public:
iface->setObserver(aliasedProperty(), this);
}
template <typename Property,
typename = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, Property>>>
template <typename Property, QtPrivate::IsUntypedPropertyData<Property> = true>
QPropertyAlias(Property *property)
: QPropertyObserver(property),
iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)

View File

@ -124,16 +124,13 @@ struct QPropertyObserverPointer;
class QUntypedPropertyData
{
public:
#if QT_DEPRECATED_SINCE(6, 8)
// sentinel to check whether a class inherits QUntypedPropertyData
struct QT_DEPRECATED_VERSION_X_6_8("Use std::is_base_of instead.")
InheritsQUntypedPropertyData
{
};
#endif
};
namespace QtPrivate {
template <typename T>
using IsUntypedPropertyData = std::enable_if_t<std::is_base_of_v<QUntypedPropertyData, T>, bool>;
}
template <typename T>
class QPropertyData;