diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-28 00:21:27 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-28 22:00:21 +0100 |
commit | 1cb192bf3da88c97e7622d4813053a4ca916044e (patch) | |
tree | 971505172b67cecc6c3831b651f1461888f304da /src/corelib/tools/qflatmap_p.h | |
parent | 77923604130057261bf774b5cc32d849a595a1f0 (diff) |
QFlatMap: replace manual const_cast<>s with std::as_const
Shorter, because it doesn't need to name the type.
As a drive-by, replace all remaining uses of the private full_map_t
alias with 'QFlatMap', the class name, which, also in templates,
refers to the class, not the class template.
Pick-to: 6.3 6.2
Change-Id: Ie3bada43d9d28a84543e8baa8a36c522dff80b9e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib/tools/qflatmap_p.h')
-rw-r--r-- | src/corelib/tools/qflatmap_p.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index 17c6167ddf..acfcf5e778 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -111,8 +111,6 @@ class QFlatMap : private QFlatMapValueCompare<Key, T, Compare> { static_assert(std::is_nothrow_destructible_v<T>, "Types with throwing destructors are not supported in Qt containers."); - using full_map_t = QFlatMap<Key, T, Compare, KeyContainer, MappedContainer>; - template <class U> class mock_pointer { @@ -274,7 +272,7 @@ public: private: containers *c = nullptr; size_type i = 0; - friend full_map_t; + friend QFlatMap; }; class const_iterator @@ -411,7 +409,7 @@ public: private: const containers *c = nullptr; size_type i = 0; - friend full_map_t; + friend QFlatMap; }; private: @@ -790,14 +788,14 @@ public: iterator lower_bound(const Key &key) { - auto cit = const_cast<const full_map_t *>(this)->lower_bound(key); + auto cit = std::as_const(*this).lower_bound(key); return { &c, cit.i }; } template <class X, class Y = Compare, is_marked_transparent<Y> = nullptr> iterator lower_bound(const X &key) { - auto cit = const_cast<const full_map_t *>(this)->lower_bound(key); + auto cit = std::as_const(*this).lower_bound(key); return { &c, cit.i }; } @@ -880,7 +878,7 @@ private: class IndexedKeyComparator { public: - IndexedKeyComparator(const full_map_t *am) + IndexedKeyComparator(const QFlatMap *am) : m(am) { } @@ -891,7 +889,7 @@ private: } private: - const full_map_t *m; + const QFlatMap *m; }; template <class InputIt> @@ -914,7 +912,7 @@ private: iterator binary_find(const Key &key) { - return { &c, const_cast<const full_map_t *>(this)->binary_find(key).i }; + return { &c, std::as_const(*this).binary_find(key).i }; } const_iterator binary_find(const Key &key) const |