75 mutable refType type_;
148 template<class... Args>
160 template<
class U,
class... Args>
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>
261 inline void cref(
const T& obj)
noexcept;
265 inline void cref(
const T*
p)
noexcept;
274 inline void ref(
T& obj)
noexcept;
315 explicit operator bool() const
noexcept {
return bool(ptr_); }
318 operator const T&()
const {
return cref(); }
343 void operator=(std::unique_ptr<T>&& other) {
reset(other.release()); }
353 inline operator tmp<T>();
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing references or pointers (no reference counting).
void operator=(std::nullptr_t) noexcept
Reset via assignment from literal nullptr.
constexpr refPtr() noexcept
Construct with no managed pointer.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
Foam::refCount::zero refCount
Null reference counter class.
bool is_reference() const noexcept
True if this is a reference (not a pointer).
void operator=(std::unique_ptr< T > &&other)
Transfer ownership by move assignment from unique_ptr.
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference).
static word typeName()
The type-name, constructed from type-name of T.
const T & operator*() const
Return const reference to the object.
const T & cref() const
Return const reference to the object or 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,...
bool empty() const noexcept
Deprecated(2020-07) True if a null managed pointer.
void ref(const tmp< T > &)=delete
Avoid inadvertent casting (object).
T * get() noexcept
Return pointer without nullptr checking.
bool good() const noexcept
True if pointer/reference is non-null.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
void ref(const autoPtr< T > &)=delete
Avoid inadvertent casting (to object or pointer).
void cref(const autoPtr< T > &)=delete
Avoid inadvertent casting (to object or pointer).
T * pointer
Pointer to type of object being managed or referenced.
const T * get() const noexcept
Return const pointer without nullptr checking.
T * release() noexcept
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
void operator=(refPtr< T > &&other) noexcept
Clear existing and transfer ownership.
void operator=(T *p)=delete
No copy assignment from plain pointer (uncontrolled access).
bool movable() const noexcept
True if this is a non-null managed pointer.
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.
bool valid() const noexcept
Identical to good(), or bool operator.
void reset(std::unique_ptr< T > &&other)
Clear existing and transfer ownership from unique_ptr.
void reset(autoPtr< T > &&other) noexcept
Clear existing and transfer ownership from autoPtr.
const T * operator->() const
Dereferences (const) pointer to the managed object.
bool is_const() const noexcept
If the stored/referenced content is const.
void operator=(const autoPtr< T > &)=delete
No copy assignment from autoPtr (can have unintended behaviour).
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
void cref(const tmp< T > &)=delete
Avoid inadvertent casting (to object).
void operator=(const tmp< T > &)=delete
No copy assignment from tmp.
static refPtr< T > NewFrom(Args &&... args)
Construct refPtr from derived type with forwarding arguments.
T element_type
Type of object being managed or referenced.
void operator=(autoPtr< T > &&other) noexcept
Transfer ownership by move assignment from autoPtr.
refPtr< T > shallowClone() const noexcept
Return a shallow copy as a wrapped reference, preserving the const/non-const status.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
void operator=(const refPtr< T > &other)
Transfer ownership of managed pointer.
static refPtr< T > New(Args &&... args)
Construct refPtr with forwarding arguments.
const T & operator()() const
Return const reference to the object - same as cref() method.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)
#define FOAM_DEPRECATED_FOR(since, replacement)
A non-counting (dummy) refCount.