Simple optional reference type. More...
Simple optional reference type.
This class template provides a convenient way around the std::optional limitation of not allowing references. This is useful for storing references to diagram elements in various views
, and writing methods which return can return an empty value if the diagram does not contain something.
This is not an owning type - it will not accept an rvalue - the actual value must be stored somewhere else as lvalue or some kind of smart pointer.
T | Type of reference |
#include <types.h>
Public Types | |
using | optional_type = T |
Public Member Functions | |
optional_ref ()=default | |
optional_ref (T *value) | |
optional_ref (const T *value) | |
optional_ref (T &value) | |
optional_ref (const T &value) | |
optional_ref (optional_ref &right) | |
template<typename V , typename = std::enable_if< std::is_base_of_v<optional_type, typename V::optional_type> || std::is_same_v<optional_type, typename V::optional_type>>> | |
optional_ref (const V &t) | |
template<typename V , typename = std::enable_if< std::is_base_of_v<optional_type, typename V::optional_type> || std::is_same_v<optional_type, typename V::optional_type>>> | |
optional_ref (V &&t) | |
template<typename V , typename = std::enable_if<std::is_base_of_v<optional_type, V>>> | |
optional_ref (const std::reference_wrapper< V > &t) | |
optional_ref & | operator= (const optional_ref &right) |
optional_ref & | operator= (optional_ref &&right) noexcept |
bool | has_value () const noexcept |
operator bool () const noexcept | |
const T & | value () const |
T & | value () |
T & | operator* () |
const T & | operator* () const |
void | reset () |
T * | get () const |
Private Attributes | |
T * | value_ {nullptr} |
using clanguml::common::optional_ref< T >::optional_type = T |
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
private |