70 ptr_(
const_cast<T*
>(&obj)),
101 <<
"Attempted copy/move of a deallocated "
132 <<
"Attempted copy/move of a deallocated "
195 return (type_ == CREF);
203 return (type_ < REF_Types);
211 return (type_ > REF_Types);
225 if (!ptr_ && is_pointer())
228 << this->
typeName() <<
" deallocated"
242 <<
"Attempted non-const reference to const object: "
246 else if (!ptr_ && is_pointer())
249 << this->
typeName() <<
" deallocated"
265 dup.type_ = (
is_const() ? CREF : REF);
292 << this->
typeName() <<
" deallocated"
305 return ptr_->clone().ptr();
342 other.ptr_ =
nullptr;
375template<
class... Args>
379 ptr_ =
new T(std::forward<Args>(
args)...);
396 type_ = (ptr_ ? CREF : PTR);
404 ptr_ =
const_cast<T*
>(&obj);
413 ptr_ =
const_cast<T*
>(
p);
414 type_ = (ptr_ ? CREF : PTR);
432 type_ = (ptr_ ? REF : PTR);
459 << this->
typeName() <<
" deallocated"
472 <<
"Attempt to cast const object to non-const: "
479 << this->
typeName() <<
" deallocated"
493 << this->
typeName() <<
" deallocated"
507 <<
"Attempt to cast const object to non-const: "
514 << this->
typeName() <<
" deallocated"
533 if (other.is_pointer())
538 other.ptr_ =
nullptr;
544 <<
"Attempted assignment of a deallocated "
552 <<
"Attempted assignment of an object reference of type "
575 return tmp<T>(cref());
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing references or pointers (no reference counting).
constexpr refPtr() noexcept
Construct with no managed pointer.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
bool is_reference() const noexcept
True if this is a reference (not a pointer).
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.
void swap(refPtr< T > &other) noexcept
Swaps the managed object with other.
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.
~refPtr() noexcept
Destructor: deletes managed pointer.
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.
const T * operator->() const
Dereferences (const) pointer to the managed object.
bool is_const() const noexcept
If the stored/referenced content is const.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
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.
A class for managing temporary objects.
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference).
T * get() noexcept
Return pointer without nullptr checking.
bool is_const() const noexcept
If the stored/referenced content is const.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for handling words, derived from Foam::string.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)