From a8fc89921917b91ab18337ad42974dca2300dd95 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sun, 20 Mar 2016 21:50:41 +0000 Subject: [PATCH] refs #624 Use std alias traits. --- src/blackmisc/atomicfile.cpp | 2 +- src/blackmisc/dbus.h | 4 ++-- src/blackmisc/inheritancetraits.h | 8 ++++---- src/blackmisc/iterator.h | 16 ++++++++-------- src/blackmisc/json.h | 12 ++++++------ src/blackmisc/lockfree.h | 2 +- src/blackmisc/logcategorylist.h | 2 +- src/blackmisc/propertyindexvariantmap.h | 8 ++++---- src/blackmisc/range.h | 2 +- src/blackmisc/statusmessage.h | 2 +- src/blackmisc/tuple.h | 2 +- src/blackmisc/tupleprivate.h | 18 +++++++++--------- src/blackmisc/valueobject.h | 2 +- src/blackmisc/variant.h | 4 ++-- src/blackmisc/variantprivate.h | 2 +- src/blackmisc/worker.h | 4 ++-- src/xbus/menus.cpp | 4 ++-- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/blackmisc/atomicfile.cpp b/src/blackmisc/atomicfile.cpp index 41948010b..11fe048ed 100644 --- a/src/blackmisc/atomicfile.cpp +++ b/src/blackmisc/atomicfile.cpp @@ -74,7 +74,7 @@ namespace BlackMisc QString CAtomicFile::randomSuffix() { constexpr auto max = 2176782335; - return QString::number(std::uniform_int_distribution::type>(0, max)(Private::defaultRandomGenerator()), 36); + return QString::number(std::uniform_int_distribution>(0, max)(Private::defaultRandomGenerator()), 36); } #if defined(Q_OS_POSIX) diff --git a/src/blackmisc/dbus.h b/src/blackmisc/dbus.h index fd757eb56..d59a34b36 100644 --- a/src/blackmisc/dbus.h +++ b/src/blackmisc/dbus.h @@ -100,7 +100,7 @@ namespace BlackMisc /*! * Operator for streaming enums to QDBusArgument. */ -template ::value, int>::type = 0> +template ::value, int> = 0> QDBusArgument &operator <<(QDBusArgument &arg, const E &value) { arg.beginStructure(); @@ -112,7 +112,7 @@ QDBusArgument &operator <<(QDBusArgument &arg, const E &value) /*! * Operator for streaming enums from QDBusArgument. */ -template ::value, int>::type = 0> +template ::value, int> = 0> const QDBusArgument &operator >>(const QDBusArgument &arg, E &value) { int temp; diff --git a/src/blackmisc/inheritancetraits.h b/src/blackmisc/inheritancetraits.h index 0c5f87a00..ad3568a3a 100644 --- a/src/blackmisc/inheritancetraits.h +++ b/src/blackmisc/inheritancetraits.h @@ -26,12 +26,12 @@ namespace BlackMisc class BaseOf { //template static typename U::base_type *test(int); - template static typename U::base_type *test(typename std::enable_if::value, int>::type); + template static typename U::base_type *test(std::enable_if_t::value, int>); template static void *test(...); public: //! The declared base_type of T, or void if there is none. - typedef typename std::remove_pointer(0))>::type type; + using type = std::remove_pointer_t(0))>; }; /*! @@ -42,7 +42,7 @@ namespace BlackMisc { public: //! Type of T::base_type, or void if not declared. - typedef typename std::conditional::type>::Defined, typename BaseOf::type, void>::type type; + using type = std::conditional_t::type>::Defined, typename BaseOf::type, void>; }; /*! @@ -55,7 +55,7 @@ namespace BlackMisc struct Empty {}; struct Fallback { int propertyByIndex; }; template struct int_t { typedef int type; }; - template struct Derived : public Fallback, public std::conditional::value, Empty, U>::type {}; + template struct Derived : public Fallback, public std::conditional_t::value, Empty, U> {}; template static void test(typename int_t<&Derived::propertyByIndex>::type); template static U test(...); diff --git a/src/blackmisc/iterator.h b/src/blackmisc/iterator.h index b2902e346..64fe86d1b 100644 --- a/src/blackmisc/iterator.h +++ b/src/blackmisc/iterator.h @@ -32,7 +32,7 @@ namespace BlackMisc * By creating a CRange from such iterators, it is possible to create a container of keys without copying them. */ template class KeyIterator - : public std::iterator().key())>::type> + : public std::iterator().key())>> { public: //! Constructor @@ -81,7 +81,7 @@ namespace BlackMisc */ template class TransformIterator : public std::iterator()(std::declval::value_type>()))>::type> + std::decay_t()(std::declval::value_type>()))>> { public: //! The type returned by the transformation function, which may or may not be a reference. @@ -90,17 +90,17 @@ namespace BlackMisc //! \private A pointer-like wrapper returned by the arrow operator if the transformation function returns by value. struct PointerWrapper { - PointerWrapper(typename std::decay::type *obj) : m_obj(std::move(*obj)) {} - typename std::decay::type const *operator ->() const { return &m_obj; } - typename std::decay::type operator *() const & { return m_obj; } - typename std::decay::type operator *() && { return std::move(m_obj); } + PointerWrapper(std::decay_t *obj) : m_obj(std::move(*obj)) {} + std::decay_t const *operator ->() const { return &m_obj; } + std::decay_t operator *() const & { return m_obj; } + std::decay_t operator *() && { return std::move(m_obj); } private: - const typename std::decay::type m_obj; + const std::decay_t m_obj; }; //! The type returned by this iterator's arrow operator, which may be a pointer or a pointer-like wrapper object using pointer = typename std::conditional::value, - typename std::remove_reference::type *, + std::remove_reference_t *, PointerWrapper>::type; //! Constructor. diff --git a/src/blackmisc/json.h b/src/blackmisc/json.h index e8f209051..792f89a45 100644 --- a/src/blackmisc/json.h +++ b/src/blackmisc/json.h @@ -63,8 +63,8 @@ BLACKMISC_EXPORT const QJsonValueRef &operator >>(const QJsonValueRef &json, QBy //! \brief Specialized JSON serialization for enum //! \remarks needs to be in global namespace //! \ingroup JSON -template typename -std::enable_if::value, QJsonObject>::type +template +std::enable_if_t::value, QJsonObject> &operator<<(QJsonObject &json, std::pair value) { json.insert(value.first, QJsonValue(static_cast(value.second))); @@ -73,8 +73,8 @@ std::enable_if::value, QJsonObject>::type //! \brief Specialized JSON deserialization for enum //! \ingroup JSON -template typename -std::enable_if::value, QJsonValue>::type +template +std::enable_if_t::value, QJsonValue> const &operator>>(const QJsonValue &json, ENUM &value) { value = static_cast(json.toInt()); @@ -83,8 +83,8 @@ const &operator>>(const QJsonValue &json, ENUM &value) //! \brief Specialized JSON deserialization for enum //! \ingroup JSON -template typename -std::enable_if::value, QJsonValueRef>::type +template +std::enable_if_t::value, QJsonValueRef> const &operator>>(const QJsonValueRef &json, ENUM &value) { value = static_cast(json.toInt()); diff --git a/src/blackmisc/lockfree.h b/src/blackmisc/lockfree.h index 56252939f..aee873681 100644 --- a/src/blackmisc/lockfree.h +++ b/src/blackmisc/lockfree.h @@ -91,7 +91,7 @@ namespace BlackMisc LockFreeReader &operator =(const LockFreeReader &) = default; private: - friend class LockFree::type>; + friend class LockFree>; LockFreeReader(std::shared_ptr ptr) : m_ptr(ptr) {} std::shared_ptr m_ptr; diff --git a/src/blackmisc/logcategorylist.h b/src/blackmisc/logcategorylist.h index 18be5eead..d772cb697 100644 --- a/src/blackmisc/logcategorylist.h +++ b/src/blackmisc/logcategorylist.h @@ -76,7 +76,7 @@ namespace BlackMisc * \param pointer The value of pointer is unimportant. Only the static type T is considered. * It is legal to pass static_cast(nullptr), but in member functions passing the this pointer is easier. */ - template ::value>::type> + template ::value>> CLogCategoryList(const T *pointer) : CLogCategoryList(fromClass()) { Q_UNUSED(pointer); } //! Convert each of the categories to a QString and return the result as a QStringList. diff --git a/src/blackmisc/propertyindexvariantmap.h b/src/blackmisc/propertyindexvariantmap.h index 29dacc57d..94172d9d0 100644 --- a/src/blackmisc/propertyindexvariantmap.h +++ b/src/blackmisc/propertyindexvariantmap.h @@ -66,14 +66,14 @@ namespace BlackMisc const Derived *derived() const { return static_cast(this); } Derived *derived() { return static_cast(this); } - template ::value, int>::type = 0> + template ::value, int> = 0> CVariant myself() const { return CVariant::from(*derived()); } - template ::value, int>::type = 0> + template ::value, int> = 0> void myself(const CVariant &variant) { *derived() = variant.to(); } - template ::value, int>::type = 0> + template ::value, int> = 0> CVariant myself() const { qFatal("isMyself should have been handled before reaching here"); return {}; } - template ::value, int>::type = 0> + template ::value, int> = 0> void myself(const CVariant &) { qFatal("isMyself should have been handled before reaching here"); } template diff --git a/src/blackmisc/range.h b/src/blackmisc/range.h index ed09052a2..c008633a3 100644 --- a/src/blackmisc/range.h +++ b/src/blackmisc/range.h @@ -45,7 +45,7 @@ namespace BlackMisc */ //! @{ template - constexpr typename std::add_const::type &as_const(T &v) noexcept { return v; } + constexpr std::add_const_t &as_const(T &v) noexcept { return v; } template void as_const(const T &&) = delete; //! @} diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index f0f754e89..d677d7b48 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -119,7 +119,7 @@ namespace BlackMisc Derived &operator <<(QChar v) { return arg(v); } Derived &operator <<(char v) { return arg(QChar(v)); } Derived &operator <<(double v) { return arg(QString::number(v)); } - template ::value>::type> + template ::value>> Derived &operator <<(const T &v) { return arg(v.toQString()); } //! @} diff --git a/src/blackmisc/tuple.h b/src/blackmisc/tuple.h index 656faffce..7e32d72c3 100644 --- a/src/blackmisc/tuple.h +++ b/src/blackmisc/tuple.h @@ -217,7 +217,7 @@ namespace BlackMisc void extendMetaTuple(Tu &&tu) const { Private::extendMeta(std::forward(tu), m_names, - Private::make_index_sequence::type>::value>()); + Private::make_index_sequence>::value>()); } }; }; diff --git a/src/blackmisc/tupleprivate.h b/src/blackmisc/tupleprivate.h index eb4f65c6f..94274d839 100644 --- a/src/blackmisc/tupleprivate.h +++ b/src/blackmisc/tupleprivate.h @@ -42,7 +42,7 @@ namespace BlackMisc template static auto toMetaTuple(T &o) { - return TupleConverter::type>::toMetaTuple(o); + return TupleConverter>::toMetaTuple(o); } }; @@ -107,24 +107,24 @@ namespace BlackMisc { typedef Tu tuple_type; template - struct test : std::integral_constant::type::flags & F)> {}; + struct test : std::integral_constant::flags & F)> {}; }; template struct FlagMissing { typedef Tu tuple_type; template - struct test : std::integral_constant::type::flags & F)> {}; + struct test : std::integral_constant::flags & F)> {}; }; // Combine make_index_sequence_if with predicates to get the indices of tuple elements with certain flags. template - auto findFlaggedIndices(Tu &&) -> make_index_sequence_if::type>> + auto findFlaggedIndices(Tu &&) -> make_index_sequence_if>> { return {}; } template - auto skipFlaggedIndices(Tu &&) -> make_index_sequence_if::type>> + auto skipFlaggedIndices(Tu &&) -> make_index_sequence_if>> { return {}; } @@ -318,9 +318,9 @@ namespace BlackMisc marshallHelper(arg, head, 0); marshallImpl(arg, tail...); } - template ::value, int>::type = 0> + template ::value, int> = 0> static void marshallHelper(QDBusArgument &arg, const T &val, int) { static_cast(val).marshallToDbus(arg); } - template ::value, int>::type = 0> + template ::value, int> = 0> static void marshallHelper(QDBusArgument &arg, const T &val, int) { arg << static_cast(val); } template static void marshallHelper(QDBusArgument &arg, const T &val, ...) { arg << val; } @@ -332,9 +332,9 @@ namespace BlackMisc unmarshallHelper(arg, head, 0); unmarshallImpl(arg, tail...); } - template ::value, int>::type = 0> + template ::value, int> = 0> static void unmarshallHelper(const QDBusArgument &arg, T &val, int) { static_cast(val).unmarshallFromDbus(arg); } - template ::value, int>::type = 0> + template ::value, int> = 0> static void unmarshallHelper(const QDBusArgument &arg, T &val, int) { int i; arg >> i; val = static_cast(i); } template static void unmarshallHelper(const QDBusArgument &arg, T &val, ...) { arg >> val; } diff --git a/src/blackmisc/valueobject.h b/src/blackmisc/valueobject.h index daca49282..c4dd2a873 100644 --- a/src/blackmisc/valueobject.h +++ b/src/blackmisc/valueobject.h @@ -47,7 +47,7 @@ namespace BlackMisc //! \private template struct DecayFirst { - typedef typename std::decay::type type; + using type = std::decay_t; }; } diff --git a/src/blackmisc/variant.h b/src/blackmisc/variant.h index c20658b28..543a56718 100644 --- a/src/blackmisc/variant.h +++ b/src/blackmisc/variant.h @@ -182,14 +182,14 @@ namespace BlackMisc //! Construct a variant from a value. template static CVariant fromValue(T &&value) { - static_assert(!std::is_same::type>::value, "CVariant is an illegal type!"); + static_assert(!std::is_same>::value, "CVariant is an illegal type!"); return CVariant(QVariant::fromValue(std::forward(value))); } //! Synonym for fromValue(). template static CVariant from(T &&value) { - static_assert(!std::is_same::type>::value, "CVariant is an illegal type!"); + static_assert(!std::is_same>::value, "CVariant is an illegal type!"); return CVariant(QVariant::fromValue(std::forward(value))); } diff --git a/src/blackmisc/variantprivate.h b/src/blackmisc/variantprivate.h index b36953665..ea7236e9b 100644 --- a/src/blackmisc/variantprivate.h +++ b/src/blackmisc/variantprivate.h @@ -140,7 +140,7 @@ namespace BlackMisc template static bool equalsPropertyByIndexHelper(const U &object, const CVariant &, const CPropertyIndex &, DISABLE_IF_HAS(equalsPropertyByIndex)) { throw CVariantException(object, "equalsPropertyByIndex"); } template static bool equalsPropertyByIndexHelper(const U &object, const CVariant &variant, const CPropertyIndex &index, ...) { return object.equalsPropertyByIndex(variant, index); } template static void toIconHelper(const U &object, CIcon &, DISABLE_IF_HAS(toIcon)) { throw CVariantException(object, "toIcon"); } - template static void toIconHelper(const U &object, CIcon &, typename std::enable_if::value, int>::type) { throw CVariantException(object, "toIcon"); } // CIcon is incomplete when CValueObjectMetaInfo is instantiated + template static void toIconHelper(const U &object, CIcon &, std::enable_if_t::value, int>) { throw CVariantException(object, "toIcon"); } // CIcon is incomplete when CValueObjectMetaInfo is instantiated template static void toIconHelper(const U &object, CIcon &o_icon, ...) { assign(o_icon, object.toIcon()); } # undef DISABLE_IF_HAS diff --git a/src/blackmisc/worker.h b/src/blackmisc/worker.h index b179f1044..0fd6fde16 100644 --- a/src/blackmisc/worker.h +++ b/src/blackmisc/worker.h @@ -187,14 +187,14 @@ namespace BlackMisc //! Uniform way to invoke either a functor or a method. template - static auto invoke(T *object, F func, Ts &&... args) -> typename std::enable_if::value>::type + static auto invoke(T *object, F func, Ts &&... args) -> std::enable_if_t::value> { return (object->*func)(std::forward(args)...); } //! Uniform way to invoke either a functor or a method. template - static auto invoke(T *, F func, Ts &&... args) -> typename std::enable_if::value>::type + static auto invoke(T *, F func, Ts &&... args) -> std::enable_if_t::value> { return func(std::forward(args)...); } diff --git a/src/xbus/menus.cpp b/src/xbus/menus.cpp index e11b4d85c..25f16cf92 100644 --- a/src/xbus/menus.cpp +++ b/src/xbus/menus.cpp @@ -20,7 +20,7 @@ namespace XBus template void *voidptr_cast(T i) { static_assert(std::is_integral::value, "voidptr_cast expects an integer"); - typedef typename std::conditional::value, intptr_t, uintptr_t>::type intptr_type; + using intptr_type = std::conditional_t::value, intptr_t, uintptr_t>; return reinterpret_cast(static_cast(i)); } @@ -28,7 +28,7 @@ namespace XBus template T intptr_cast(void *p) { static_assert(std::is_integral::value, "voidptr_cast returns an integer"); - typedef typename std::conditional::value, intptr_t, uintptr_t>::type intptr_type; + using intptr_type = std::conditional_t::value, intptr_t, uintptr_t>; return static_cast(reinterpret_cast(p)); }