36 if (ptr_->count() > 1)
39 <<
"Attempt to create more than 2 tmp's referring to" 40 " the same object of type " << typeName()
51 type_(nonReusable ? NON_RESUSABLE_TMP : REUSABLE_TMP),
54 if (tPtr && !tPtr->unique())
57 <<
"Attempted construction of a " << typeName()
58 <<
" from non-unique pointer" 68 ptr_(const_cast<
T*>(&tRef))
87 <<
"Attempted copy of a deallocated " << typeName()
117 if (allowTransfer && type_ == REUSABLE_TMP)
129 <<
"Attempted copy of a deallocated " << typeName()
148 return type_ == REUSABLE_TMP || type_ == NON_RESUSABLE_TMP;
155 return type_ == REUSABLE_TMP;
162 return (isAnyTmp() && !ptr_);
169 return (!isAnyTmp() || (isAnyTmp() && ptr_));
176 return "tmp<" +
word(
typeid(
T).
name()) +
'>';
188 << typeName() <<
" deallocated" 195 <<
"Attempt to acquire non-const reference to const object" 196 <<
" from a " << typeName()
212 << typeName() <<
" deallocated" 219 <<
"Attempt to acquire pointer to object referred to" 220 <<
" by multiple temporaries of type " << typeName()
231 return ptr_->clone().ptr();
239 if (isAnyTmp() && ptr_)
266 << typeName() <<
" deallocated" 286 << typeName() <<
" deallocated" 311 << typeName() <<
" deallocated" 318 <<
"Attempt to cast const object to non-const for a " << typeName()
329 if (isAnyTmp() && !ptr_)
332 << typeName() <<
" deallocated" 348 <<
"Attempted copy of a deallocated " << typeName()
352 if (tPtr && !tPtr->unique())
355 <<
"Attempted assignment of a " << typeName()
356 <<
" to non-unique pointer" 360 type_ = REUSABLE_TMP;
387 <<
"Attempted assignment to a const reference to an object" 388 <<
" of type " <<
typeid(
T).
name()
void clear() const
If object pointer points to valid object:
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const T & operator()() const
Const dereference operator.
T & ref() const
Return non-const reference or generate a fatal error.
bool isTmp() const
Return true if this is really a temporary object.
tmp(T *=0, bool nonReusable=false)
Store object pointer of a non-reusable or reusable temporary object.
T * operator->()
Return object pointer.
word typeName() const
Return the type name of the tmp.
bool valid() const
Is this temporary object valid,.
void operator=(T *)
Assignment to pointer changing this tmp to a temporary T.
A class for handling words, derived from string.
errorManip< error > abort(error &err)
~tmp()
Destructor: deletes temporary object when the reference count is 0.
word name(const complex &)
Return a string representation of a complex.
bool empty() const
Return true if this temporary object empty,.
T * ptr() const
Return tmp pointer for reuse.
A class for managing temporary objects.