From f21ecb5657ee679f4c988de1bcd8d66b32952dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 2 Oct 2019 15:39:17 +0200 Subject: [PATCH] Simplify creating QCFTypes from CFTypeRefs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of forcing the user to cast: QCFType foo = (CFFooRef)CFFunctionReturningCFTypeRef()); We can do it for them, since we already know the expected type: auto foo = QCFType(CFFunctionReturningCFTypeRef)); Change-Id: I994d5d6530f220288b4bfd6ab16eae9f159ce3ef Reviewed-by: Thiago Macieira Reviewed-by: Tor Arne Vestbø --- src/corelib/kernel/qcore_mac_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index d03e2f37380..535d3579b29 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -137,8 +137,10 @@ private: template class QCFType : public QAppleRefCounted { + using Base = QAppleRefCounted; public: - using QAppleRefCounted::QAppleRefCounted; + using Base::Base; + explicit QCFType(CFTypeRef r) : Base(static_cast(r)) {} template X as() const { return reinterpret_cast(this->value); } static QCFType constructFromGet(const T &t) { @@ -151,6 +153,7 @@ public: class Q_CORE_EXPORT QCFString : public QCFType { public: + using QCFType::QCFType; inline QCFString(const QString &str) : QCFType(0), string(str) {} inline QCFString(const CFStringRef cfstr = 0) : QCFType(cfstr) {} inline QCFString(const QCFType &other) : QCFType(other) {}