Lumiera  0.pre.03
»edit your freedom«
VariantO< TYPES, Access > Class Template Reference

#include "lib/variant-o.hpp"

Description

template<typename TYPES, template< typename > class Access>
class lib::VariantO< TYPES, Access >

A variant wrapper (typesafe union) capable of holding a value of any of a bounded collection of types.

The value is stored in a local buffer directly within the object and may be accessed by a typesafe visitation.

This utility class is similar to boost::variant and indeed was implemented (5/08) in an effort to replace the latter in a draft solution for the problem of typesafe access to the correct wrapper class from within some builder tool. Well – after finishing this "exercise" I must admit that it is not really much more simple than what boost::variant does internally. At least we are pulling in fewer headers and the actual code path is shorter compared with boost::variant, at the price of being not so generic, no care for alignment issues within the buffer or for thread safety.
Deprecated:
immature first design attempt. obsolete. Please use lib::Variant ////////////////TICKET #738
Parameters
TYPEScollection of possible types to be stored in this variant object
Accesspolicy how to access the stored value

Definition at line 244 of file variant-o.hpp.

Public Member Functions

template<typename TAR >
TAR get ()
 retrieve current content of the variant, trying to cast or convert it to the given type. More...
 
template<typename SRC >
VariantOoperator= (SRC src)
 store a copy of the given argument within the variant holder buffer, thereby typically casting or converting the given source type to the best suited (base) type (out of the collection of possible types for this VariantO instance)
 
void reset ()
 

Private Types

typedef Holder::Deleter Deleter
 
typedef variant::Holder< TYPES > Holder
 

Private Attributes

Holder::Storage holder_
 storage: buffer holding either an "empty" marker, or an instance of one of the configured payload types
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ get()

TAR get ( )
inline

retrieve current content of the variant, trying to cast or convert it to the given type.

Actually, the function access(T&) on the Access-policy (template param) is invoked with the type currently stored in the holder buffer. May return NULL if conversion fails.

Definition at line 284 of file variant-o.hpp.

Referenced by WrappedStandardExeBuilder::__call__().

+ Here is the caller graph for this function:
+ Inheritance diagram for VariantO< TYPES, Access >:
+ Collaboration diagram for VariantO< TYPES, Access >:

The documentation for this class was generated from the following file: