Go to the documentation of this file.
35 template<
class... Args>
43 template<
class U,
class... Args>
79 ptr_(
const_cast<T*
>(&obj)),
110 <<
"Attempted copy of a deallocated " << typeName()
139 <<
"Attempted copy of a deallocated " << typeName()
165 return (!ptr_ && isTmp());
172 return (ptr_ || type_ == CREF);
179 return (type_ == PTR && ptr_);
186 return "tmpNrc<" +
word(
typeid(
T).
name()) +
'>';
212 << typeName() <<
" deallocated"
229 << typeName() <<
" deallocated"
236 <<
"Attempted non-const reference to const object from a "
248 if (isTmp() && !ptr_)
251 << typeName() <<
" deallocated"
255 return const_cast<T&
>(*ptr_);
267 << typeName() <<
" deallocated"
277 return ptr_->clone().ptr();
322 other.ptr_ =
nullptr;
331 ptr_ =
const_cast<T*
>(&obj);
374 if (!ptr_ && isTmp())
377 << typeName() <<
" deallocated"
393 << typeName() <<
" deallocated"
400 <<
"Attempt to cast const object to non-const for a " << typeName()
411 return (ptr_ || type_ == CREF);
423 <<
"Attempted copy of a deallocated " << typeName()
451 <<
"Attempted assignment to a deallocated " << typeName()
458 <<
"Attempted assignment to a const reference to an object"
459 <<
" of type " <<
typeid(
T).
name()
477 other.ptr_ =
nullptr;
~tmpNrc()
Destructor: deletes managed pointer.
A class for handling words, derived from Foam::string.
word typeName() const
Return type-name of the tmp, constructed from type-name of T.
A class for managing temporary objects.
void swap(tmpNrc< T > &other) noexcept
Swaps the managed object with other.
A class for managing temporary objects without reference counting.
word name(const complex &c)
Return string representation of complex.
T & constCast() const
Non-const dereference, even if the object is const.
void operator=(T *p)
Take ownership of the pointer.
void clear() const noexcept
void reset() noexcept
Release ownership of managed temporary object.
errorManip< error > abort(error &err)
static tmpNrc< T > New(Args &&... args)
Construct tmpNrc of T with forwarding arguments.
static tmpNrc< T > NewFrom(Args &&... args)
Construct tmpNrc from derived type with forwarding arguments.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool valid() const noexcept
bool movable() const noexcept
True if this is a non-null managed pointer with a unique ref-count.
bool empty() const noexcept
True if this is a non-null managed pointer.
constexpr tmpNrc() noexcept
Construct with no managed pointer.
Foam::argList args(argc, argv)
const T * operator->() const
Dereferences (const) pointer to the managed object.
bool isTmp() const noexcept
True if this is a managed pointer (not a const reference)
T * get() noexcept
Return pointer without nullptr checking.
const T & operator()() const
Return const reference to the object.