diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-09-12 11:07:31 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-09-13 10:47:13 +0200 |
commit | 351c738fc4586bf354c9363fb78e190bdfca4617 (patch) | |
tree | c391ce693e00e4f61591a111c347623c4408115a /src/corelib | |
parent | 908e80d8bb79e703789084e7e9c5203ab66a755d (diff) |
QPointer: some simplifications
- don't write explicit meta functions, use std::conditional
- = default the default ctor
The class is already not trivially-copyable, so making the default
ctor trivial doesn't change the ABI.
Change-Id: I8e35bbbb35973c9ff8fc48dfbfc10061de4bfd30
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qpointer.h | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index 7052bcf0d4..5efdb0b395 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -54,20 +54,11 @@ class QPointer { Q_STATIC_ASSERT_X(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type"); - template<typename U> - struct TypeSelector - { - typedef QObject Type; - }; - template<typename U> - struct TypeSelector<const U> - { - typedef const QObject Type; - }; - typedef typename TypeSelector<T>::Type QObjectType; + using QObjectType = + typename std::conditional<std::is_const<T>::value, const QObject, QObject>::type; QWeakPointer<QObjectType> wp; public: - inline QPointer() { } + QPointer() = default; inline QPointer(T *p) : wp(p, true) { } // compiler-generated copy/move ctor/assignment operators are fine! // compiler-generated dtor is fine! |