Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-06-13 10:02:11

impl_ptr is a smart pointer that

* supports the "pimple" idiom;

* can be used to safely pass dynamically allocated memory blocks across
application/library boundaries when the application and the library heap
managers differ;

* can be used as a building block to construct other smart pointers and
variant types. (*)

If there's interest, I'll request a formal review.

(*) Example: a cloning smart pointer:
#include <boost/impl_ptr.hpp>
#include <boost/dynamic_traits.hpp>
template<class T> class my_clone_traits: public boost::dynamic_traits<T>
    virtual T * copy(T const * p) const { return p? p->Clone(): 0; }
    virtual void destroy(T * p) const { delete p; }
    static my_clone_traits const * instance()
        static my_clone_traits t; return &t;
template<class T> class my_clone_ptr: public boost::impl_ptr<T>
    explicit my_clone_ptr(T * p = 0): boost::impl_ptr<T>(p,
      my_clone_traits<T>::instance()) {}
For another example, see
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at