A class for managing references or pointers (no reference counting) More...
Public Types | |
typedef T | element_type |
Type of object being managed or referenced. More... | |
typedef T * | pointer |
Pointer to type of object being managed or referenced. More... | |
typedef Foam::refCount::zero | refCount |
Null reference counter class. More... | |
Public Member Functions | |
constexpr | refPtr () noexcept |
Construct with no managed pointer. More... | |
constexpr | refPtr (std::nullptr_t) noexcept |
Construct with no managed pointer (literal nullptr). More... | |
constexpr | refPtr (T *p) noexcept |
Construct, taking ownership of the pointer. More... | |
refPtr (autoPtr< T > &&ptr) noexcept | |
Move construct from autoPtr, transferring ownership. More... | |
refPtr (std::unique_ptr< T > &&ptr) noexcept | |
Move construct from unique_ptr, transferring ownership. More... | |
constexpr | refPtr (const T &obj) noexcept |
Construct for a const reference to an object. More... | |
refPtr (refPtr< T > &&rhs) noexcept | |
Move construct, transferring ownership. More... | |
refPtr (const refPtr< T > &rhs) | |
Copy construct (shallow copy) More... | |
refPtr (const refPtr< T > &rhs, bool reuse) | |
Copy/move construct. Optionally reusing pointer. More... | |
~refPtr () | |
Destructor: deletes managed pointer. More... | |
bool | good () const noexcept |
True if pointer/reference is non-null. More... | |
bool | is_const () const noexcept |
If the stored/referenced content is const. More... | |
bool | is_pointer () const noexcept |
True if this is a managed pointer (not a reference) More... | |
bool | movable () const noexcept |
True if this is a non-null managed pointer. More... | |
T * | get () noexcept |
Return pointer without nullptr checking. More... | |
const T * | get () const noexcept |
Return const pointer without nullptr checking. More... | |
const T & | cref () const |
T & | ref () const |
T & | constCast () const |
refPtr< T > | shallowClone () const noexcept |
T * | release () noexcept |
T * | ptr () const |
Return managed pointer for reuse, or clone() the object reference. More... | |
void | clear () const noexcept |
void | reset (refPtr< T > &&other) noexcept |
Clear existing and transfer ownership. More... | |
void | reset (T *p=nullptr) noexcept |
Delete managed pointer and set to new given pointer. More... | |
void | reset (autoPtr< T > &&other) noexcept |
Clear existing and transfer ownership from autoPtr. More... | |
void | reset (std::unique_ptr< T > &&other) |
Clear existing and transfer ownership from unique_ptr. More... | |
void | cref (const refPtr< T > &other) noexcept |
Clear existing and set (const) reference from other. More... | |
void | cref (const T &obj) noexcept |
Clear existing and set (const) reference. More... | |
void | cref (const T *p) noexcept |
Clear existing and set (const) reference to pointer content. More... | |
void | ref (T &obj) noexcept |
Clear existing and set (non-const) reference. More... | |
void | ref (T *p) noexcept |
Clear existing and set (non-const) reference to pointer content. More... | |
void | swap (refPtr< T > &other) noexcept |
Swaps the managed object with other. More... | |
const T & | operator* () const |
Return const reference to the object. More... | |
T & | operator* () |
Return reference to the managed object. More... | |
const T * | operator-> () const |
Dereferences (const) pointer to the managed object. More... | |
T * | operator-> () |
Dereferences (non-const) pointer to the managed object. More... | |
const T & | operator() () const |
Return const reference to the object - same as cref() method. More... | |
operator bool () const noexcept | |
True if pointer/reference is non-null. Same as good() More... | |
operator const T & () const | |
Cast to underlying data type, using the cref() method. More... | |
void | operator= (const refPtr< T > &other) |
Transfer ownership of the managed pointer. More... | |
void | operator= (refPtr< T > &&other) noexcept |
Clear existing and transfer ownership. More... | |
void | operator= (T *p) |
Take ownership of the pointer. More... | |
void | operator= (std::nullptr_t) noexcept |
Reset via assignment from literal nullptr. More... | |
operator tmp< T > () | |
Conversion to tmp, releases pointer or shallow-copies reference. More... | |
bool | valid () const noexcept |
Identical to good(), or bool operator. More... | |
bool | empty () const noexcept |
Deprecated(2020-07) True if a null managed pointer. More... | |
template<class... Args> | |
Foam::refPtr< T > | New (Args &&... args) |
template<class U , class... Args> | |
Foam::refPtr< T > | NewFrom (Args &&... args) |
Static Public Member Functions | |
template<class... Args> | |
static refPtr< T > | New (Args &&... args) |
Construct refPtr of T with forwarding arguments. More... | |
template<class U , class... Args> | |
static refPtr< T > | NewFrom (Args &&... args) |
Construct refPtr from derived type with forwarding arguments. More... | |
static word | typeName () |
The type-name, constructed from type-name of T. More... | |
A class for managing references or pointers (no reference counting)
typedef T element_type |
typedef Foam::refCount::zero refCount |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Construct refPtr of T with forwarding arguments.
args | list of arguments with which an instance of T will be constructed. |
Referenced by AMIInterpolation::calculate(), RASModelVariables::cloneRefPtr(), fileOperation::lookupAndCacheProcessorsPath(), and blockMesh::topology().
Construct refPtr from derived type with forwarding arguments.
args | list of arguments with which an instance of U will be constructed. |
|
inlinestatic |
|
inlinenoexcept |
True if pointer/reference is non-null.
Definition at line 154 of file refPtr.H.
Referenced by PrecisionAdaptor< Type, InputType, Container >::commit().
|
inlinenoexcept |
|
inlinenoexcept |
True if this is a managed pointer (not a reference)
Definition at line 160 of file refPtr.H.
Referenced by regIOobject::store().
|
inlinenoexcept |
|
inlinenoexcept |
Return pointer without nullptr checking.
Definition at line 169 of file refPtr.H.
Referenced by PrecisionAdaptor< Type, InputType, Container >::set(), and regIOobject::store().
|
inlinenoexcept |
|
inline |
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 189 of file refPtrI.H.
Referenced by parseDriver::getField(), fvExprDriver::getTopoSetLabels(), fvExprDriver::getVariable(), parseDriver::getVariableIfAvailable(), PatchFunction1< Foam::Vector >::New(), Function1< Foam::Tensor >::New(), refPtr< T >::operator const T &(), refPtr< Foam::OSstream >::operator()(), and regIOobject::store().
|
inline |
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 203 of file refPtrI.H.
Referenced by PrecisionAdaptor< Type, InputType, Container >::commit(), mappedPolyPatch::mapCollocatedFaces(), mappedWallPolyPatch::mapCollocatedFaces(), and cyclicPolyPatch::mapCollocatedFaces().
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
Definition at line 246 of file refPtrI.H.
Referenced by regIOobject::store().
|
inline |
Return managed pointer for reuse, or clone() the object reference.
Definition at line 260 of file refPtrI.H.
Referenced by PtrList< transferModel >::append(), PtrDynList< Foam::profilingInformation >::append(), PtrList< transferModel >::set(), and PtrDynList< Foam::profilingInformation >::set().
|
inlinenoexcept |
Clear existing and transfer ownership.
Definition at line 303 of file refPtrI.H.
Referenced by fvExprDriver::getTopoSetLabels().
|
inlinenoexcept |
Clear existing and transfer ownership from autoPtr.
Definition at line 217 of file refPtr.H.
Referenced by refPtr< Foam::OSstream >::reset().
|
inline |
Clear existing and transfer ownership from unique_ptr.
Definition at line 220 of file refPtr.H.
Referenced by refPtr< Foam::OSstream >::reset().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineexplicitnoexcept |
|
inline |
Cast to underlying data type, using the cref() method.
Definition at line 274 of file refPtr.H.
References refPtr< T >::cref().
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Identical to good(), or bool operator.
Definition at line 300 of file refPtr.H.
Referenced by parseDriver::getField(), fvExprDriver::getTopoSetLabels(), fvExprDriver::getVariable(), and parseDriver::getVariableIfAvailable().
|
inlinenoexcept |
Deprecated(2020-07) True if a null managed pointer.
|
inline |
|
inline |