39 if (ptr_->count() > 1)
42 <<
"Attempt to create more than 2 tmp's referring to"
43 " the same object of type "
55 return "tmp<" +
word(
typeid(
T).
name()) +
'>';
60template<
class... Args>
68template<
class U,
class... Args>
102 <<
"Attempted construction of a "
104 <<
" from non-unique pointer"
113 ptr_(
const_cast<T*
>(&obj)),
155 <<
"Attempted copy of a deallocated "
186 <<
"Attempted copy of a deallocated "
208 return (type_ == PTR && ptr_ && ptr_->unique());
215 if (type_ == PTR && !ptr_)
218 << this->typeName() <<
" deallocated"
232 <<
"Attempted non-const reference to const object: "
236 else if (type_ == PTR && !ptr_)
239 << this->typeName() <<
" deallocated"
250 return const_cast<T&
>(cref());
260 << this->typeName() <<
" deallocated"
269 <<
"Attempt to acquire pointer to object referred to"
270 <<
" by multiple temporaries of type "
282 return ptr_->
clone().ptr();
289 if (type_ == PTR && ptr_)
325 other.ptr_ =
nullptr;
340 type_ = (ptr_ ? CREF : PTR);
348 ptr_ =
const_cast<T*
>(&obj);
357 ptr_ =
const_cast<T*
>(
p);
358 type_ = (ptr_ ? CREF : PTR);
376 type_ = (ptr_ ? REF : PTR);
400 if (type_ == PTR && !ptr_)
403 << this->typeName() <<
" deallocated"
417 <<
"Attempt to cast const object to non-const: "
421 else if (type_ == PTR && !ptr_)
424 << this->typeName() <<
" deallocated"
442 if (other.type_ == PTR)
446 other.ptr_ =
nullptr;
451 <<
"Attempted assignment of a deallocated "
459 <<
"Attempted assignment of an object reference of type "
478 other.ptr_ =
nullptr;
489 <<
"Attempted copy of a deallocated "
496 <<
"Attempted assignment of a "
498 <<
" to non-unique pointer"
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void reset()
Reset to defaults.
bool unique() const noexcept
Return true if the reference count is zero.
A class for managing temporary objects.
void swap(tmp< T > &other) noexcept
Swaps the managed object with other.
static word typeName()
The type-name, constructed from type-name of T.
void clear() const noexcept
bool movable() const noexcept
True if this is a non-null managed pointer with a unique ref-count.
void operator=(const tmp< T > &other)
Transfer ownership of the managed pointer.
const T * operator->() const
Dereferences (const) pointer to the managed object.
~tmp()
Destructor: deletes managed pointer when the ref-count is 0.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
static tmp< T > NewFrom(Args &&... args)
Construct tmp from derived type with forwarding arguments.
constexpr tmp() noexcept
Construct with no managed pointer.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManip< error > abort(error &err)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Foam::argList args(argc, argv)