I'm trying to use smart pointers to hold COM objects in my class while avoiding
ComPtr
.
The solution is to use ComPtr
. unique_ptr
is a poor substitute for ComPtr
if you're working with COM objects.
ComPtr
provides specialized functionality for working with COM objects and IUnknown
. For example, it has built in support for safe interface querying (via the As
member function). It is also usable with out parameters, which are common in COM (via the GetAddressOf
functions).