Spicy
Public Types | Public Member Functions | List of all members
hilti::rt::StrongReference< T > Class Template Reference

#include <reference.h>

Inheritance diagram for hilti::rt::StrongReference< T >:

Public Types

using Base = std::shared_ptr< T >
 

Public Member Functions

 StrongReference ()
 
 StrongReference (T t)
 
 StrongReference (const ValueReference< T > &t)
 
 StrongReference (std::nullptr_t)
 
 StrongReference (const StrongReference &other)
 
 StrongReference (StrongReference &&other) noexcept
 
bool isNull () const
 
ValueReference< T > derefAsValue () const
 
void reset ()
 
const T & operator* () const
 
T & operator* ()
 
const T * operator-> () const
 
T * operator-> ()
 
 operator bool () const
 
StrongReferenceoperator= (T other)
 
StrongReferenceoperator= (const ValueReference< T > &other)
 
StrongReferenceoperator= (const StrongReference &other)
 
StrongReferenceoperator= (StrongReference &&other) noexcept
 
StrongReferenceoperator= (std::nullptr_t) noexcept
 

Detailed Description

template<typename T>
class hilti::rt::StrongReference< T >

A strong reference to a shared value. This is essentially a shared_ptr that can bind to the values of ValueReference or WeakReference.

Note that different from ValueReference, a strong reference can explicitly be null.

Constructor & Destructor Documentation

◆ StrongReference() [1/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( )
inline

Default constructor creating a null reference.

◆ StrongReference() [2/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( t)
inlineexplicit

Instantiates a reference pointing to a newly allocated value.

Parameters
tinitialization value

◆ StrongReference() [3/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( const ValueReference< T > &  t)
inlineexplicit

Instantiates a reference pointing to the value referred to be an existing ValueReference. This does not copy the value, it will be shared (and managed jointly) afterwards.

◆ StrongReference() [4/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( std::nullptr_t  )
inlineexplicit

Instantiate an unset reference.

◆ StrongReference() [5/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( const StrongReference< T > &  other)
inline

Copy constructor. This copies the reference, not the value, which will be shared afterwards.

◆ StrongReference() [6/6]

template<typename T>
hilti::rt::StrongReference< T >::StrongReference ( StrongReference< T > &&  other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ derefAsValue()

template<typename T>
ValueReference<T> hilti::rt::StrongReference< T >::derefAsValue ( ) const
inline

Returns a value reference that is linked to the referred value. If the strong reference is null, the returned reference will be so, too.

◆ isNull()

template<typename T>
bool hilti::rt::StrongReference< T >::isNull ( ) const
inline

Returns true if the reference does not refer any value.

◆ operator bool()

template<typename T>
hilti::rt::StrongReference< T >::operator bool ( ) const
inlineexplicit

Returns true if the reference is not null.

◆ operator*() [1/2]

template<typename T>
const T& hilti::rt::StrongReference< T >::operator* ( ) const
inline

Returns the contained value.

Exceptions
NullReferenceif the instance is null.

◆ operator*() [2/2]

template<typename T>
T& hilti::rt::StrongReference< T >::operator* ( )
inline

Returns the contained value.

Exceptions
NullReferenceif the instance is null.

◆ operator->() [1/2]

template<typename T>
const T* hilti::rt::StrongReference< T >::operator-> ( ) const
inline

Returns a pointer to the contained value.

Exceptions
NullReferenceif the instance is null.

◆ operator->() [2/2]

template<typename T>
T* hilti::rt::StrongReference< T >::operator-> ( )
inline

Returns a pointer to the contained value.

Exceptions
NullReferenceif the instance is null.

◆ operator=() [1/5]

template<typename T>
StrongReference& hilti::rt::StrongReference< T >::operator= ( other)
inline

Reinitializes the reference with a newly allocated value, releasing any previous ownership still held.

Parameters
tvalue to allocate and then refer to

◆ operator=() [2/5]

template<typename T>
StrongReference& hilti::rt::StrongReference< T >::operator= ( const ValueReference< T > &  other)
inline

Reinitialized the reference to now point to to the value referred to be an existing ValueReference. This does not copy that value, it will be shared (and managed jointly) afterwards.

◆ operator=() [3/5]

template<typename T>
StrongReference& hilti::rt::StrongReference< T >::operator= ( const StrongReference< T > &  other)
inline

Copy assignment. This will share ownership, not copy the value.

◆ operator=() [4/5]

template<typename T>
StrongReference& hilti::rt::StrongReference< T >::operator= ( StrongReference< T > &&  other)
inlinenoexcept

Move assignment.

◆ operator=() [5/5]

template<typename T>
StrongReference& hilti::rt::StrongReference< T >::operator= ( std::nullptr_t  )
inlinenoexcept

Reset pointer.

◆ reset()

template<typename T>
void hilti::rt::StrongReference< T >::reset ( )
inline

Resets the reference to a null value, releasing any ownership it still holds.


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