mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #413 CVariant and CPropertyIndexVariantMap equality operator templates support any metatype-registered class, not just CValueObject subclasses.
This commit is contained in:
@@ -116,22 +116,22 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Operator == with CValueObject
|
//! Operator == with CValueObject
|
||||||
//! \todo Still needed?
|
//! \todo Still needed?
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
friend bool operator ==(const CPropertyIndexVariantMap &valueMap, const T &valueObject) { return valueMap == CVariant::from(valueObject); }
|
friend bool operator ==(const CPropertyIndexVariantMap &valueMap, const T &valueObject) { return valueMap == CVariant::from(valueObject); }
|
||||||
|
|
||||||
//! Operator != with CValueObject
|
//! Operator != with CValueObject
|
||||||
//! \todo Still needed?
|
//! \todo Still needed?
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
friend bool operator !=(const CPropertyIndexVariantMap &valueMap, const T &valueObject) { return valueMap != CVariant::from(valueObject); }
|
friend bool operator !=(const CPropertyIndexVariantMap &valueMap, const T &valueObject) { return valueMap != CVariant::from(valueObject); }
|
||||||
|
|
||||||
//! Operator == with CValueObject
|
//! Operator == with CValueObject
|
||||||
//! \todo Still needed?
|
//! \todo Still needed?
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
friend bool operator ==(const T &valueObject, const CPropertyIndexVariantMap &valueMap) { return valueMap == CVariant::from(valueObject); }
|
friend bool operator ==(const T &valueObject, const CPropertyIndexVariantMap &valueMap) { return valueMap == CVariant::from(valueObject); }
|
||||||
|
|
||||||
//! Operator != with CValueObject
|
//! Operator != with CValueObject
|
||||||
//! \todo Still needed?
|
//! \todo Still needed?
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
friend bool operator !=(const T &valueObject, const CPropertyIndexVariantMap &valueMap) { return valueMap != CVariant::from(valueObject); }
|
friend bool operator !=(const T &valueObject, const CPropertyIndexVariantMap &valueMap) { return valueMap != CVariant::from(valueObject); }
|
||||||
|
|
||||||
//! Map
|
//! Map
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
bool operator ==(const T &value, const CVariant &variant)
|
bool operator ==(const T &value, const CVariant &variant)
|
||||||
{
|
{
|
||||||
if (variant.canConvert<T>()) { return variant.value<T>() == value; }
|
if (variant.canConvert<T>()) { return variant.value<T>() == value; }
|
||||||
@@ -247,21 +247,21 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
bool operator !=(const T &value, const CVariant &variant)
|
bool operator !=(const T &value, const CVariant &variant)
|
||||||
{
|
{
|
||||||
return !(value == variant);
|
return !(value == variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
bool operator ==(const CVariant &variant, const T &value)
|
bool operator ==(const CVariant &variant, const T &value)
|
||||||
{
|
{
|
||||||
return value == variant;
|
return value == variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
template <class T, class = typename std::enable_if<QMetaTypeId<T>::Defined>::type>
|
||||||
bool operator !=(const CVariant &variant, const T &value)
|
bool operator !=(const CVariant &variant, const T &value)
|
||||||
{
|
{
|
||||||
return !(value == variant);
|
return !(value == variant);
|
||||||
|
|||||||
Reference in New Issue
Block a user