![]() |
Spicy
|
#include <reference.h>
Public Member Functions | |
ValueReference () | |
ValueReference (T t) | |
ValueReference (std::shared_ptr< T > t) | |
ValueReference (const ValueReference &other) | |
ValueReference (ValueReference &&other) noexcept=default | |
~ValueReference () | |
bool | isNull () const |
const T * | get () const |
std::shared_ptr< T > | asSharedPtr () const |
void | reset () |
const T & | operator* () const |
T & | operator* () |
const T * | operator-> () const |
T * | operator-> () |
operator const T & () const | |
bool | operator== (const ValueReference< T > &other) const |
bool | operator== (const T &other) const |
bool | operator!= (const ValueReference< T > &other) const |
bool | operator!= (const T &other) const |
ValueReference & | operator= (T other) |
ValueReference & | operator= (const ValueReference &other) |
ValueReference & | operator= (ValueReference &&other) noexcept |
ValueReference & | operator= (std::shared_ptr< T > other) noexcept |
Static Public Member Functions | |
static ValueReference | self (T *t) |
Class representing HILTI's value_ref<T>
type. This class stores an value of type T on the heap and imposes value semantics on it. In particular, copying a ValueReference
will link the new instance to its own copy of the managed value.
Generally, a value reference will always have a value associated with it. There are however ways to create it without one. Accesses that require a value, are checked and will abort in that case.
Other reference types (StrongReference
, WeakReference
) can bind to an existing value reference, essentially creating handles to its value. They then become joined managers of the value.
Controllable
and hence could turn it into a shared_ptr right there. On the downside, that would mean a shared_from_this()
call even if the resulting instance is never used – which with the current code generator could happen frequently (at least once we optimized to use this
instead of the self
wrapper when possible). So leaving it alone for now.
|
inline |
Instantiates a reference containing a new value of T
initialized to its default value.
|
inline |
Instantiates a reference containing a new value of T
initialized to a given value.
t | value to initialize new instance with |
|
inlineexplicit |
Instantiates a new reference from an existing std::shared_ptr
to a value of type T
. This does not copy the pointer's target value; the new reference will keep a pointer to the same value.
This constructor is mostly for internal purposes to create a new value reference that's associated with an existing StrongReference
.
t | shared pointer to link to |
|
inline |
Copy constructor. The new instance will refer to a copy of the source's value.
|
defaultnoexcept |
Move constructor.
|
inline |
Destructor.
|
inline |
Returns a shared pointer to the referred value. The result may be a null pointer if the instance does not refer to a valid value.
For this to work, the value reference must have either (1) create the contained value itself through one of the standard constructor; or (2) if created through an explicit pointer constructor, the instance must be located on the heap and be the instance of a classed derived from Controllable<T>
.
IllegalReference | if no shared pointer can be constructed for the contained instance. |
|
inline |
Returns a pointer to the referred value. The result may be null if the instance does not refer to a valid value.
|
inline |
Returns true if the reference does not contain a value. This will rarely happen, except when explicitly constructed that way through an existing pointer.
|
inline |
Implicitly converts to the contained type.
NullReference | if the instance does not refer to a valid value |
|
inline |
Compares the values of two references.
NullReference | if one of the instances does not refer to a valid value |
|
inline |
Compares the values of two references.
NullReference | if one of the instances does not refer to a valid value |
|
inline |
Returns a reference to the contained value.
NullReference | if the instance does not refer to a valid value |
|
inline |
Returns a reference to the contained value.
NullReference | if the instance does not refer to a valid value |
|
inline |
Returns a pointer to the contained value.
NullReference | if the instance does not refer to a valid value |
|
inline |
Returns a pointer to the contained value.
NullReference | if the instance does not refer to a valid value |
|
inline |
Assigns to the contained value. Assigning does not invalidate other references associated with the same value; they'll see the change.
NullReference | if the instance does not currently refer to a valid value |
|
inline |
Assigns to the contained value. Assigning does not invalidate other references associated with the same value; they'll see the change.
NullReference | if the instance does not currently refer to a valid value |
|
inlinenoexcept |
Assigns to the contained value. Assigning does not invalidate other references associated with the same value; they'll see the change.
NullReference | if the instance does not currently refer to a valid value |
|
inlinenoexcept |
Assigns from an existing std::shared_ptr
to a value of type T
. This does not copy the pointer's target value; we will store a pointer to the same value.
|
inline |
Compares the values of two references.
NullReference | if one of the instances does not refer to a valid value |
|
inline |
Compares the values of two references.
NullReference | if one of the instances does not refer to a valid value |
|
inline |
Resets the contained value to a fresh copy of a T
value initialized to its default.
|
inlinestatic |
Shortcut to create a new instance referring to an existing value of type T
. T
must be derived from Controllable<T>
.
This is for internal use by the code generator to wrap this
inside methods into a value reference.