75 mutable refType type_;
148 template<class... Args>
160 template<
class U,
class... Args>
197 const T*
get()
const noexcept {
return ptr_; }
207 inline T&
ref()
const;
228 inline
T*
ptr() const;
247 void reset(std::unique_ptr<T>&& other) {
reset(other.release()); }
254 template<
class... Args>
315 explicit operator bool() const
noexcept {
return bool(ptr_); }
318 operator const T&()
const {
return cref(); }
325 inline void operator=(
const refPtr<T>& other);
343 void operator=(std::unique_ptr<T>&& other) {
reset(other.release()); }
353 inline operator tmp<T>();
const T & operator()() const
Return const reference to the object - same as cref() method.
static refPtr< T > New(Args &&... args)
Construct refPtr with forwarding arguments.
bool valid() const noexcept
Identical to good(), or bool operator.
bool good() const noexcept
True if pointer/reference is non-null.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
const T * operator->() const
Dereferences (const) pointer to the managed object.
A class for managing references or pointers (no reference counting)
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
bool empty() const noexcept
Deprecated(2020-07) True if a null managed pointer.
T & constCast() const
Return non-const reference to the object or to the contents of a (non-null) managed pointer...
Foam::refCount::zero refCount
Null reference counter class.
void operator=(const refPtr< T > &other)
Transfer ownership of managed pointer.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
const T & operator*() const
Return const reference to the object.
constexpr refPtr() noexcept
Construct with no managed pointer.
static word typeName()
The type-name, constructed from type-name of T.
T * get() noexcept
Return pointer without nullptr checking.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
T element_type
Type of object being managed or referenced.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T * pointer
Pointer to type of object being managed or referenced.
bool is_const() const noexcept
If the stored/referenced content is const.
void reset(autoPtr< T > &&other) noexcept
Clear existing and transfer ownership from autoPtr.
T * release() noexcept
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
bool movable() const noexcept
True if this is a non-null managed pointer.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
bool is_reference() const noexcept
True if this is a reference (not a pointer)
refPtr< T > shallowClone() const noexcept
Return a shallow copy as a wrapped reference, preserving the const/non-const status.
A class for managing temporary objects.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
Foam::argList args(argc, argv)
A non-counting (dummy) refCount.
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference)
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.
static refPtr< T > NewFrom(Args &&... args)
Construct refPtr from derived type with forwarding arguments.