diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-14 10:35:31 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-15 12:18:06 +0000 |
commit | 3486c7cab45ac0060bfc1dee3f92e723a8731446 (patch) | |
tree | 429286b0b9f2e17a52340e85eda74a4560b7404b /src/lib/corelib/tools | |
parent | 410740fc0ea11a78e2fd6d934f2ff79e2fbb3fb8 (diff) |
Simplify some templates
... using C++14's "_t" typedef.
Change-Id: I908c5a8005d40bfed4b457cb250ecc38ed959a18
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/tools')
-rw-r--r-- | src/lib/corelib/tools/persistence.h | 21 | ||||
-rw-r--r-- | src/lib/corelib/tools/set.h | 2 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h index 923d5b059..9aec8eff9 100644 --- a/src/lib/corelib/tools/persistence.h +++ b/src/lib/corelib/tools/persistence.h @@ -194,8 +194,7 @@ template <class T> inline std::shared_ptr<T> PersistentPool::idLoadS() /***** Specializations of Helper class *****/ -template<typename T> -struct PersistentPool::Helper<T, typename std::enable_if<std::is_integral<T>::value>::type> +template<typename T> struct PersistentPool::Helper<T, std::enable_if_t<std::is_integral<T>::value>> { static void store(const T &value, PersistentPool *pool) { pool->m_stream << value; } static void load(T &value, PersistentPool *pool) { pool->m_stream >> value; } @@ -213,8 +212,8 @@ template<> struct PersistentPool::Helper<long> }; template<typename T> -struct PersistentPool::Helper<T, typename std::enable_if<std::is_same<T, std::time_t>::value - && !std::is_same<T, long>::value>::type> +struct PersistentPool::Helper<T, std::enable_if_t<std::is_same<T, std::time_t>::value + && !std::is_same<T, long>::value>> { static void store(std::time_t value, PersistentPool *pool) { pool->m_stream << qint64(value); } static void load(std::time_t &value, PersistentPool *pool) @@ -225,10 +224,9 @@ struct PersistentPool::Helper<T, typename std::enable_if<std::is_same<T, std::ti } }; -template<typename T> -struct PersistentPool::Helper<T, typename std::enable_if<std::is_enum<T>::value>::type> +template<typename T> struct PersistentPool::Helper<T, std::enable_if_t<std::is_enum<T>::value>> { - using U = typename std::underlying_type<T>::type; + using U = std::underlying_type_t<T>; static void store(const T &value, PersistentPool *pool) { pool->m_stream << static_cast<U>(value); @@ -247,7 +245,7 @@ template<typename T> struct PersistentPool::Helper<std::shared_ptr<T>> } static void load(std::shared_ptr<T> &value, PersistentPool *pool) { - value = pool->idLoadS<typename std::remove_const<T>::type>(); + value = pool->idLoadS<std::remove_const_t<T>>(); } }; @@ -259,7 +257,7 @@ template<typename T> struct PersistentPool::Helper<std::unique_ptr<T>> } static void load(std::unique_ptr<T> &ptr, PersistentPool *pool) { - ptr.reset(pool->idLoad<typename std::remove_const<T>::type>()); + ptr.reset(pool->idLoad<std::remove_const_t<T>>()); } }; @@ -340,8 +338,7 @@ template<> struct IsSimpleContainer<QStringList> : std::true_type { }; template<typename T> struct IsSimpleContainer<QList<T>> : std::true_type { }; template<typename T> struct IsSimpleContainer<std::vector<T>> : std::true_type { }; -template<typename T> -struct PersistentPool::Helper<T, typename std::enable_if<IsSimpleContainer<T>::value>::type> +template<typename T> struct PersistentPool::Helper<T, std::enable_if_t<IsSimpleContainer<T>::value>> { static void store(const T &container, PersistentPool *pool) { @@ -364,7 +361,7 @@ template<typename K, typename V> struct IsKeyValueContainer<QMap<K, V>> : std::t template<typename K, typename V> struct IsKeyValueContainer<QHash<K, V>> : std::true_type { }; template<typename T> -struct PersistentPool::Helper<T, typename std::enable_if<IsKeyValueContainer<T>::value>::type> +struct PersistentPool::Helper<T, std::enable_if_t<IsKeyValueContainer<T>::value>> { static void store(const T &container, PersistentPool *pool) { diff --git a/src/lib/corelib/tools/set.h b/src/lib/corelib/tools/set.h index 8301246eb..322074b0d 100644 --- a/src/lib/corelib/tools/set.h +++ b/src/lib/corelib/tools/set.h @@ -353,7 +353,7 @@ template<typename T> template<typename U> Set<T> Set<T>::filtered(const Set<U> & static_assert(std::is_pointer<U>::value, "Set::filtered() assumes pointer types"); Set<T> filteredSet; for (auto &u : s) { - if (hasDynamicType<typename std::remove_pointer<T>::type>(u)) + if (hasDynamicType<std::remove_pointer_t<T>>(u)) filteredSet.m_data.push_back(static_cast<T>(u)); } return filteredSet; |