[telepathy-qt4/master] shared-ptr: Added WeakPtr::toStrongRef that returns a SharedPtr from a WeakPtr.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue Apr 7 06:10:23 PDT 2009


Rationale (Jonathon Jongsma):
You also might consider something like the boost::weak_ptr::lock() API that
allows you to easily create a SharedPtr from a WeakPtr.

Added "lock" idea but using Qt idiom, as used in QWeakPointer.
---
 TelepathyQt4/shared-ptr.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/shared-ptr.h b/TelepathyQt4/shared-ptr.h
index 61ce2f4..9f87a9d 100644
--- a/TelepathyQt4/shared-ptr.h
+++ b/TelepathyQt4/shared-ptr.h
@@ -185,6 +185,8 @@ public:
         return *this;
     }
 
+    SharedPtr<T> toStrongRef() const { return SharedPtr<T>(*this); }
+
 private:
     friend class SharedPtr<T>;
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list