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>
bb10
Marc Mutz 2022-01-28 00:21:27 +01:00
parent 7792360413
commit 1cb192bf3d
1 changed files with 7 additions and 9 deletions

View File

@ -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