A class for managing references or pointers (no reference counting). More...
#include <refPtr.H>

Public Types | |
| typedef T | element_type |
| Type of object being managed or referenced. | |
| typedef T * | pointer |
| Pointer to type of object being managed or referenced. | |
| typedef Foam::refCount::zero | refCount |
| Null reference counter class. | |
Public Member Functions | |
| constexpr | refPtr () noexcept |
| Construct with no managed pointer. | |
| constexpr | refPtr (std::nullptr_t) noexcept |
| Implicit construct from literal nullptr: no managed pointer. | |
| constexpr | refPtr (T *p) noexcept |
| Construct, taking ownership of the pointer. | |
| constexpr | refPtr (const T &obj) noexcept |
| Implicit construct for a const reference to an object. | |
| refPtr (refPtr< T > &&rhs) noexcept | |
| Move construct, transferring ownership. | |
| refPtr (const refPtr< T > &rhs) | |
| Copy construct (shallow copy). | |
| refPtr (const refPtr< T > &rhs, bool reuse) | |
| Copy/move construct. Optionally reusing pointer. | |
| refPtr (std::unique_ptr< T > &&rhs) noexcept | |
| Move construct from unique_ptr, transferring ownership. | |
| refPtr (const autoPtr< T > &)=delete | |
| No copy construct from autoPtr, also avoids implicit cast to object or pointer. | |
| refPtr (autoPtr< T > &&rhs) noexcept | |
| Move construct from autoPtr, transferring ownership. | |
| refPtr (const tmp< T > &rhs, bool reuse) | |
| Reference tmp contents or transfer ownership if requested/possible. | |
| refPtr (const tmp< T > &rhs) | |
| Reference the tmp contents. | |
| refPtr (tmp< T > &&rhs) | |
| Move construct from tmp, transfer ownership if possible. | |
| ~refPtr () noexcept | |
| Destructor: deletes managed pointer. | |
| bool | good () const noexcept |
| True if pointer/reference is non-null. | |
| bool | is_const () const noexcept |
| If the stored/referenced content is const. | |
| bool | is_pointer () const noexcept |
| True if this is a managed pointer (not a reference). | |
| bool | is_reference () const noexcept |
| True if this is a reference (not a pointer). | |
| bool | movable () const noexcept |
| True if this is a non-null managed pointer. | |
| T * | get () noexcept |
| Return pointer without nullptr checking. | |
| const T * | get () const noexcept |
| Return const pointer without nullptr checking. | |
| const T & | cref () const |
| Return const reference to the object or to the contents of a (non-null) managed pointer. | |
| T & | ref () const |
| Return non-const reference to the contents of a non-null managed pointer. | |
| T & | constCast () const |
| Return non-const reference to the object or to the contents of a (non-null) managed pointer, with an additional const_cast. | |
| refPtr< T > | shallowClone () const noexcept |
| Return a shallow copy as a wrapped reference, preserving the const/non-const status. | |
| T * | release () noexcept |
| Release ownership and return the pointer. A no-op for reference objects (returns nullptr). | |
| T * | ptr () const |
| Return managed pointer for reuse, or clone() the object reference. | |
| void | clear () const noexcept |
| If object pointer points to valid object: delete object and set pointer to nullptr. | |
| void | reset (T *p=nullptr) noexcept |
| Delete managed pointer and set to new given pointer. | |
| void | reset (refPtr< T > &&other) noexcept |
| Clear existing and transfer ownership. | |
| void | reset (const autoPtr< T > &)=delete |
| No reset from autoPtr reference (potentially confusing). | |
| void | reset (autoPtr< T > &&other) noexcept |
| Clear existing and transfer ownership from autoPtr. | |
| void | reset (std::unique_ptr< T > &&other) |
| Clear existing and transfer ownership from unique_ptr. | |
| void | reset (tmp< T > &rhs, bool reuse) |
| Reference tmp contents or transfer pointer ownership if possible. | |
| template<class... Args> | |
| T & | emplace (Args &&... args) |
| Reset with emplace construction. Return reference to the new content. | |
| void | cref (const refPtr< T > &other) noexcept |
| Clear existing and set (const) reference from other. | |
| void | cref (const T &obj) noexcept |
| Clear existing and set (const) reference. | |
| void | cref (const T *p) noexcept |
| Clear existing and set (const) reference to pointer content. | |
| void | cref (const autoPtr< T > &)=delete |
| Avoid inadvertent casting (to object or pointer). | |
| void | cref (const tmp< T > &)=delete |
| Avoid inadvertent casting (to object). | |
| void | ref (T &obj) noexcept |
| Clear existing and set (non-const) reference. | |
| void | ref (T *p) noexcept |
| Clear existing and set (non-const) reference to pointer content. | |
| void | ref (const autoPtr< T > &)=delete |
| Avoid inadvertent casting (to object or pointer). | |
| void | ref (const tmp< T > &)=delete |
| Avoid inadvertent casting (object). | |
| void | swap (refPtr< T > &other) noexcept |
| Swaps the managed object with other. | |
| const T & | operator* () const |
| Return const reference to the object. | |
| T & | operator* () |
| Return reference to the managed object. | |
| const T * | operator-> () const |
| Dereferences (const) pointer to the managed object. | |
| T * | operator-> () |
| Dereferences (non-const) pointer to the managed object. | |
| const T & | operator() () const |
| Return const reference to the object - same as cref() method. | |
| operator bool () const noexcept | |
| True if pointer/reference is non-null. Same as good(). | |
| operator const T & () const | |
| Cast to underlying data type, using the cref() method. | |
| void | operator= (const refPtr< T > &other) |
| Transfer ownership of managed pointer. | |
| void | operator= (refPtr< T > &&other) noexcept |
| Clear existing and transfer ownership. | |
| void | operator= (T *p)=delete |
| No copy assignment from plain pointer (uncontrolled access). | |
| void | operator= (std::nullptr_t) noexcept |
| Reset via assignment from literal nullptr. | |
| void | operator= (const autoPtr< T > &)=delete |
| No copy assignment from autoPtr (can have unintended behaviour). | |
| void | operator= (autoPtr< T > &&other) noexcept |
| Transfer ownership by move assignment from autoPtr. | |
| void | operator= (std::unique_ptr< T > &&other) |
| Transfer ownership by move assignment from unique_ptr. | |
| void | operator= (const tmp< T > &)=delete |
| No copy assignment from tmp. | |
| void | operator= (tmp< T > &&other) |
| Move construct, transferring pointer ownership if possible. | |
| operator tmp< T > () | |
| Conversion to tmp, releases pointer or shallow-copies reference. | |
| bool | valid () const noexcept |
| Identical to good(), or bool operator. | |
| bool | empty () const noexcept |
| Deprecated(2020-07) True if a null managed pointer. | |
Static Public Member Functions | |
| template<class... Args> | |
| static refPtr< T > | New (Args &&... args) |
| Construct refPtr with forwarding arguments. | |
| template<class U, class... Args> | |
| static refPtr< T > | NewFrom (Args &&... args) |
| Construct refPtr from derived type with forwarding arguments. | |
| static word | typeName () |
| The type-name, constructed from type-name of T. | |
A class for managing references or pointers (no reference counting).
| typedef T element_type |
| typedef Foam::refCount::zero refCount |
|
inlineconstexprnoexcept |
Construct with no managed pointer.
Definition at line 37 of file refPtrI.H.
References Foam::noexcept.
Referenced by cref(), New(), NewFrom(), operator=(), operator=(), ref(), refPtr(), refPtr(), refPtr(), refPtr(), refPtr(), refPtr(), refPtr(), refPtr(), refPtr(), reset(), shallowClone(), and swap().

