src/core/ptr.h
changeset 544 cbc4158d47c9
parent 543 a730800a31d5
child 567 6fb98941c36f
--- a/src/core/ptr.h	Wed May 09 13:26:21 2007 -0400
+++ b/src/core/ptr.h	Wed May 09 19:48:33 2007 +0200
@@ -72,7 +72,23 @@
   Ptr (Ptr<U> const &o);
   ~Ptr () ;
   Ptr<T> &operator = (Ptr const& o);
-  T const& Peek () const;
+
+  /**
+   * \return the pointer managed by this smart pointer.
+   *
+   * The underlying refcount is not incremented prior
+   * to returning to the caller so the caller is not
+   * responsible for calling Unref himself.
+   */
+  T * Peek () const;
+
+  /**
+   * \return the pointer managed by this smart pointer.
+   *
+   * The underlying refcount is incremented prior
+   * to returning to the caller so the caller is
+   * responsible for calling Unref himself.
+   */
   T * Get () const;
   T *operator -> () const;
   T *operator -> ();
@@ -97,20 +113,6 @@
   inline friend Ptr<T1> const_pointer_cast (Ptr<T2> const&p);
 
 
-  /**
-   * \returns raw pointer
-   *
-   * It is a programming error to invoke this method when
-   * the reference count of the smart pointer is not one.
-   * If you try to do it anyway, an assert will be triggered.
-   * If asserts are disabled, bad things will happen.
-   * Once you have successfully called Ptr<T>::Remove on
-   * a smart pointer, the smart pointer will forget 
-   * about the raw pointer and will stop managing it. As such,
-   * you, as the caller, become responsible for invoking
-   * operator delete on the returned raw pointer.
-   */
-  T *Remove (void);
 };
 
 template <typename T>
@@ -172,10 +174,10 @@
 }
 
 template <typename T>
-T const& 
+T *
 Ptr<T>::Peek () const
 {
-  return *m_ptr;
+  return m_ptr;
 }
 
 template <typename T>
@@ -218,23 +220,6 @@
   return &test;
 }
 
-template <typename T>
-T *
-Ptr<T>::Remove (void) 
-{
-  if (m_ptr == 0)
-    {
-      return (T *) 0;
-    }
-  else
-    {
-      //NS_ASSERT (m_ptr->IsSingle());
-      T *retval = m_ptr;
-      m_ptr = 0;
-      return retval;
-    }
-}
-
 // non-member friend functions.
 template <typename T1, typename T2>
 bool