Cannot directly access the raw pointer/reference from autoPtr
All of the access methods for autoPtr include validity checks and will fail if the underlying point is NULL.
In some cases, however, we'd like to retain the automatic deletion mechanism, but still address a nullptr. This is mostly for cases in which a file-stream should be allocated, but only on the master process. For these cases we'd still like to pass through and reference the underlying pointer (eg, to obtain the correct method call) without tripping the pointer check mechanism. If we attempt to use the ptr()
method, the autoPtr memory management is bypassed and we risk memory leaks.
Instead provide an alternative mechanism to obtain the raw underlying pointers/references. The first proposal used refOrNull()
for this particular operation, but if expanding this to include pointers, it is not the best name. Propose to use rawPtr()
and rawRef()
for these useful, but potentially dangerous, operations.