Lumiera  0.pre.03
»edit your freedom«
variant-o.hpp File Reference

Go to the source code of this file.

Description

This file defines a simple alternative to boost::variant.

It pulls in fewer headers and has a shorter code path, but also doesn't deal with alignment issues and is not threadsafe.

Values can be stored using operator= . In order to access the value stored in lib::VariantO, you additionally need to define an access "functor"

  • with a typedef "Ret" for the return type
  • providing a static Ret access(ELM&) function for each of the types used in the VariantO "The" typical example for such an access "functor" is the util::AccessCasted template.
Deprecated:
immature first try. Preferably use lib::Variant
Todo:

the instance handling for the accessor seems somewhat clumsy: we're creating a static accessor instance for each type of access functor, and each of these accessors holds a trampoline table. Why are we building a table, while we're using a templated access functor anyway? This table inhibits inlining, and there seems to be no runtime benefit. This whole design indeed was a hastily made (prompted by actual need) first attempt. It should be rewritten from scratch (HIV 4/2015)

///////////////////////////////////////TICKET #738 should be rewritten from scratch

///////////////////////////////////////TICKET #141 write an unit test for variant

See also
wrapperptr.hpp usage example

Definition in file variant-o.hpp.

Classes

struct  Holder< TYPES >::Buffer
 Storage to hold the actual value. More...
 
struct  Holder< TYPES >::CasePrepare< T, BASE, i >
 initialise the dispatcher (trampoline) for the case of accessing type T More...
 
struct  Holder< TYPES >::CaseSelect< FUNCTOR >
 provide a dispatcher table based visitation mechanism More...
 
struct  Holder< TYPES >::Deleter
 
struct  Holder< TYPES >
 internal helper used to build a variant storage wrapper. More...
 
struct  Holder< TYPES >::PlacementAdapter< T, BASE, idx >
 
class  VariantO< TYPES, Access >
 A variant wrapper (typesafe union) capable of holding a value of any of a bounded collection of types. More...
 

Namespaces

 lib
 Implementation namespace for support and library code.