|
inlineconstexprnoexcept |
Implicit construct from literal nullptr: no managed pointer.
Definition at line 45 of file refPtrI.H.
References Foam::noexcept.
Construct, taking ownership of the pointer.
Definition at line 53 of file refPtrI.H.
References Foam::noexcept, p, and Foam::T().

Implicit construct for a const reference to an object.
Definition at line 61 of file refPtrI.H.
References Foam::noexcept, and Foam::T().

Move construct, transferring ownership.
Definition at line 69 of file refPtrI.H.
References Foam::noexcept, refPtr(), and Foam::rhs().

Copy construct (shallow copy).
Definition at line 80 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, is_pointer(), refPtr(), Foam::rhs(), and typeName().

Copy/move construct. Optionally reusing pointer.
Definition at line 103 of file refPtrI.H.
References refPtr(), and Foam::rhs().

Move construct from unique_ptr, transferring ownership.
Definition at line 134 of file refPtrI.H.
References Foam::noexcept, refPtr(), and Foam::rhs().

No copy construct from autoPtr, also avoids implicit cast to object or pointer.
References Foam::noexcept, refPtr(), Foam::rhs(), and Foam::T().

Move construct from autoPtr, transferring ownership.
Definition at line 141 of file refPtrI.H.
References Foam::noexcept, refPtr(), and Foam::rhs().

