summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-10-02 15:39:17 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-10-04 15:09:32 +0200
commitf21ecb5657ee679f4c988de1bcd8d66b32952dec (patch)
tree63945085db454b1006a726966d426dbc696188a4 /src/corelib
parent191eb076a9b3f54b50d8c6d50039c59c03ae0483 (diff)
Simplify creating QCFTypes from CFTypeRefs
Instead of forcing the user to cast: QCFType<CFFooRef> foo = (CFFooRef)CFFunctionReturningCFTypeRef()); We can do it for them, since we already know the expected type: auto foo = QCFType<CFFooRef>(CFFunctionReturningCFTypeRef)); Change-Id: I994d5d6530f220288b4bfd6ab16eae9f159ce3ef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qcore_mac_p.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index d03e2f3738..535d3579b2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -137,8 +137,10 @@ private:
template <typename T>
class QCFType : public QAppleRefCounted<T, CFTypeRef, CFRetain, CFRelease>
{
+ using Base = QAppleRefCounted<T, CFTypeRef, CFRetain, CFRelease>;
public:
- using QAppleRefCounted<T, CFTypeRef, CFRetain, CFRelease>::QAppleRefCounted;
+ using Base::Base;
+ explicit QCFType(CFTypeRef r) : Base(static_cast<T>(r)) {}
template <typename X> X as() const { return reinterpret_cast<X>(this->value); }
static QCFType constructFromGet(const T &t)
{
@@ -151,6 +153,7 @@ public:
class Q_CORE_EXPORT QCFString : public QCFType<CFStringRef>
{
public:
+ using QCFType<CFStringRef>::QCFType;
inline QCFString(const QString &str) : QCFType<CFStringRef>(0), string(str) {}
inline QCFString(const CFStringRef cfstr = 0) : QCFType<CFStringRef>(cfstr) {}
inline QCFString(const QCFType<CFStringRef> &other) : QCFType<CFStringRef>(other) {}