63 template<
class T>
class refPtr;
88 mutable refType type_;
94 inline void checkUseCount()
const;
121 inline explicit
tmp(
T*
p);
140 inline
tmp(const
tmp<
T>& rhs,
bool reuse);
166 template<class... Args>
178 template<
class U,
class... Args>
215 const T*
get()
const noexcept {
return ptr_; }
220 inline const T&
cref()
const;
225 inline T&
ref()
const;
236 inline T*
ptr()
const;
260 template<class... Args>
304 inline const
T* operator->() const;
308 inline
T* operator->();
311 const
T& operator()()
const {
return cref(); }
317 explicit operator bool() const
noexcept {
return bool(ptr_); }
320 operator const T&()
const {
return cref(); }
327 inline void operator=(
const tmp<T>& other);
bool isTmp() const noexcept
Identical to is_pointer(). Prefer is_pointer() or movable().
static word typeName()
The type-name, constructed from type-name of T.
bool valid() const noexcept
Identical to good(), or bool operator.
Foam::refCount refCount
Reference counter class.
constexpr tmp() noexcept
Construct with no managed pointer.
Reference counter for various OpenFOAM components.
bool movable() const noexcept
True if this is a non-null managed pointer with a unique ref-count.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
bool empty() const noexcept
Deprecated(2020-07) True if a null managed pointer.
void protect(bool on) noexcept
Use specified protection against moving for the managed pointer. No-op for references.
A class for managing references or pointers (no reference counting)
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
T * get() noexcept
Return pointer without nullptr checking.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
static tmp< T > NewFrom(Args &&... args)
Construct tmp from derived type with forwarding arguments.
void swap(tmp< T > &other) noexcept
Swaps the managed object with other.
bool is_reference() const noexcept
True if this is a reference (not a pointer)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
T * pointer
Pointer to type of object being managed or referenced.
void operator=(const tmp< T > &other)
Transfer ownership of the managed pointer.
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference)
bool good() const noexcept
True if pointer/reference is non-null.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
T & constCast() const
Return non-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.
A class for managing temporary objects.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
Foam::argList args(argc, argv)
bool is_const() const noexcept
If the stored/referenced content is const.
T element_type
Type of object being managed or referenced.
void reset(tmp< T > &&other) noexcept
Clear existing and transfer ownership.