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>
bb10
parent
f1c41382af
commit
d783363f60
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue