Logo Search packages:      
Sourcecode: znc version File versions

template<typename T>
CSmartPtr<T>& CSmartPtr< T >::Attach ( T *  pRawPtr  )  [inline]

Attach to a given raw pointer, it will Release() the current raw pointer and assign the new one.

Parameters:
pRawPtr The raw pointer to keep track of, ***WARNING*** Do _NOT_ allow more than one CSmartPtr keep track of the same raw pointer
Returns:
Reference to self

Definition at line 541 of file Utils.h.

Referenced by CSmartPtr< CTemplateOptions >::CSmartPtr(), and CSmartPtr< CTemplateOptions >::operator=().

                                       {
            assert(pRawPtr);

            if (pRawPtr != m_pType) {                             // Check for assignment to self
                  Release();                                            // Release the current pointer
                  m_pType = pRawPtr;                                    // Point to the passed raw pointer

                  if (m_pType) {                                        // If the passed pointer was valid
                        m_puCount = new unsigned int(1);    // Create a new counter starting at 1 (us)
                  }
            }

            return *this;
      }


Generated by  Doxygen 1.6.0   Back to index