39 if (ptr_->count() > 1)
42 <<
"Attempt to create more than 2 tmp's referring to the same" 43 " object of type tmp<" <<
typeid(
T).
name() <<
'>' 82 if (ptr_ && !ptr_->unique())
85 <<
"Attempted construction of a " 87 <<
" from non-unique pointer" 96 ptr_(const_cast<T*>(&obj)),
138 <<
"Attempted copy/move of a deallocated " 169 <<
"Attempted copy/move of a deallocated " 198 return (is_pointer() && ptr_ && ptr_->unique());
205 if (is_pointer() && !ptr_)
208 << this->typeName() <<
" deallocated" 222 <<
"Attempted non-const reference to const object: " 226 else if (is_pointer() && !ptr_)
229 << this->typeName() <<
" deallocated" 243 << this->typeName() <<
" deallocated" 252 <<
"Attempt to acquire pointer to object referred to" 253 <<
" by multiple temporaries of type " 265 return ptr_->clone().ptr();
272 if (is_pointer() && ptr_)
309 other.ptr_ =
nullptr;
325 type_ = (ptr_ ? CREF : PTR);
333 ptr_ =
const_cast<T*
>(&obj);
342 ptr_ =
const_cast<T*
>(
p);
343 type_ = (ptr_ ? CREF : PTR);
361 type_ = (ptr_ ? REF : PTR);
385 if (is_pointer() && !ptr_)
388 << this->typeName() <<
" deallocated" 402 <<
"Attempt to cast const object to non-const: " 406 else if (is_pointer() && !ptr_)
409 << this->typeName() <<
" deallocated" 428 if (other.is_pointer())
433 other.ptr_ =
nullptr;
439 <<
"Attempted assignment of a deallocated " 447 <<
"Attempted assignment of an object reference of type " 467 other.ptr_ =
nullptr;
478 <<
"Attempted copy of a deallocated " 482 else if (!
p->unique())
485 <<
"Attempted assignment of a " 487 <<
" to non-unique pointer" static word typeName()
The type-name, constructed from type-name of T.
constexpr tmp() noexcept
Construct with no managed pointer.
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.
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.
~tmp() noexcept
Destructor: deletes managed pointer when the ref-count is 0.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
errorManip< error > abort(error &err)
const T * operator->() const
Dereferences (const) pointer to the managed object.
void swap(tmp< T > &other) noexcept
Swaps the managed object with other.
void operator=(const tmp< T > &other)
Transfer ownership of the managed pointer.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
void reset(tmp< T > &&other) noexcept
Clear existing and transfer ownership.