mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
refs #697 Type traits renamed with T prefix.
This commit is contained in:
@@ -56,7 +56,7 @@ namespace BlackMisc
|
|||||||
static bool equals(const Derived &a, const Derived &b)
|
static bool equals(const Derived &a, const Derived &b)
|
||||||
{
|
{
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
||||||
bool result = baseEquals(static_cast<const BaseOfT<Derived> *>(&a), static_cast<const BaseOfT<Derived> *>(&b));
|
bool result = baseEquals(static_cast<const TBaseOfT<Derived> *>(&a), static_cast<const TBaseOfT<Derived> *>(&b));
|
||||||
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result && EqualsByMetaClass::membersEqual(std::forward<decltype(args)>(args)...); });
|
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result && EqualsByMetaClass::membersEqual(std::forward<decltype(args)>(args)...); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -120,8 +120,8 @@ namespace BlackMisc
|
|||||||
static bool less(const Derived &a, const Derived &b)
|
static bool less(const Derived &a, const Derived &b)
|
||||||
{
|
{
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
||||||
bool result = baseLess(static_cast<const BaseOfT<Derived> *>(&a), static_cast<const BaseOfT<Derived> *>(&b));
|
bool result = baseLess(static_cast<const TBaseOfT<Derived> *>(&a), static_cast<const TBaseOfT<Derived> *>(&b));
|
||||||
bool gt = baseLess(static_cast<const BaseOfT<Derived> *>(&b), static_cast<const BaseOfT<Derived> *>(&a));
|
bool gt = baseLess(static_cast<const TBaseOfT<Derived> *>(&b), static_cast<const TBaseOfT<Derived> *>(&a));
|
||||||
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result || LessThanByMetaClass::membersLess(gt, std::forward<decltype(args)>(args)...); });
|
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result || LessThanByMetaClass::membersLess(gt, std::forward<decltype(args)>(args)...); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ namespace BlackMisc
|
|||||||
static int compareImpl(const Derived &a, const Derived &b)
|
static int compareImpl(const Derived &a, const Derived &b)
|
||||||
{
|
{
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForComparison>());
|
||||||
int result = baseCompare(static_cast<const BaseOfT<Derived> *>(&a), static_cast<const BaseOfT<Derived> *>(&b));
|
int result = baseCompare(static_cast<const TBaseOfT<Derived> *>(&a), static_cast<const TBaseOfT<Derived> *>(&b));
|
||||||
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result ? result : CompareByMetaClass::membersCompare(std::forward<decltype(args)>(args)...); });
|
meta.forEachMemberPair(a, b, [ & ](auto &&... args) { result = result ? result : CompareByMetaClass::membersCompare(std::forward<decltype(args)>(args)...); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ namespace BlackMisc
|
|||||||
static int membersCompare(const T &a, const T &b, Flags)
|
static int membersCompare(const T &a, const T &b, Flags)
|
||||||
{
|
{
|
||||||
using CaseInsensitive = std::integral_constant<bool, static_cast<bool>(Flags::value & CaseInsensitiveComparison)>;
|
using CaseInsensitive = std::integral_constant<bool, static_cast<bool>(Flags::value & CaseInsensitiveComparison)>;
|
||||||
return membersCompare(a, b, CaseInsensitive(), HasCompare<T, T>());
|
return membersCompare(a, b, CaseInsensitive(), THasCompare<T, T>());
|
||||||
}
|
}
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
static int membersCompare(const T &a, const T &b, std::true_type, U) { return a.compare(b, Qt::CaseInsensitive); }
|
static int membersCompare(const T &a, const T &b, std::true_type, U) { return a.compare(b, Qt::CaseInsensitive); }
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
|||||||
//! Marshall without begin/endStructure, for when composed within another object
|
//! Marshall without begin/endStructure, for when composed within another object
|
||||||
void marshallToDbus(QDBusArgument &arg) const
|
void marshallToDbus(QDBusArgument &arg) const
|
||||||
{
|
{
|
||||||
baseMarshall(static_cast<const BaseOfT<Derived> *>(derived()), arg);
|
baseMarshall(static_cast<const TBaseOfT<Derived> *>(derived()), arg);
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
||||||
meta.forEachMember(*derived(), [ & ](const auto &member) { arg << member; });
|
meta.forEachMember(*derived(), [ & ](const auto &member) { arg << member; });
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ namespace BlackMisc
|
|||||||
//! Unmarshall without begin/endStructure, for when composed within another object
|
//! Unmarshall without begin/endStructure, for when composed within another object
|
||||||
void unmarshallFromDbus(const QDBusArgument &arg)
|
void unmarshallFromDbus(const QDBusArgument &arg)
|
||||||
{
|
{
|
||||||
baseUnmarshall(static_cast<BaseOfT<Derived> *>(derived()), arg);
|
baseUnmarshall(static_cast<TBaseOfT<Derived> *>(derived()), arg);
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
||||||
meta.forEachMember(*derived(), [ & ](auto &member) { arg >> member; });
|
meta.forEachMember(*derived(), [ & ](auto &member) { arg >> member; });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,19 +53,19 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
template <bool KeySupportsQHash /* = true */, bool KeySupportsQMap>
|
template <bool KeySupportsQHash /* = true */, bool KeySupportsQMap>
|
||||||
struct AssociativityTraits
|
struct TAssociativityTraits
|
||||||
{
|
{
|
||||||
template <class Key, class Value>
|
template <class Key, class Value>
|
||||||
using DefaultType = QHash<Key, Value>;
|
using DefaultType = QHash<Key, Value>;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AssociativityTraits<false, true>
|
struct TAssociativityTraits<false, true>
|
||||||
{
|
{
|
||||||
template <class Key, class Value>
|
template <class Key, class Value>
|
||||||
using DefaultType = QMap<Key, Value>;
|
using DefaultType = QMap<Key, Value>;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AssociativityTraits<false, false>
|
struct TAssociativityTraits<false, false>
|
||||||
{
|
{
|
||||||
template <class Key, class>
|
template <class Key, class>
|
||||||
struct DefaultType { static_assert(std::is_void<Key>::value, "Key does not support either QHash or QMap"); };
|
struct DefaultType { static_assert(std::is_void<Key>::value, "Key does not support either QHash or QMap"); };
|
||||||
@@ -87,12 +87,12 @@ namespace BlackMisc
|
|||||||
* Trait to select the appropriate default associative container type depending on what the key type supports.
|
* Trait to select the appropriate default associative container type depending on what the key type supports.
|
||||||
*/
|
*/
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
using DefaultAssociativeType = typename Private::AssociativityTraits<ModelsQHashKey<K>::value, ModelsQMapKey<K>::value>::template DefaultType<K, V>;
|
using TDefaultAssociativeType = typename Private::TAssociativityTraits<TModelsQHashKey<K>::value, TModelsQMapKey<K>::value>::template DefaultType<K, V>;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Associative container with value semantics, chooses a sensible default implementation container type.
|
* Associative container with value semantics, chooses a sensible default implementation container type.
|
||||||
*/
|
*/
|
||||||
template<class Key, class Value, template <class...> class Impl = DefaultAssociativeType>
|
template<class Key, class Value, template <class...> class Impl = TDefaultAssociativeType>
|
||||||
class CDictionary :
|
class CDictionary :
|
||||||
public Mixin::DBusOperators<CDictionary<Key, Value, Impl>>,
|
public Mixin::DBusOperators<CDictionary<Key, Value, Impl>>,
|
||||||
public Mixin::JsonOperators<CDictionary<Key, Value, Impl>>,
|
public Mixin::JsonOperators<CDictionary<Key, Value, Impl>>,
|
||||||
@@ -485,7 +485,7 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
static uint hashImpl(const Derived &value)
|
static uint hashImpl(const Derived &value)
|
||||||
{
|
{
|
||||||
uint hash = baseHash(static_cast<const BaseOfT<Derived> *>(&value));
|
uint hash = baseHash(static_cast<const TBaseOfT<Derived> *>(&value));
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForHashing>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForHashing>());
|
||||||
meta.forEachMember(value, Private::Hasher { hash });
|
meta.forEachMember(value, Private::Hasher { hash });
|
||||||
return hash;
|
return hash;
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ namespace BlackMisc
|
|||||||
* If T has a member typedef base_type, this trait will obtain it, otherwise void.
|
* If T has a member typedef base_type, this trait will obtain it, otherwise void.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct BaseOf
|
struct TBaseOf
|
||||||
{
|
{
|
||||||
using type = void; //!< void
|
using type = void; //!< void
|
||||||
};
|
};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct BaseOf<T, void_t<typename T::base_type>>
|
struct TBaseOf<T, void_t<typename T::base_type>>
|
||||||
{
|
{
|
||||||
using type = typename T::base_type; //!< T::base_type
|
using type = typename T::base_type; //!< T::base_type
|
||||||
};
|
};
|
||||||
@@ -40,45 +40,45 @@ namespace BlackMisc
|
|||||||
* It T has a member typedef base_type which is a registered metatype, this trait will obtain it, otherwise void.
|
* It T has a member typedef base_type which is a registered metatype, this trait will obtain it, otherwise void.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
struct MetaBaseOf
|
struct TMetaBaseOf
|
||||||
{
|
{
|
||||||
//! Type of T::base_type, or void if not declared.
|
//! Type of T::base_type, or void if not declared.
|
||||||
using type = std::conditional_t<QMetaTypeId<typename BaseOf<T>::type>::Defined, typename BaseOf<T>::type, void>;
|
using type = std::conditional_t<QMetaTypeId<typename TBaseOf<T>::type>::Defined, typename TBaseOf<T>::type, void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* If T has a member typedef base_type which has a member propertyByIndex, this trait will obtain it, otherwise void.
|
* If T has a member typedef base_type which has a member propertyByIndex, this trait will obtain it, otherwise void.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct IndexBaseOf
|
struct TIndexBaseOf
|
||||||
{
|
{
|
||||||
using type = void; //!< void
|
using type = void; //!< void
|
||||||
};
|
};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct IndexBaseOf<T, void_t<decltype(std::declval<typename T::base_type>().propertyByIndex(std::declval<CPropertyIndex>()))>>
|
struct TIndexBaseOf<T, void_t<decltype(std::declval<typename T::base_type>().propertyByIndex(std::declval<CPropertyIndex>()))>>
|
||||||
{
|
{
|
||||||
using type = typename T::base_type; //!< T::base_type
|
using type = typename T::base_type; //!< T::base_type
|
||||||
};
|
};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Alias for typename BaseOf<T>::type.
|
* Alias for typename TBaseOf<T>::type.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
using BaseOfT = typename BaseOf<T>::type;
|
using TBaseOfT = typename TBaseOf<T>::type;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Alias for typename MetaBaseOf<T>::type.
|
* Alias for typename TMetaBaseOf<T>::type.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
using MetaBaseOfT = typename MetaBaseOf<T>::type;
|
using TMetaBaseOfT = typename TMetaBaseOf<T>::type;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Alias for typename IndexBaseOf<T>::type.
|
* Alias for typename TIndexBaseOf<T>::type.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
using IndexBaseOfT = typename IndexBaseOf<T>::type;
|
using TIndexBaseOfT = typename TIndexBaseOf<T>::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
template <class T> auto makeInsertIterator(T &container)
|
template <class T> auto makeInsertIterator(T &container)
|
||||||
{
|
{
|
||||||
return Private::makeInsertIterator(container, HasPushBack<T>());
|
return Private::makeInsertIterator(container, THasPushBack<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
json << std::pair<QString, const std::decay_t<decltype(member)> &>(name, member); // std::make_pair causes an ambiguous operator<<
|
json << std::pair<QString, const std::decay_t<decltype(member)> &>(name, member); // std::make_pair causes an ambiguous operator<<
|
||||||
});
|
});
|
||||||
return Json::appendJsonObject(json, baseToJson(static_cast<const BaseOfT<Derived> *>(derived())));
|
return Json::appendJsonObject(json, baseToJson(static_cast<const TBaseOfT<Derived> *>(derived())));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Convenience function JSON as string
|
//! Convenience function JSON as string
|
||||||
@@ -301,7 +301,7 @@ namespace BlackMisc
|
|||||||
//! Assign from JSON object
|
//! Assign from JSON object
|
||||||
void convertFromJson(const QJsonObject &json)
|
void convertFromJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
baseConvertFromJson(static_cast<BaseOfT<Derived> *>(derived()), json);
|
baseConvertFromJson(static_cast<TBaseOfT<Derived> *>(derived()), json);
|
||||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForJson>());
|
auto meta = introspect<Derived>().without(MetaFlags<DisabledForJson>());
|
||||||
meta.forEachMemberName(*derived(), [ & ](auto & member, const QString & name)
|
meta.forEachMemberName(*derived(), [ & ](auto & member, const QString & name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace BlackMisc
|
|||||||
static QThreadStorage<CLogCategoryList> list;
|
static QThreadStorage<CLogCategoryList> list;
|
||||||
if (! list.hasLocalData())
|
if (! list.hasLocalData())
|
||||||
{
|
{
|
||||||
list.localData().appendCategoriesFromMemberFunction(tag<T>(), HasGetLogCategories<T>());
|
list.localData().appendCategoriesFromMemberFunction(tag<T>(), THasGetLogCategories<T>());
|
||||||
list.localData().appendCategoriesFromMetaType(tag<T>(), std::integral_constant<bool, QMetaTypeId<T>::Defined>());
|
list.localData().appendCategoriesFromMetaType(tag<T>(), std::integral_constant<bool, QMetaTypeId<T>::Defined>());
|
||||||
list.localData().appendCategoriesFromMetaObject(tag<T>(), std::is_base_of<QObject, T>());
|
list.localData().appendCategoriesFromMetaObject(tag<T>(), std::is_base_of<QObject, T>());
|
||||||
if (list.localData().isEmpty()) { list.localData().push_back(CLogCategory::uncategorized()); }
|
if (list.localData().isEmpty()) { list.localData().push_back(CLogCategory::uncategorized()); }
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace BlackMisc
|
|||||||
return [index = *this](const auto &a, const auto &b)
|
return [index = *this](const auto &a, const auto &b)
|
||||||
{
|
{
|
||||||
using T = std::decay_t<decltype(a)>;
|
using T = std::decay_t<decltype(a)>;
|
||||||
return Private::compareByProperty(a, b, index, HasCompareByPropertyIndex<T>(), HasPropertyByIndex<T>());
|
return Private::compareByProperty(a, b, index, THasCompareByPropertyIndex<T>(), THasPropertyByIndex<T>());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
baseSetPropertyByIndex(static_cast<IndexBaseOfT<Derived> *>(derived()), variant, index);
|
baseSetPropertyByIndex(static_cast<TIndexBaseOfT<Derived> *>(derived()), variant, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
@@ -263,7 +263,7 @@ namespace BlackMisc
|
|||||||
case IndexString:
|
case IndexString:
|
||||||
return CVariant(derived()->toQString());
|
return CVariant(derived()->toQString());
|
||||||
default:
|
default:
|
||||||
return basePropertyByIndex(static_cast<const IndexBaseOfT<Derived> *>(derived()), index);
|
return basePropertyByIndex(static_cast<const TIndexBaseOfT<Derived> *>(derived()), index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
|
|||||||
@@ -145,9 +145,9 @@ namespace BlackMisc
|
|||||||
protected:
|
protected:
|
||||||
//! Efficiently compare addresses of two objects. Return false if types are not compatible.
|
//! Efficiently compare addresses of two objects. Return false if types are not compatible.
|
||||||
//! @{
|
//! @{
|
||||||
template <typename T, typename U, std::enable_if_t<IsEqualityComparable<const T *, const U *>::value, int> = 0>
|
template <typename T, typename U, std::enable_if_t<TIsEqualityComparable<const T *, const U *>::value, int> = 0>
|
||||||
static bool equalPointers(const T *a, const U *b) { return a == b; }
|
static bool equalPointers(const T *a, const U *b) { return a == b; }
|
||||||
template <typename T, typename U, std::enable_if_t<! IsEqualityComparable<const T *, const U *>::value, int> = 0>
|
template <typename T, typename U, std::enable_if_t<! TIsEqualityComparable<const T *, const U *>::value, int> = 0>
|
||||||
static bool equalPointers(const T *, const U *) { return false; }
|
static bool equalPointers(const T *, const U *) { return false; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace BlackMisc
|
|||||||
Derived &operator <<(QChar v) { return arg(v); }
|
Derived &operator <<(QChar v) { return arg(v); }
|
||||||
Derived &operator <<(char v) { return arg(QChar(v)); }
|
Derived &operator <<(char v) { return arg(QChar(v)); }
|
||||||
Derived &operator <<(double v) { return arg(QString::number(v)); }
|
Derived &operator <<(double v) { return arg(QString::number(v)); }
|
||||||
template <class T, class = std::enable_if_t<HasToQString<T>::value>>
|
template <class T, class = std::enable_if_t<THasToQString<T>::value>>
|
||||||
Derived &operator <<(const T &v) { return arg(v.toQString()); }
|
Derived &operator <<(const T &v) { return arg(v.toQString()); }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ namespace BlackMisc
|
|||||||
* Trait to detect whether T contains a member function toQString.
|
* Trait to detect whether T contains a member function toQString.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct HasToQString : public std::false_type {};
|
struct THasToQString : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct HasToQString<T, void_t<decltype(std::declval<T>().toQString())>> : public std::true_type {};
|
struct THasToQString<T, void_t<decltype(std::declval<T>().toQString())>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
#ifdef Q_CC_MSVC // work around what seems to be an expression SFINAE bug in MSVC
|
#ifdef Q_CC_MSVC // work around what seems to be an expression SFINAE bug in MSVC
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
struct HasPushBackHelper
|
struct THasPushBackHelper
|
||||||
{
|
{
|
||||||
struct Base { int push_back; };
|
struct Base { int push_back; };
|
||||||
template <typename T> struct Derived : public T, public Base {};
|
template <typename T> struct Derived : public T, public Base {};
|
||||||
@@ -61,23 +61,23 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using HasPushBack = decltype(Private::HasPushBackHelper::test<T>(nullptr));
|
using THasPushBack = decltype(Private::THasPushBackHelper::test<T>(nullptr));
|
||||||
#else
|
#else
|
||||||
/*!
|
/*!
|
||||||
* Trait which is true if the expression a.push_back(v) is valid when a and v are instances of T and T::value_type.
|
* Trait which is true if the expression a.push_back(v) is valid when a and v are instances of T and T::value_type.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct HasPushBack : public std::false_type {};
|
struct THasPushBack : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct HasPushBack<T, void_t<decltype(std::declval<T>().push_back(std::declval<typename T::value_type>()))>> : public std::true_type {};
|
struct THasPushBack<T, void_t<decltype(std::declval<T>().push_back(std::declval<typename T::value_type>()))>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_CC_MSVC
|
#ifdef Q_CC_MSVC
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
struct HasGetLogCategoriesHelper
|
struct THasGetLogCategoriesHelper
|
||||||
{
|
{
|
||||||
struct Base { int getLogCategories; };
|
struct Base { int getLogCategories; };
|
||||||
template <typename T> struct Derived : public T, public Base {};
|
template <typename T> struct Derived : public T, public Base {};
|
||||||
@@ -87,16 +87,16 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using HasGetLogCategories = decltype(Private::HasGetLogCategoriesHelper::test<T>(nullptr));
|
using THasGetLogCategories = decltype(Private::THasGetLogCategoriesHelper::test<T>(nullptr));
|
||||||
#else
|
#else
|
||||||
/*!
|
/*!
|
||||||
* Trait to detect whether a class T has a static member function named getLogCategories.
|
* Trait to detect whether a class T has a static member function named getLogCategories.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct HasGetLogCategories : public std::false_type {};
|
struct THasGetLogCategories : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct HasGetLogCategories<T, void_t<decltype(T::getLogCategories())>> : public std::true_type {};
|
struct THasGetLogCategories<T, void_t<decltype(T::getLogCategories())>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -104,30 +104,30 @@ namespace BlackMisc
|
|||||||
* Trait to detect whether a class T can be used as a key in a QHash.
|
* Trait to detect whether a class T can be used as a key in a QHash.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct ModelsQHashKey : public std::false_type {};
|
struct TModelsQHashKey : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct ModelsQHashKey<T, void_t<decltype(std::declval<T>() == std::declval<T>(), qHash(std::declval<T>()))>> : public std::true_type {};
|
struct TModelsQHashKey<T, void_t<decltype(std::declval<T>() == std::declval<T>(), qHash(std::declval<T>()))>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Trait to detect whether a class T can be used as a key in a QMap.
|
* Trait to detect whether a class T can be used as a key in a QMap.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct ModelsQMapKey : public std::false_type {};
|
struct TModelsQMapKey : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct ModelsQMapKey<T, void_t<decltype(std::declval<T>() < std::declval<T>())>> : public std::true_type {};
|
struct TModelsQMapKey<T, void_t<decltype(std::declval<T>() < std::declval<T>())>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Trait which is true if the expression compare(a, b) is valid when a and b are instances of T and U.
|
* Trait which is true if the expression compare(a, b) is valid when a and b are instances of T and U.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename U, typename = void_t<>>
|
template <typename T, typename U, typename = void_t<>>
|
||||||
struct HasCompare : public std::false_type {};
|
struct THasCompare : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
struct HasCompare<T, U, void_t<decltype(compare(std::declval<T>(), std::declval<U>()))>> : public std::true_type {};
|
struct THasCompare<T, U, void_t<decltype(compare(std::declval<T>(), std::declval<U>()))>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -135,10 +135,10 @@ namespace BlackMisc
|
|||||||
* and i is an instance of CPropertyIndex.
|
* and i is an instance of CPropertyIndex.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct HasCompareByPropertyIndex : public std::false_type {};
|
struct THasCompareByPropertyIndex : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct HasCompareByPropertyIndex<T, void_t<decltype(std::declval<T>().compareByPropertyIndex(std::declval<CPropertyIndex>(), std::declval<T>()))>> : public std::true_type {};
|
struct THasCompareByPropertyIndex<T, void_t<decltype(std::declval<T>().compareByPropertyIndex(std::declval<CPropertyIndex>(), std::declval<T>()))>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -146,20 +146,20 @@ namespace BlackMisc
|
|||||||
* instance of CPropertyIndex.
|
* instance of CPropertyIndex.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = void_t<>>
|
template <typename T, typename = void_t<>>
|
||||||
struct HasPropertyByIndex : public std::false_type {};
|
struct THasPropertyByIndex : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct HasPropertyByIndex<T, void_t<decltype(std::declval<T>().propertyByIndex(std::declval<CPropertyIndex>()))>> : public std::true_type {};
|
struct THasPropertyByIndex<T, void_t<decltype(std::declval<T>().propertyByIndex(std::declval<CPropertyIndex>()))>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Trait which is true if the expression a == b is valid when a and b are instances of T and U.
|
* Trait which is true if the expression a == b is valid when a and b are instances of T and U.
|
||||||
*/
|
*/
|
||||||
template <typename T, typename U, typename = void_t<>>
|
template <typename T, typename U, typename = void_t<>>
|
||||||
struct IsEqualityComparable : public std::false_type {};
|
struct TIsEqualityComparable : public std::false_type {};
|
||||||
//! \cond
|
//! \cond
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
struct IsEqualityComparable<T, U, void_t<decltype(std::declval<T>() == std::declval<U>())>> : public std::true_type {};
|
struct TIsEqualityComparable<T, U, void_t<decltype(std::declval<T>() == std::declval<U>())>> : public std::true_type {};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ namespace BlackMisc
|
|||||||
//! Type of pointer to non-const member function of U taking no arguments and returning void,
|
//! Type of pointer to non-const member function of U taking no arguments and returning void,
|
||||||
//! for slot parameter of CCached constructor.
|
//! for slot parameter of CCached constructor.
|
||||||
template <typename U>
|
template <typename U>
|
||||||
using NotifySlot = Private::NonDeduced<void (U::*)()>;
|
using NotifySlot = Private::TNonDeduced<void (U::*)()>;
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
//! \param cache The CValueCache object which manages the value.
|
//! \param cache The CValueCache object which manages the value.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
|||||||
* \private Identity type trait.
|
* \private Identity type trait.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Identity
|
struct TIdentity
|
||||||
{
|
{
|
||||||
using type = T;
|
using type = T;
|
||||||
};
|
};
|
||||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
|||||||
* \private Trick to force a non-deduced context during template argument type deduction.
|
* \private Trick to force a non-deduced context during template argument type deduction.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using NonDeduced = typename Identity<T>::type;
|
using TNonDeduced = typename TIdentity<T>::type;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \private QObject subclass used by CCached<T> class template for signal/slot communication with CValueCache.
|
* \private QObject subclass used by CCached<T> class template for signal/slot communication with CValueCache.
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (metaTypeId == QMetaType::UnknownType) { return false; }
|
if (metaTypeId == QMetaType::UnknownType) { return false; }
|
||||||
if (metaTypeId == getMetaTypeId()) { return true; }
|
if (metaTypeId == getMetaTypeId()) { return true; }
|
||||||
return baseIsA(static_cast<const MetaBaseOfT<Derived> *>(derived()), metaTypeId);
|
return baseIsA(static_cast<const TMetaBaseOfT<Derived> *>(derived()), metaTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -176,8 +176,8 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
virtual const void *upCastTo(const void *object, int metaTypeId) const override
|
virtual const void *upCastTo(const void *object, int metaTypeId) const override
|
||||||
{
|
{
|
||||||
const auto base = static_cast<const void *>(static_cast<const MetaBaseOfT<T> *>(&cast(object)));
|
const auto base = static_cast<const void *>(static_cast<const TMetaBaseOfT<T> *>(&cast(object)));
|
||||||
return metaTypeId == getMetaTypeId() ? object : CValueObjectMetaInfo<MetaBaseOfT<T>> {} .upCastTo(base, metaTypeId);
|
return metaTypeId == getMetaTypeId() ? object : CValueObjectMetaInfo<TMetaBaseOfT<T>> {} .upCastTo(base, metaTypeId);
|
||||||
}
|
}
|
||||||
virtual int compareImpl(const void *lhs, const void *rhs) const override
|
virtual int compareImpl(const void *lhs, const void *rhs) const override
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user