Go to the documentation of this file.
74 mutable refType type_;
100 template<
class... Args>
108 template<
class U,
class... Args>
115 inline constexpr
refPtr() noexcept;
118 inline constexpr
refPtr(std::nullptr_t) noexcept;
121 inline explicit constexpr
refPtr(
T*
p) noexcept;
127 inline explicit
refPtr(std::unique_ptr<
T>&&
ptr) noexcept;
130 inline constexpr
refPtr(const
T& obj) noexcept;
155 bool good() const noexcept {
return bool(ptr_); }
158 bool is_const() const noexcept {
return type_ == CREF; }
161 bool is_pointer() const noexcept {
return type_ == PTR; }
164 inline bool movable() const noexcept;
170 T*
get() noexcept {
return ptr_; }
173 const T*
get() const noexcept {
return ptr_; }
178 inline const T&
cref()
const;
183 inline T&
ref()
const;
204 inline
T*
ptr() const;
208 inline
void clear() const noexcept;
215 inline
void reset(
T*
p =
nullptr) noexcept;
221 void reset(std::unique_ptr<T>&& other) {
reset(other.release()); }
228 inline void cref(
const T& obj) noexcept;
232 inline void cref(
const T*
p) noexcept;
236 inline void ref(
T& obj) noexcept;
240 inline void ref(
T*
p) noexcept;
272 explicit operator bool() const noexcept {
return bool(ptr_); }
275 operator const T&()
const {
return cref(); }
292 inline void operator=(std::nullptr_t) noexcept;
301 bool valid() const noexcept {
return bool(ptr_); }
307 bool empty() const noexcept {
return !ptr_; }
static refPtr< T > New(Args &&... args)
Construct refPtr of T with forwarding arguments.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
A class for handling words, derived from Foam::string.
A class for managing temporary objects.
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference)
refPtr< T > shallowClone() const noexcept
void reset(std::unique_ptr< T > &&other)
Clear existing and transfer ownership from unique_ptr.
T * get() noexcept
Return pointer without nullptr checking.
T element_type
Type of object being managed or referenced.
const T * get() const noexcept
Return const pointer without nullptr checking.
bool valid() const noexcept
Identical to good(), or bool operator.
void clear() const noexcept
void reset(refPtr< T > &&other) noexcept
Clear existing and transfer ownership.
void reset(autoPtr< T > &&other) noexcept
Clear existing and transfer ownership from autoPtr.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool movable() const noexcept
True if this is a non-null managed pointer.
const T & operator*() const
Return const reference to the object.
Foam::refCount::zero refCount
Null reference counter class.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A non-counting (dummy) refCount.
const T & operator()() const
Return const reference to the object - same as cref() method.
bool empty() const noexcept
Deprecated(2020-07) True if a null managed pointer.
constexpr refPtr() noexcept
Construct with no managed pointer.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
static refPtr< T > NewFrom(Args &&... args)
Construct refPtr from derived type with forwarding arguments.
T * pointer
Pointer to type of object being managed or referenced.
bool good() const noexcept
True if pointer/reference is non-null.
void operator=(const refPtr< T > &other)
Transfer ownership of the managed pointer.
Foam::argList args(argc, argv)
const T * operator->() const
Dereferences (const) pointer to the managed object.
static word typeName()
The type-name, constructed from type-name of T.
A class for managing references or pointers (no reference counting)
bool is_const() const noexcept
If the stored/referenced content is const.