tmpNrc< T > Class Template Reference

A class for managing temporary objects without reference counting. More...

Inheritance diagram for tmpNrc< T >:
[legend]

Public Types

typedef T element_type
 Type of object being managed. More...
 
typedef T * pointer
 Pointer to type of object being managed. More...
 
typedef Foam::refCount::zero refCount
 Null reference counter class. More...
 

Public Member Functions

constexpr tmpNrc () noexcept
 Construct with no managed pointer. More...
 
constexpr tmpNrc (std::nullptr_t) noexcept
 Construct with no managed pointer. More...
 
 tmpNrc (T *p) noexcept
 Construct, taking ownership of the pointer. More...
 
 tmpNrc (const T &obj) noexcept
 Construct for a const reference to an object. More...
 
 tmpNrc (tmpNrc< T > &&t) noexcept
 Move construct, transferring ownership. More...
 
 tmpNrc (const tmpNrc< T > &t)
 Copy construct. More...
 
 tmpNrc (const tmpNrc< T > &t, bool reuse)
 Copy construct. Optionally reusing pointer. More...
 
 ~tmpNrc ()
 Destructor: deletes managed pointer. More...
 
bool isTmp () const noexcept
 True if this is a managed pointer (not a const reference) More...
 
bool empty () const noexcept
 True if this is a non-null managed pointer. More...
 
bool valid () const noexcept
 
bool movable () const noexcept
 True if this is a non-null managed pointer with a unique ref-count. More...
 
word typeName () const
 Return type-name of the tmp, constructed from type-name of T. More...
 
T * get () noexcept
 Return pointer without nullptr checking. More...
 
const T * get () const noexcept
 Return const pointer without nullptr checking. More...
 
const T & cref () const
 
T & ref () const
 
T & constCast () const
 Non-const dereference, even if the object is const. More...
 
T * ptr () const
 
void clear () const noexcept
 
void reset () noexcept
 Release ownership of managed temporary object. More...
 
void reset (T *p) noexcept
 Delete managed temporary object and set to new given pointer. More...
 
void reset (tmpNrc< T > &&other) noexcept
 Clear existing and transfer ownership. More...
 
void cref (const T &obj) noexcept
 Delete managed temporary object and set to const reference. More...
 
void swap (tmpNrc< T > &other) noexcept
 Swaps the managed object with other. More...
 
const T & operator() () const
 Return const reference to the object. More...
 
 operator const T & () const
 Cast to underlying data type, using the cref() method. More...
 
const T * operator-> () const
 Dereferences (const) pointer to the managed object. More...
 
T * operator-> ()
 Dereferences (non-const) pointer to the managed object. More...
 
 operator bool () const noexcept
 Is non-null managed pointer or const object reference : valid() More...
 
void operator= (T *p)
 Take ownership of the pointer. More...
 
void operator= (const tmpNrc< T > &t)
 Transfer ownership of the managed pointer. More...
 
void operator= (tmpNrc< T > &&other) noexcept
 Clear existing and transfer ownership. More...
 
 operator tmp< T > ()
 Conversion to tmp. More...
 
void operator= (std::nullptr_t)=delete
 No assignment from literal nullptr. More...
 
template<class... Args>
Foam::tmpNrc< T > New (Args &&... args)
 
template<class U , class... Args>
Foam::tmpNrc< T > NewFrom (Args &&... args)
 

Static Public Member Functions

template<class... Args>
static tmpNrc< T > New (Args &&... args)
 Construct tmpNrc of T with forwarding arguments. More...
 
template<class U , class... Args>
static tmpNrc< T > NewFrom (Args &&... args)
 Construct tmpNrc from derived type with forwarding arguments. More...
 

Detailed Description

template<class T>
class Foam::tmpNrc< T >

A class for managing temporary objects without reference counting.

Source files
See also
Foam::autoPtr Foam::tmp

Definition at line 56 of file tmpNrc.H.

Member Typedef Documentation

◆ element_type

typedef T element_type

Type of object being managed.

Definition at line 79 of file tmpNrc.H.

◆ pointer

typedef T* pointer

Pointer to type of object being managed.

Definition at line 82 of file tmpNrc.H.

◆ refCount

Null reference counter class.

Definition at line 86 of file tmpNrc.H.

Constructor & Destructor Documentation

◆ tmpNrc() [1/7]

constexpr tmpNrc ( )
inlineconstexprnoexcept

Construct with no managed pointer.

Definition at line 53 of file tmpNrcI.H.

◆ tmpNrc() [2/7]

constexpr tmpNrc ( std::nullptr_t  )
inlineconstexprnoexcept

Construct with no managed pointer.

Definition at line 61 of file tmpNrcI.H.

◆ tmpNrc() [3/7]

tmpNrc ( T *  p)
inlineexplicitnoexcept

Construct, taking ownership of the pointer.

Definition at line 69 of file tmpNrcI.H.

◆ tmpNrc() [4/7]

tmpNrc ( const T &  obj)
inlinenoexcept

Construct for a const reference to an object.

Definition at line 77 of file tmpNrcI.H.

◆ tmpNrc() [5/7]

tmpNrc ( tmpNrc< T > &&  t)
inlinenoexcept

Move construct, transferring ownership.

Definition at line 85 of file tmpNrcI.H.

◆ tmpNrc() [6/7]

tmpNrc ( const tmpNrc< T > &  t)
inline

Copy construct.

Definition at line 96 of file tmpNrcI.H.

◆ tmpNrc() [7/7]

tmpNrc ( const tmpNrc< T > &  t,
bool  reuse 
)
inline

Copy construct. Optionally reusing pointer.

Definition at line 118 of file tmpNrcI.H.

◆ ~tmpNrc()

~tmpNrc ( )
inline

Destructor: deletes managed pointer.

Definition at line 147 of file tmpNrcI.H.

Member Function Documentation

◆ New() [1/2]

static tmpNrc<T> New ( Args &&...  args)
inlinestatic

Construct tmpNrc of T with forwarding arguments.

Parameters
argslist of arguments with which an instance of T will be constructed.
Note
Similar to std::make_shared, but the overload for array types is not disabled.

Referenced by AMIInterpolation::calculate().

Here is the caller graph for this function:

◆ NewFrom() [1/2]

static tmpNrc<T> NewFrom ( Args &&...  args)
inlinestatic

Construct tmpNrc from derived type with forwarding arguments.

Parameters
argslist of arguments with which an instance of U will be constructed.
Note
Similar to New but for derived types

◆ isTmp()

bool isTmp ( ) const
inlinenoexcept

True if this is a managed pointer (not a const reference)

Definition at line 156 of file tmpNrcI.H.

Referenced by tmpNrc< Foam::PrimitivePatch >::operator=().

Here is the caller graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

True if this is a non-null managed pointer.

Definition at line 163 of file tmpNrcI.H.

◆ valid()

bool valid ( ) const
inlinenoexcept

True if this is a non-null managed pointer, or is a const object reference

Definition at line 170 of file tmpNrcI.H.

◆ movable()

bool movable ( ) const
inlinenoexcept

True if this is a non-null managed pointer with a unique ref-count.

Definition at line 177 of file tmpNrcI.H.

◆ typeName()

Foam::word typeName ( ) const
inline

Return type-name of the tmp, constructed from type-name of T.

Definition at line 184 of file tmpNrcI.H.

◆ get() [1/2]

T * get ( )
inlinenoexcept

Return pointer without nullptr checking.

Definition at line 191 of file tmpNrcI.H.

◆ get() [2/2]

const T * get ( ) const
inlinenoexcept

Return const pointer without nullptr checking.

Definition at line 198 of file tmpNrcI.H.

◆ cref() [1/2]

const T & cref ( ) const
inline

Return the const object reference or a const reference to the contents of a non-null managed pointer.

Fatal for a null managed pointer

Definition at line 205 of file tmpNrcI.H.

◆ ref()

T & ref ( ) const
inline

Return non-const reference to the contents of a non-null managed pointer.

Fatal for a null managed pointer or if the object is const.

Definition at line 222 of file tmpNrcI.H.

◆ constCast()

T & constCast ( ) const
inline

Non-const dereference, even if the object is const.

This is similar to ref(), but applies a const_cast to access const objects. Fatal for a null managed pointer.

Definition at line 246 of file tmpNrcI.H.

◆ ptr()

T * ptr ( ) const
inline

Return managed pointer for reuse, or clone() the const object reference.

Definition at line 260 of file tmpNrcI.H.

◆ clear()

void clear ( ) const
inlinenoexcept

If object pointer points to valid object: delete object and set pointer to nullptr

Definition at line 282 of file tmpNrcI.H.

◆ reset() [1/3]

void reset ( )
inlinenoexcept

Release ownership of managed temporary object.

After this call no object is managed.

Definition at line 293 of file tmpNrcI.H.

◆ reset() [2/3]

void reset ( T *  p)
inlinenoexcept

Delete managed temporary object and set to new given pointer.

Definition at line 302 of file tmpNrcI.H.

◆ reset() [3/3]

void reset ( tmpNrc< T > &&  other)
inlinenoexcept

Clear existing and transfer ownership.

Definition at line 311 of file tmpNrcI.H.

◆ cref() [2/2]

void cref ( const T &  obj)
inlinenoexcept

Delete managed temporary object and set to const reference.

Definition at line 328 of file tmpNrcI.H.

◆ swap()

void swap ( tmpNrc< T > &  other)
inlinenoexcept

Swaps the managed object with other.

Definition at line 337 of file tmpNrcI.H.

◆ operator()()

const T & operator() ( ) const
inline

Return const reference to the object.

Identical to cref() method.

Definition at line 358 of file tmpNrcI.H.

◆ operator const T &()

operator const T & ( ) const
inline

Cast to underlying data type, using the cref() method.

Definition at line 365 of file tmpNrcI.H.

◆ operator->() [1/2]

const T * operator-> ( ) const
inline

Dereferences (const) pointer to the managed object.

Fatal for a null managed pointer.

Definition at line 372 of file tmpNrcI.H.

◆ operator->() [2/2]

T * operator-> ( )
inline

Dereferences (non-const) pointer to the managed object.

Fatal for a null managed pointer or if the object is const.

Definition at line 386 of file tmpNrcI.H.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

Is non-null managed pointer or const object reference : valid()

Definition at line 409 of file tmpNrcI.H.

◆ operator=() [1/4]

void operator= ( T *  p)
inline

Take ownership of the pointer.

Fatal for a null pointer, or when the pointer is non-unique.

Definition at line 416 of file tmpNrcI.H.

◆ operator=() [2/4]

void operator= ( const tmpNrc< T > &  t)
inline

Transfer ownership of the managed pointer.

Fatal for a null managed pointer or if the object is const.

Definition at line 433 of file tmpNrcI.H.

◆ operator=() [3/4]

void operator= ( tmpNrc< T > &&  other)
inlinenoexcept

Clear existing and transfer ownership.

Definition at line 466 of file tmpNrcI.H.

◆ operator tmp< T >()

operator tmp< T > ( )
inline

Conversion to tmp.

Definition at line 483 of file tmpNrcI.H.

◆ operator=() [4/4]

void operator= ( std::nullptr_t  )
delete

No assignment from literal nullptr.

Consistent with run-time check for nullptr on assignment.

◆ New() [2/2]

Foam::tmpNrc<T> New ( Args &&...  args)
inline

Definition at line 36 of file tmpNrcI.H.

◆ NewFrom() [2/2]

Foam::tmpNrc<T> NewFrom ( Args &&...  args)
inline

Definition at line 44 of file tmpNrcI.H.


The documentation for this class was generated from the following files: