mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
refs #356 Removed CValueObject and expanded CValueObjectStdTuple to compensate.
* Involves rearranging some header includes to break cyclic include dependencies, * Adding a new, simple base class CEmpty, * Removing any remaining polymorphic uses of CValueObject with templates, * Adding a new trait for use with enable_if to restrict templates to work only with value objects, * Replacing the polymorphic/runtime multimethod-based compare functions with static/compile-time compare functions.
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#include "valueobject.h" // outside include guard due to cyclic dependency hack (MS)
|
||||
|
||||
#ifndef BLACKMISC_VARIANT_H
|
||||
#define BLACKMISC_VARIANT_H
|
||||
|
||||
#include "valueobject.h"
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
#include <QJsonValueRef>
|
||||
@@ -220,7 +221,7 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||
template <class T, class = typename std::enable_if<std::is_base_of<CValueObject, T>::value>::type>
|
||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
||||
bool operator ==(const T &value, const CVariant &variant)
|
||||
{
|
||||
if (variant.canConvert<T>()) { return variant.value<T>() == value; }
|
||||
@@ -228,21 +229,21 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||
template <class T, class = typename std::enable_if<std::is_base_of<CValueObject, T>::value>::type>
|
||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
||||
bool operator !=(const T &value, const CVariant &variant)
|
||||
{
|
||||
return !(value == variant);
|
||||
}
|
||||
|
||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||
template <class T, class = typename std::enable_if<std::is_base_of<CValueObject, T>::value>::type>
|
||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
||||
bool operator ==(const CVariant &variant, const T &value)
|
||||
{
|
||||
return value == variant;
|
||||
}
|
||||
|
||||
//! Compare stored value of CVariant with any CValueObject derived class.
|
||||
template <class T, class = typename std::enable_if<std::is_base_of<CValueObject, T>::value>::type>
|
||||
template <class T, class = typename std::enable_if<IsValueObject<T>::value>::type>
|
||||
bool operator !=(const CVariant &variant, const T &value)
|
||||
{
|
||||
return !(value == variant);
|
||||
|
||||
Reference in New Issue
Block a user