1. is a cast from a pointer to a pointre
3. is a case from a smartptr to a smartptr
2. is an error (I presume when you say blows up you mean it fails to compile?)
 
I don't know what you mean by "confusing redundancy". I don't see any redundancy at all, since it is no more/less reasonable to want to be able to cast raw pointers as smartptrs. Is that what you mean?
 
"Adi Shavit" <adish@gentech.co.il> wrote in message news:eturnn$6cq$1@digitalmars.com...
Indeed, it does!

Can you explain what the difference is between each of the versions, and why this (confusing) redundancy exists?

Here they are for reference:
//...
stlsoft::ref_ptr<IGraphBuilder> pGraph;
stlsoft::ref_ptr<IMediaControl> pMediaControl;
//...

1. pMediaControl.set(interface_cast_addref<IMediaControl*>(pGraph.get()), false); // this is OK
2.
pMediaControl.set(interface_cast_addref<IMediaControl*>(pGraph), false);       // this blows up.
3.
pMediaControl = interface_cast<IMediaControl>(pGraph);                         // this is OK
Thanks,
Adi


Matthew Wilson wrote:
As far as I can remember, the adjustment to interface_cast_addref<> to take ref_ptr<X> arguments has _not_ been done, so the code as you've written it will not work.
 
However, the following (cleaner, nicer, more transparent) version should:
 
   //...
   stlsoft::ref_ptr<IGraphBuilder> pGraph;
   stlsoft::ref_ptr<IMediaControl> pMediaControl;
   //...

   if(SUCCEEDED(co_create_instance(CLSID_FilterGraph, pGraph)))
   {
      pMediaControl = interface_cast<IMediaControl>(pGraph);
     //...
 
:-)
 
Matt