Boost logo

Boost :

From: Greg Colvin (greg_at_[hidden])
Date: 2002-05-07 13:31:38


At 11:53 AM 05/07/2002, Gennadiywrote:

>"Peter Dimov" <pdimov_at_[hidden]> wrote in message news:009901c1f5c2$7d9b6100
>> ...
>> Why wouldn't you use your own framework to make a COM smart pointer for
>> this? Consider what happens when you forget to specialize the traits class
>> for some COM interface.
>
>I can always typedefdef whatever you want. For example:
>
>template<typename T>
>typedef smart_ptr<T, ownership_is<intrusive_ref_counted> > IntrusivePtr;
>
>Now following will never compile:
>class A;
>IntrusivePtr<A> v;
>
>If you forgot to specialize itrusive_... traits you will get just plain
>pointer, the same if you would use just T*. But what you expect?! This is a
>price for using of unified interface. Do you know other solution to make
>COM-based intrusive counted pointer to work with unified interface like
>shared_ptr?

   void com_releaser(IUnknown* p) { p->Release(); }

   template<class T> shared_ptr<T>
   make_com_shared_ptr(IUnknown* p) {
      p->AddRef();
      return shared_ptr<T> (p,com_releaser);
   }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk