71 ptr_(const_cast<T*>(&obj)),
102 <<
"Attempted copy/move of a deallocated " 133 <<
"Attempted copy/move of a deallocated " 160 reset(
const_cast<tmp<T>&
>(rhs), reuse);
169 reset(
const_cast<tmp<T>&
>(rhs),
false);
196 return (is_pointer() && ptr_);
203 if (is_pointer() && !ptr_)
206 << this->typeName() <<
" deallocated" 220 <<
"Attempted non-const reference to const object: " 224 else if (is_pointer() && !ptr_)
227 << this->typeName() <<
" deallocated" 243 dup.type_ = (is_const() ? CREF : REF);
270 << this->typeName() <<
" deallocated" 283 return ptr_->clone().ptr();
320 other.ptr_ =
nullptr;
363 type_ = (ptr_ ? CREF : PTR);
371 ptr_ =
const_cast<T*
>(&obj);
380 ptr_ =
const_cast<T*
>(
p);
381 type_ = (ptr_ ? CREF : PTR);
399 type_ = (ptr_ ? REF : PTR);
426 << this->typeName() <<
" deallocated" 439 <<
"Attempt to cast const object to non-const: " 446 << this->typeName() <<
" deallocated" 460 << this->typeName() <<
" deallocated" 474 <<
"Attempt to cast const object to non-const: " 481 << this->typeName() <<
" deallocated" 500 if (other.is_pointer())
505 other.ptr_ =
nullptr;
511 <<
"Attempted assignment of a deallocated " 519 <<
"Attempted assignment of an object reference of type " 542 return tmp<T>(cref());
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void operator=(const refPtr< T > &other)
Transfer ownership of managed pointer.
T * get() noexcept
Return pointer without nullptr checking.
A class for handling words, derived from Foam::string.
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.
errorManip< error > abort(error &err)
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T * release() noexcept
Release ownership and return the pointer. A no-op for reference objects (returns nullptr).
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference)
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...
refPtr< T > shallowClone() const noexcept
Return a shallow copy as a wrapped reference, preserving the const/non-const status.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
bool is_const() const noexcept
If the stored/referenced content is const.
~refPtr() noexcept
Destructor: deletes managed pointer.
void reset(T *p=nullptr) noexcept
Delete managed pointer and set to new given pointer.