Originally Posted by
iMalc
You'll find that most smart pointer classes allow some way of transferring ownerhip through calls to or from functions that can't take a smart pointer, such as by having a Attach and Detach functions. External functions such as CreateThread that do not let you pass the type of object you want by value are precisely when you need such things. Using Attach and Detach instead of direct calls to the objects AddRef and Release methods tends to mean cleaner and exception-safe code.
btw AddRef, Release, Attach and Detach are just the names of functions used with COM objects and CComPtr, which I use on a daily basis.