Angus Leeming wrote:
> I need some guidance here... My feeling is to add 'create_ptr' and
> 'destroy_ptr' template parameters to copied_ptr...

I remembered tha boost::shared_ptr has a Deleter template parameter., so I am 
not talking crap here.

We would need a Creator parameter too. Something like this would do it.
But, is it worth the effort?
Angus

==================================================================
copied_ptr.h

template <typename T, 
          typename CreatorT=DefaultCreator<T>, 
          typename DeleterT=DefaultDeleter<T>>
class copied_ptr {
        T * ptr_;
        CreatorT create;
        DeleterT destroy;

        ~copied_ptr() { destroy(ptr_); }
        void copy(copied_ptr const & other) {
                ptr_ = other.ptr_ ? create(*other.ptr_) : 0;
        }

        // rest of the class is unchanged
        ...
};

template <typename T>
struct DefaultCreator {
        T * operator()(T const & other) { return new T(other); }
}


template <typename T>
struct DefaultDeleter {
        void operator()(T * ptr) { delete ptr; }
}
==================================================================
bufferparams.h

class BufferParams {
        ...
        class Impl;
        struct ImplCreator {
                // defined out-of-line, in bufferparams.C
                Impl * operator()(Impl const &);
        }
        struct ImplDeleter {
                // defined out-of-line, in bufferparams.C
                void operator()(Impl *);
        }
        lyx::support::copied_ptr<Impl, ImplCreator, ImplDeleter> pimpl_;
};


Reply via email to