|
slot 0.0.1
A real time UI render framework
|
类 | |
| class | ComPtr |
枚举 | |
| enum | InitAttach { INIT_ATTACH } |
| ComPtr is a simple smart pointer that manages types which implement COM based interfaces. 更多... | |
| enum Slang::InitAttach |
ComPtr is a simple smart pointer that manages types which implement COM based interfaces.
A class that implements a COM, must derive from the IUnknown interface or a type that matches it's layout exactly (such as ISlangUnknown). Trying to use this template with a class that doesn't follow these rules, will lead to undefined behavior. This is a 'strong' pointer type, and will AddRef when a non null pointer is set and Release when the pointer leaves scope. Using 'detach' allows a pointer to be removed from the management of the ComPtr. To set the smart pointer to null, there is the method setNull, or alternatively just assign SLANG_NULL/nullptr.
One edge case using the template is that sometimes you want access as a pointer to a pointer. Sometimes this is to write into the smart pointer, other times to pass as an array. To handle these different behaviors there are the methods readRef and writeRef, which are used instead of the & (ref) operator. For example
A more common scenario writing to the pointer
| 枚举值 | |
|---|---|
| INIT_ATTACH | |