mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Use std::bool_constant (C++17 feature)
This commit is contained in:
@@ -116,7 +116,7 @@ namespace BlackMisc
|
||||
{
|
||||
CLogCategoryList list;
|
||||
list.appendCategoriesFromMemberFunction(tag<T>(), THasGetLogCategories<T>());
|
||||
list.appendCategoriesFromMetaType(tag<T>(), std::integral_constant<bool, QMetaTypeId<T>::Defined>());
|
||||
list.appendCategoriesFromMetaType(tag<T>(), std::bool_constant<QMetaTypeId<T>::Defined>());
|
||||
list.appendCategoriesFromMetaObject(tag<T>(), std::is_base_of<QObject, T>());
|
||||
if (list.isEmpty()) { list.push_back(CLogCategories::uncategorized()); }
|
||||
return list;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace BlackMisc
|
||||
struct MetaFlags : public std::integral_constant<quint64, F>
|
||||
{
|
||||
//! Implicit conversion to std::false_type (if F is zero) or std::true_type (if F is non-zero).
|
||||
constexpr operator std::integral_constant<bool, static_cast<bool>(F)>() const { return {}; }
|
||||
constexpr operator std::bool_constant<static_cast<bool>(F)>() const { return {}; }
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace BlackMisc
|
||||
template <typename T, typename Flags>
|
||||
static bool membersEqual(const T &a, const T &b, Flags)
|
||||
{
|
||||
return membersEqual(a, b, std::integral_constant<bool, static_cast<bool>(Flags::value & CaseInsensitiveComparison)>());
|
||||
return membersEqual(a, b, std::bool_constant<static_cast<bool>(Flags::value & CaseInsensitiveComparison)>());
|
||||
}
|
||||
template <typename T>
|
||||
static bool membersEqual(const T &a, const T &b, std::true_type) { return a.compare(b, Qt::CaseInsensitive) == 0; }
|
||||
@@ -135,7 +135,7 @@ namespace BlackMisc
|
||||
template <typename T, typename Flags>
|
||||
static bool membersLess(bool &io_greaterThan, const T &a, const T &b, Flags)
|
||||
{
|
||||
using CaseInsensitive = std::integral_constant<bool, static_cast<bool>(Flags::value & CaseInsensitiveComparison)>;
|
||||
using CaseInsensitive = std::bool_constant<static_cast<bool>(Flags::value & CaseInsensitiveComparison)>;
|
||||
if (io_greaterThan) { return false; }
|
||||
io_greaterThan = membersLess(b, a, CaseInsensitive());
|
||||
return membersLess(a, b, CaseInsensitive());
|
||||
@@ -171,7 +171,7 @@ namespace BlackMisc
|
||||
template <typename T, typename 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::bool_constant<static_cast<bool>(Flags::value & CaseInsensitiveComparison)>;
|
||||
return membersCompare(a, b, CaseInsensitive(), THasCompare<T, T>());
|
||||
}
|
||||
template <typename T, typename U>
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace BlackMisc
|
||||
constexpr auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
||||
meta.forEachMember([ &, this ](auto member)
|
||||
{
|
||||
using lossless = std::integral_constant<bool, member.has(MetaFlags<LosslessMarshalling>())>;
|
||||
using lossless = std::bool_constant<member.has(MetaFlags<LosslessMarshalling>())>;
|
||||
Private::marshallMember(arg, member.in(*this->derived()), lossless());
|
||||
});
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace BlackMisc
|
||||
constexpr auto meta = introspect<Derived>().without(MetaFlags<DisabledForMarshalling>());
|
||||
meta.forEachMember([ &, this ](auto member)
|
||||
{
|
||||
using lossless = std::integral_constant<bool, member.has(MetaFlags<LosslessMarshalling>())>;
|
||||
using lossless = std::bool_constant<member.has(MetaFlags<LosslessMarshalling>())>;
|
||||
Private::unmarshallMember(arg, member.in(*this->derived()), lossless());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace BlackMisc
|
||||
}
|
||||
virtual int getMetaTypeId() const override
|
||||
{
|
||||
return maybeGetMetaTypeId(std::integral_constant<bool, QMetaTypeId<T>::Defined> {});
|
||||
return maybeGetMetaTypeId(std::bool_constant<QMetaTypeId<T>::Defined> {});
|
||||
}
|
||||
virtual const void *upCastTo(const void *object, int metaTypeId) const override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user