Changeset 420

Show
Ignore:
Timestamp:
07/20/09 10:11:50 (15 years ago)
Author:
vbarta
Message:

some inline documentation, using it_assert_debug (like other library classes)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/shared_ptr.h

    r419 r420  
    1414#define shared_ptr_h 
    1515 
    16 #include <assert.h> 
    1716#include <limits.h> 
    1817#include <algorithm> 
    1918#include <stdexcept> 
    2019#include <string> 
     20#include "itpp_ext.h" 
    2121 
    2222namespace bdm { 
     
    3333 
    3434public: 
     35    //! Creates an empty shared_ptr - one that doesn't point anywhere. 
    3536    shared_ptr(): 
    3637        payload(0), 
     
    3940    } 
    4041 
     42    //! Constructs a shared_ptr that owns the pointer p (unless p is 
     43    //! null, in which case this constructor creates an empty 
     44    //! shared_ptr). 
    4145    shared_ptr(T *p): 
    4246        payload(p), 
     
    4549    } 
    4650 
     51    //! If other is empty, constructs an empty shared_ptr; otherwise, 
     52    //! constructs a shared_ptr that shares ownership with other. 
    4753    shared_ptr(const shared_ptr &other): 
    4854        payload(other.payload), 
     
    6874    } 
    6975 
     76    //! Returns the stored pointer (which remains owned by this 
     77    //! instance). 
    7078    T *get() { return payload; } 
    7179 
     80    //! Returns the stored pointer (which remains owned by this 
     81    //! instance). This method may only be called when the stored 
     82    //! pointer isn't NULL. 
    7283    T *operator->() 
    7384    { 
    74         assert(payload); 
     85        it_assert_debug(payload, "dereferencing NULL"); 
    7586        return payload; 
    7687    } 
    7788 
     89    //! Returns a reference to the object pointed to by the stored 
     90    //! pointer. This method may only be called when the stored pointer 
     91    //! isn't NULL. 
    7892    T &operator*() 
    7993    { 
    80         assert(payload); 
     94        it_assert_debug(payload, "dereferencing NULL"); 
    8195        return *payload; 
    8296    } 
    8397 
     98    //! Returns the stored pointer (which remains owned by this 
     99    //! instance). 
    84100    const T* get() const { return payload; } 
    85101 
     102    //! Returns the stored pointer (which remains owned by this 
     103    //! instance). This method may only be called when the stored 
     104    //! pointer isn't NULL. 
    86105    const T *operator->() const 
    87106    { 
    88         assert(payload); 
     107        it_assert_debug(payload, "dereferencing NULL"); 
    89108        return payload; 
    90109    } 
    91110 
     111    //! Returns a reference to the object pointed to by the stored 
     112    //! pointer. This method may only be called when the stored pointer 
     113    //! isn't NULL. 
    92114    const T &operator*() const 
    93115    { 
    94         assert(payload); 
     116        it_assert_debug(payload, "dereferencing NULL"); 
    95117        return *payload; 
    96118    }