Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/variant.hpp"
Typesafe union record.
A Variant element may carry an embedded value of any of the predefined types. The type may not be rebound: It must be created holding some value and each instance is fixed to the specific type used at construction time. Yet within the same type, variant elements are copyable and assignable. The embedded type is erased on the signature, but knowledge about the actual type is retained, encoded into the embedded VTable. Thus, any access to the variant's value requires knowledge of the type in question, but type mismatch will provoke an exception at runtime. Generic access is possible using a visitor.
Definition at line 224 of file variant.hpp.
Public Types | |
enum | { SIZ = meta::maxSize<typename TYPES::List>::value, ALIGN = meta::maxAlign<typename TYPES::List>::value } |
template<template< class > class _P_> | |
using | FirstMatching = variant::FirstMatchingType< TYPES, _P_ > |
Metafunction to pick the first of the variant's types, which satisfies the given trait or predicate template. More... | |
template<typename RET > | |
using | VisitorConstFunc = typename variant::VFunc< RET >::template VisitorInterface< meta::ConstAll< typename TYPES::List > > |
template<typename RET > | |
using | VisitorFunc = typename variant::VFunc< RET >::template VisitorInterface< TYPES > |
Public Member Functions | |
template<typename X > | |
Variant (X &&x) | |
Variant (Variant &ref) | |
Variant (Variant const &ref) | |
Variant (Variant &&rref) | |
void | accept (Visitor &visitor) |
bool | accept (Predicate &visitor) const |
string | accept (Renderer &visitor) const |
template<typename X > | |
X & | get () |
template<typename X > | |
X const & | get () const |
operator string () const | |
diagnostic helper | |
template<typename X > | |
Variant & | operator= (X x) |
Variant & | operator= (Variant &ovar) |
Variant & | operator= (Variant const &ovar) |
Variant & | operator= (Variant &&rvar) |
Classes | |
struct | Buff |
concrete inner capsule specialised for a given type More... | |
struct | Buffer |
Inner capsule managing the contained object (interface) More... | |
class | Predicate |
class | Renderer |
class | Visitor |
to be implemented by the client for visitation More... | |
Protected Member Functions | |
template<typename X > | |
Buff< X > & | buff () |
Buffer & | buffer () |
Buffer const & | buffer () const |
template<typename X > | |
X * | maybeGet () |
Private Types | |
enum | { BUFFSIZE = sizeof(Buffer) } |
Private Attributes | |
char | storage_ [BUFFSIZE] |
embedded buffer actually holding the concrete Buff object, which in turn holds and manages the target object. More... | |
using FirstMatching = variant::FirstMatchingType<TYPES, _P_> |
Metafunction to pick the first of the variant's types, which satisfies the given trait or predicate template.
FirstMatching<P>::Type
Definition at line 268 of file variant.hpp.
|
inlineprotected |
for derived classes to implement custom access logic
Definition at line 437 of file variant.hpp.
|
private |
embedded buffer actually holding the concrete Buff object, which in turn holds and manages the target object.
Definition at line 408 of file variant.hpp.