summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-11-08 10:53:11 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-11-19 20:02:59 +0000
commitd783363f60173f1bc6525f1a8bbbd87f1e3afc1d (patch)
tree6014d50cb1ee16aeaff9668bf00d901e2c89a5f4 /src
parentf1c41382af0fd3e769b5792891b204ebeecd3bd2 (diff)
QFlatMap: make nested mock_object SCARY
Swap the definition of the nested mock_object out of the QFlatMap body into a namespace scope and replace it with a template alias. This way, there's _one_ mock_object<U> for every U, not one for every QFlatMap<K, V, Comp, KeyC, ValueC>::mock_object<U> ("SCARY"). Should reduce compile times, but I didn't measure. Change-Id: I37f7413a49d0424e06ef4e78d65dea5962599e79 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qflatmap_p.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h
index ba02503d2b..6937d21544 100644
--- a/src/corelib/tools/qflatmap_p.h
+++ b/src/corelib/tools/qflatmap_p.h
@@ -83,6 +83,24 @@ public:
}
};
+namespace detail {
+template <class T>
+class QFlatMapMockPointer
+{
+ T ref;
+public:
+ QFlatMapMockPointer(T r)
+ : ref(r)
+ {
+ }
+
+ T *operator->()
+ {
+ return &ref;
+ }
+};
+} // namespace detail
+
template<class Key, class T, class Compare = std::less<Key>, class KeyContainer = QList<Key>,
class MappedContainer = QList<T>>
class QFlatMap : private QFlatMapValueCompare<Key, T, Compare>
@@ -90,21 +108,7 @@ 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.");
template <class U>
- class mock_pointer
- {
- U ref;
- public:
- mock_pointer(U r)
- : ref(r)
- {
- }
-
- U *operator->()
- {
- return &ref;
- }
- };
-
+ using mock_pointer = detail::QFlatMapMockPointer<U>;
public:
using key_type = Key;
using mapped_type = T;