Although it would be a terrible idea for a production solution, it would not be too difficult to roll on your own for the class if you were not trying to be cross-compiler, flexible and thread safe as boost:
template <typename contained> class my_shared_ptr { public: my_shared_ptr() : ptr_(NULL), ref_count_(NULL) { } my_shared_ptr(contained * p) : ptr_(p), ref_count_(p ? new int : NULL) { inc_ref(); } my_shared_ptr(const my_shared_ptr& rhs) : ptr_(rhs.p), ref_count_(rhs.ref_count_) { inc_ref(); } ~my_shared_ptr() { if(ref_count_ && 0 == dec_ref()) { delete ptr_; delete ref_count_; } } contained * get() { return ptr_; } const contained * get() const { return ptr_; } void swap(my_shared_ptr& rhs)
Todd gardner
source share