Multi-typed value. A variant is a value of any type from a fixed set of bounded types, the active bounded type may be changed dynamically.
More...
|
| | variant () |
| | First default constructible bounded type is set as the value. More...
|
| |
| template<class T > |
| | variant (T &&val) |
| | Attempts to copy/move construct any bounded type, otherwise first bounded type constructible with val is set as the value. More...
|
| |
| template<class... Args> |
| | variant (Args &&...args) |
| | First bounded type constructible with args is set as the value. More...
|
| |
| | variant (const variant &rhs) |
| |
| | variant (variant &rhs) |
| |
| | variant (variant &&rhs) |
| |
| | ~variant () |
| |
| template<class T > |
| void | bind (T &&val) |
| | Bind reference to object. First bounded reference type bindable to rhs is set as the value. More...
|
| |
| template<class T > |
| variant & | operator= (T &&val) |
| | Attempts to copy/move-assign to any bounded type, otherwise first bounded type assignable to val is set as the value. More...
|
| |
| variant & | operator= (const variant &rhs) |
| |
| variant & | operator= (variant &rhs) |
| |
| variant & | operator= (variant &&rhs) |
| |
| szt | size () const |
| | Get number of bounded types. More...
|
| |
| szt | type () const |
| | Get active bounded type id, range [0, size) More...
|
| |
| template<class T > |
| T & | get () |
| | Get variant value as type. Throws VariantError if the active bounded type is not convertible to the requested type. More...
|
| |
| template<class T > |
| const T & | get () const |
| |
| template<class R , class Func , class... Args> |
| R | visit (Func &&f, Args &&...args) |
| | Visit stored value using functor. Calls functor(stored_value, args...) if such a call is valid and returns the result. More...
|
| |
| template<class R , class Func , class... Args> |
| R | visit (Func &&f, Args &&...args) const |
| |
| template<class Func , class... Args> |
| void | visit (Func &&f, Args &&...args) |
| | Visit for void result type. Does nothing (no throw) if the visitor does not accept the active bounded type. More...
|
| |
| template<class Func , class... Args> |
| void | visit (Func &&f, Args &&...args) const |
| |
template<class... Types>
class honey::variant< Types >
Multi-typed value. A variant is a value of any type from a fixed set of bounded types, the active bounded type may be changed dynamically.
Supports const/ref bounded types. A ref must be bound before it can be used, either construct with an object ref or call bind(). All assignments operate on the bound object.
A variant is implicitly convertible to any of its bounded types. Implicit conversion throws VariantError if the active bounded type is not convertible to the requested type.
template<class... Types>
template<class T >
Attempts to copy/move-assign to any bounded type, otherwise first bounded type assignable to val is set as the value.
For a bounded type to be assignable to val it must also be constructible with val, this is necessary for changing the active bounded type. Fails at compile-time if no bounded types are assignable to val.
Bounded reference types must be bound to an object before being assigned, this is asserted at runtime.