Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-20 09:28:40

From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>
> I agree that release() is dangerous. It is also required if you want to
> smart pointers with any COM (and, I suspect, CORBA) projects. The typical
> scenario (shown by Rob), is when you need to return a pointer in an out
> parameter. In that case you need to tell your smart pointer you want to
> ownership of the pointee away from the smart pointer.

Dunno 'bout CORBA but in COM there's no need for release() (lowercase R.)
Here's why:

template<class T> T * release(com_smart_ptr<T> & p)
    T * q = p.get();

    if(q != 0)

    return q;

Peter Dimov
Multi Media Ltd.

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