On 09/02/2008, Curt Arnold <[EMAIL PROTECTED]> wrote:
> > These functions don't need their casts either:
> >            T* operator->() const {return (T*) p; }
> >            T& operator*() const {return (T&) *p; }
> >            operator T*() const {return (T*) p; }
> > (The last of these functions is a bad idea IMHO, as with most implicit
> > conversion operators. An explicit ObjectPtrT::get() function would be
> > better, but that would be an API change, so nevermind.)
>
> Well if there is an API change, now is the time to do it.  That is a
> hold over from log4cxx 0.9.7, can't immediately predict the
> implications.  I assume the intended use is to allow use of an
> ObjectPtrT<T> when a function takes a T*.

One danger of an implicit conversion that is specific to smart
pointers is that the conversion also allows:

  ObjectPtrT<Foo> p(new Foo);
  delete p;   // oops!

Jonathan

Reply via email to