Destructor: deletes managed pointer.
Definition at line 177 of file refPtrI.H.
References clear(), and Foam::noexcept.

Construct refPtr with forwarding arguments.
| args | list of arguments with which an instance of T will be constructed. |
Definition at line 187 of file refPtr.H.
References args, New(), refPtr(), Foam::T(), and T.
Referenced by AMIInterpolation::calculate(), RASModelVariables::cloneRefPtr(), fvExprDriver::getTopoSetLabels(), fileOperation::lookupAndCacheProcessorsPath(), New(), and blockMesh::topology().


|
inlinestatic |
Construct refPtr from derived type with forwarding arguments.
| args | list of arguments with which an instance of U will be constructed. |
Definition at line 202 of file refPtr.H.
References args, refPtr(), and U.

|
inlinestatic |
|
inlinenoexcept |
True if pointer/reference is non-null.
Definition at line 221 of file refPtr.H.
References Foam::noexcept.
Referenced by PrecisionAdaptor< Type, InputType, Container >::commit(), and fvExprDriver::getTopoSetLabels().

|
inlinenoexcept |
If the stored/referenced content is const.
Definition at line 186 of file refPtrI.H.
References Foam::noexcept.
Referenced by operator*(), operator->(), and shallowClone().

|
inlinenoexcept |
True if this is a managed pointer (not a reference).
Definition at line 193 of file refPtrI.H.
References Foam::noexcept.
Referenced by clear(), cref(), movable(), operator tmp< T >(), operator=(), refPtr(), release(), and regIOobject::store().

|
inlinenoexcept |
True if this is a reference (not a pointer).
Definition at line 201 of file refPtrI.H.
References Foam::noexcept.
|
inlinenoexcept |
True if this is a non-null managed pointer.
Definition at line 209 of file refPtrI.H.
References is_pointer(), and Foam::noexcept.

Return pointer without nullptr checking.
Definition at line 249 of file refPtr.H.
References get(), Foam::noexcept, and Foam::T().
Referenced by fileOperation::fileHandler(), get(), and regIOobject::store().


Return const pointer without nullptr checking.
Definition at line 254 of file refPtr.H.
References Foam::noexcept, and Foam::T().

Return const reference to the object or to the contents of a (non-null) managed pointer.
Fatal for a null managed pointer
Definition at line 216 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, is_pointer(), and Foam::T().
Referenced by constCast(), parseDriver::getField(), fvExprDriver::getOrReadFieldImpl(), fvExprDriver::getTopoSetLabels(), fvExprDriver::getVariable(), parseDriver::getVariableIfAvailable(), streamLineBase::initInterpolations(), Function1< Type >::New(), refPtr< Field< InputType > >::operator const Field< InputType > &(), operator tmp< T >(), operator()(), GAMGPreconditioner::precondition(), GAMGAgglomeration::procAgglomerateLduAddressing(), Foam::shallowCloneFunctions(), regIOobject::store(), streamLine::track(), and wallBoundedStreamLine::track().


Return non-const reference to the contents of a non-null managed pointer.
Fatal for a null managed pointer or if the object is const.
Definition at line 230 of file refPtrI.H.
References Foam::T().
Referenced by kahipDecomp::decomposeSerial(), metisDecomp::decomposeSerial(), scotchDecomp::decomposeSerial(), primitiveMeshTools::makeCellCentresAndVols(), cyclicPolyPatch::mapCollocatedFaces(), mappedPolyPatch::mapCollocatedFaces(), mappedWallPolyPatch::mapCollocatedFaces(), faMatrix< scalar >::residual(), fvMatrix< scalar >::residual(), lduMatrix::solver::scalarSolve(), fvMesh::setPhi(), faMatrix< Type >::solve(), FPCG::solve(), GAMGSolver::solve(), PBiCG::solve(), PBiCGStab::solve(), PCG::solve(), PPCG::solve(), PPCR::solve(), smoothSolver::solve(), fvMatrix< Type >::solveSegregated(), and primitiveMeshTools::updateCellCentresAndVols().


