Template Class Variable

Inheritance Relationships

Base Type

Class Documentation

template<typename T>
class uconfig::Variable : public uconfig::Object

Variable object.

tparam T

Type of underlying variable to store.

Public Types

template<typename F>
using iface_type = VariableIface<T, F>

Public Functions

Variable()

Constructor.

Variable(T &&init_value)

Constructor.

Variable(const T &init_value)

Constructor.

Variable(const Variable<T>&) = default

Copy constructor.

Variable<T> &operator=(const Variable<T>&) = default

Copy assignment.

Variable(Variable<T> &&other) noexcept = default

Move constructor.

Variable<T> &operator=(Variable<T> &&other) noexcept = default

Move assignment.

Variable<T> &operator=(T &&other) noexcept

Move assignment from T.

virtual ~Variable() = default

Destructor.

virtual bool Initialized() const noexcept override

Check if variable has a value.

Returns

true if it has, false otherwise.

virtual bool Optional() const noexcept override

Check if variable is marked as optional.

Returns

true if has been, false otherwise.

T &Get()

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A reference to the value.

const T &Get() const

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A const reference to the value.

T &operator*()

Dereference operator.

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A reference to the value.

const T &operator*() const

Dereference operator.

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A const reference to the value.

T *operator->()

Structure dereference operator.

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A pointer to the value.

const T *operator->() const

Structure dereference operator.

Read the value.

Throws

uconfig::Error – Thrown if variable has no value.

Returns

A const pointer to the value.

explicit operator T&()

Explicit conversation to T&.

Throws

uconfig::Error – Thrown if variable has no value.

explicit operator const T&() const

Explicit conversation to const T&.

Throws

uconfig::Error – Thrown if variable has no value.

Protected Attributes

bool optional_ = false
std::optional<T> value_ = std::nullopt

Stored value or none.

Friends

friend class VariableIface