NVIDIA NvNeural SDK
2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
|
Details type that allows version-safe use of out-pointer parameters without converting through an intermediate raw pointer variable or mismatching fromPointer/fromPointerNoAddRef. More...
#include <nvneural/RefPtr.h>
Public Member Functions | |
operator TObject ** () | |
Converts to the TObject output pointer. | |
~OutputWrapper () | |
After the pointer-consuming expression has been evaluated, ensure the pointer returned by the external code is still of the interface we think it is. | |
Friends | |
class | RefPtr |
Details type that allows version-safe use of out-pointer parameters without converting through an intermediate raw pointer variable or mismatching fromPointer/fromPointerNoAddRef.
Why we don't just make RefPtr::put() return &m_pObject and call it a day: During development, an engineer might redefine an IThing interface in an ABI-breaking fashion. By convention, the engineer regenerates IThing::interfaceId, but old binaries might not be updated to reflect the new changes. From their perspective, it's still IThing to C++ but with an ODR violation that will lead to hard-to-debug crashes.
Calling IRefObject::queryInterface on the newly returned pointer ensures that the returned pointer is using the same interface ID as the code that consumes it. This does not guard against all ABI breakage, but at least converts "best intention" dev-time breakage into much- easier-to-diagnose null pointers.