Return non-const reference to the object or to the contents of a (non-null) managed pointer, with an additional const_cast.
Fatal for a null managed pointer.
Definition at line 278 of file refPtr.H.
References cref(), and Foam::T().
Referenced by kahipDecomp::decomposeSerial(), metisDecomp::decomposeSerial(), and meshRefinement::findRegions().


|
inlinenoexcept |
Return a shallow copy as a wrapped reference, preserving the const/non-const status.
Definition at line 251 of file refPtrI.H.
References is_const(), Foam::noexcept, and refPtr().

Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
Definition at line 266 of file refPtrI.H.
References is_pointer(), Foam::noexcept, and Foam::T().
Referenced by regIOobject::store().


Return managed pointer for reuse, or clone() the object reference.
Definition at line 280 of file refPtrI.H.
References Foam::T().
Referenced by operator tmp< T >(), PtrDynList< T, SizeMin >::push_back(), PtrList< T >::push_back(), HashPtrTable< T, Key, Hash >::set(), PtrDynList< T, SizeMin >::set(), and PtrList< T >::set().


|
inlinenoexcept |
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition at line 303 of file refPtrI.H.
References is_pointer(), and Foam::noexcept.
Referenced by kahipDecomp::decomposeSerial(), metisDecomp::decomposeSerial(), and scotchDecomp::decomposeSerial().


Delete managed pointer and set to new given pointer.
Definition at line 314 of file refPtrI.H.
References clear(), p, and Foam::T().
Referenced by fileOperation::fileHandler(), fvExprDriver::getTopoSetLabels(), streamLineBase::initInterpolations(), operator=(), operator=(), operator=(), operator=(), refPtr(), refPtr(), refPtr(), reset(), reset(), and ISQP::ShermanMorrisonPrecon().


Reference tmp contents or transfer pointer ownership if possible.
Definition at line 341 of file refPtrI.H.
References tmp< T >::get().

Avoid inadvertent casting (to object or pointer).
Avoid inadvertent casting (to object or pointer).
Swaps the managed object with other.
Definition at line 430 of file refPtrI.H.
References p, refPtr(), and Foam::T().
Referenced by fileOperation::fileHandler(), and fileOperation::fileHandler().


Return const reference to the object.
Fatal if nothing is managed
Definition at line 447 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and Foam::T().

Return reference to the managed object.
Fatal if nothing is managed or if the object is const.
Definition at line 460 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, is_const(), and Foam::T().

Dereferences (const) pointer to the managed object.
Fatal if nothing is managed.
Definition at line 481 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and Foam::T().

Dereferences (non-const) pointer to the managed object.
Fatal if nothing is managed or if the object is const.
Definition at line 495 of file refPtrI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, is_const(), and Foam::T().

|
inlineexplicitnoexcept |
True if pointer/reference is non-null. Same as good().
Definition at line 443 of file refPtr.H.
References Foam::noexcept.
Transfer ownership of managed pointer.
Fatal for a null managed pointer or if the object is const.
Definition at line 516 of file refPtrI.H.
References Foam::abort(), clear(), Foam::FatalError, FatalErrorInFunction, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, is_pointer(), name, refPtr(), and Foam::T().

|
inlinenoexcept |
No copy assignment from autoPtr (can have unintended behaviour).
Conversion to tmp, releases pointer or shallow-copies reference.
Definition at line 560 of file refPtrI.H.
References cref(), is_pointer(), and ptr().

|
inlinenoexcept |
Identical to good(), or bool operator.
Definition at line 512 of file refPtr.H.
References Foam::noexcept.
Referenced by fvExprDriver::getOrReadFieldImpl(), fvExprDriver::getVariable(), and parseDriver::getVariableIfAvailable().

|
inlinenoexcept |
Deprecated(2020-07) True if a null managed pointer.
Definition at line 521 of file refPtr.H.
References empty(), and Foam::noexcept.
Referenced by empty().

