lumiera::Variant< TYPES, Access > Class Template Reference

#include <variant.hpp>

Inheritance diagram for lumiera::Variant< TYPES, Access >:

Inheritance graph
[legend]
Collaboration diagram for lumiera::Variant< TYPES, Access >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<typename TYPES, template< typename > class Access>
class lumiera::Variant< 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 finisihng 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 beeing not so generic, not caring for alignment issues within the buffer and being not threadsafe
Parameters:
TYPES collection of possible types to be stored in this variant object
Access policy how to access the stored value

Definition at line 229 of file variant.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.
template<typename SRC>
Variantoperator= (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 Variant instance)
void reset ()

Private Types

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

Private Attributes

Holder::Storage holder_
 storage: buffer holding either and "empty" marker, or one of the configured pointer to wrapper types

Member Function Documentation

template<typename TYPES, template< typename > class Access>
template<typename TAR>
TAR lumiera::Variant< TYPES, Access >::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 269 of file variant.hpp.

template<typename TYPES, template< typename > class Access>
template<typename SRC>
Variant& lumiera::Variant< TYPES, Access >::operator= ( SRC  src  )  [inline]

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 Variant instance)

Definition at line 253 of file variant.hpp.


Member Data Documentation

template<typename TYPES, template< typename > class Access>
Holder::Storage lumiera::Variant< TYPES, Access >::holder_ [private]

storage: buffer holding either and "empty" marker, or one of the configured pointer to wrapper types

Definition at line 239 of file variant.hpp.


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

Generated on Tue Jan 6 17:21:28 2009 for Lumiera by  doxygen 1.5.6