template<class I>
class Steinberg::OPtr< I >
OPtr - "owning" smart pointer used for newly created FObjects.
FUnknown implementations are supposed to have a refCount of 1 right after creation. So using an IPtr on newly created objects would lead to a leak. Instead the OPtr can be used in this case.
Example:
OPtr(I *p)
Definition smartpointer.h:213
The assignment operator takes ownership of a new object and releases the old. So its safe to write:
path = FHostCreate (IPath, hostClasses);
path = 0;
This is the difference to using an IPtr with addRef=false.
IPtr<IPath> path (FHostCreate (IPath, hostClasses),
false);
path = FHostCreate (IPath, hostClasses);
path = 0;
IPtr(I *ptr, bool addRef=true)
Definition smartpointer.h:126
This will lead to a leak!