diff options
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlprivate.h | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 62524aa..3f41fb7 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -123,43 +123,13 @@ namespace QmlPrivate } }; - template <typename T> - class has_attachedPropertiesMember - { - typedef int yes_type; - typedef char no_type; - template <int> - struct Selector {}; - - template <typename S> - static yes_type test(Selector<sizeof(&S::qmlAttachedProperties)>*); - - template <typename S> - static no_type test(...); - - public: - static bool const value = sizeof(test<T>(0)) == sizeof(yes_type); - }; - - template <typename T, bool hasMember> - class has_attachedPropertiesMethod + template<typename T, typename Sign = T *(*)(QObject *)> + struct has_qmlAttachedProperties { - typedef int yes_type; - typedef char no_type; - - template<typename ReturnType> - static yes_type check(ReturnType *(*)(QObject *)); - static no_type check(...); - - public: - static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type); - }; - - template <typename T> - class has_attachedPropertiesMethod<T, false> - { - public: - static bool const value = false; + template <typename U, U> struct type_check; + template <typename _1> static char check(type_check<Sign, &_1::qmlAttachedProperties> *); + template <typename > static int check(...); + static bool const value = sizeof(check<T>(0)) == sizeof(char); }; template<typename T, int N> @@ -191,13 +161,13 @@ namespace QmlPrivate template<typename T> inline QmlAttachedPropertiesFunc attachedPropertiesFunc() { - return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func(); + return AttachedPropertySelector<T, has_qmlAttachedProperties<T>::value >::func(); } template<typename T> inline const QMetaObject *attachedPropertiesMetaObject() { - return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject(); + return AttachedPropertySelector<T, has_qmlAttachedProperties<T>::value >::metaObject(); } struct MetaTypeIds { |