Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

variant< T1, T2, T3, T4, T5, T6, T7, T8 > Class Template Reference

variant< T1, T2, T3, T4, T5, T6, T7, T8 > Class Template Reference
[variant]

A template class that can store any of the types defined in the template parameter list. More...

#include <variant.h>

Data Structures

class  reader_type
 Base reader type functor class. More...
class  reader_type< R1, no_type2, no_type3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Define the reader type for 1 type. More...
class  reader_type< R1, R2, no_type3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Define the reader type for 2 types. More...
class  reader_type< R1, R2, R3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Define the reader type for 3 types. More...
class  reader_type< R1, R2, R3, R4, no_type5, no_type6, no_type7, no_type8 >
 Define the reader type for 4 types. More...
class  reader_type< R1, R2, R3, R4, R5, no_type6, no_type7, no_type8 >
 Define the reader type for 5 types. More...
class  reader_type< R1, R2, R3, R4, R5, R6, no_type7, no_type8 >
 Define the reader type for 6 types. More...
class  reader_type< R1, R2, R3, R4, R5, R6, R7, no_type8 >
 Define the reader type for 7 types. More...
class  upcast_functor
 Base upcast_functor for eight types. More...
class  upcast_functor< TBase, U1, no_type2, no_type3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Upcast_functor for one type. More...
class  upcast_functor< TBase, U1, U2, no_type3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Upcast_functor for two types. More...
class  upcast_functor< TBase, U1, U2, U3, no_type4, no_type5, no_type6, no_type7, no_type8 >
 Upcast_functor for three types. More...
class  upcast_functor< TBase, U1, U2, U3, U4, no_type5, no_type6, no_type7, no_type8 >
 Upcast_functor for four types. More...
class  upcast_functor< TBase, U1, U2, U3, U4, U5, no_type6, no_type7, no_type8 >
 Upcast_functor for five types. More...
class  upcast_functor< TBase, U1, U2, U3, U4, U5, U6, no_type7, no_type8 >
 Upcast_functor for six types. More...
class  upcast_functor< TBase, U1, U2, U3, U4, U5, U6, U7, no_type8 >
 Upcast_functor for seven types. More...

Public Types

typedef reader_type< T1, T2,
T3, T4, T5, T6, T7, T8 > 
reader
 The base type for derived readers.

Public Member Functions

 ~variant ()
 Destructor.
 variant ()
 Default constructor.
template<typename T >
 variant (const T &value)
 Constructor that catches any types that are not supported.
 variant (const variant &other)
 Copy constructor.
template<typename T >
variantoperator= (const T &value)
 Assignment operator for T1 type.
variantoperator= (const variant &other)
 Assignment operator for variant type.
bool is_same_type (const variant &other) const
 Checks if the type is the same as the current stored type.
template<typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 >
bool is_same_type (const variant< U1, U2, U3, U4, U5, U6, U7, U8 > &other) const
 Checks if the type is the same as the current stored type.
void call (reader &reader)
 Calls the supplied reader instance.
bool is_valid () const
 Checks whether a valid value is currently stored.
template<typename T >
bool is_type () const
 Checks to see if the type currently stored is the same as that specified in the template parameter.
void clear ()
 Clears the value to 'no valid stored value'.
template<typename T >
T & get ()
 Gets the value stored as the specified template type.
template<typename T >
const T & get () const
 Gets the value stored as the specified template type.
template<typename TBase >
TBase & upcast ()
 Gets the value stored as the specified template type.
template<typename TBase >
const TBase & upcast () const
 Gets the value stored as the specified template type.
 operator T1 & ()
 Conversion operators for each type.

Static Public Member Functions

template<typename T >
static bool is_supported_type ()
 Checks if the template type is supported by the implementation of variant.

Detailed Description

template<typename T1, typename T2 = __private_variant__::no_type<2>, typename T3 = __private_variant__::no_type<3>, typename T4 = __private_variant__::no_type<4>, typename T5 = __private_variant__::no_type<5>, typename T6 = __private_variant__::no_type<6>, typename T7 = __private_variant__::no_type<7>, typename T8 = __private_variant__::no_type<8>>
class etl::variant< T1, T2, T3, T4, T5, T6, T7, T8 >

A template class that can store any of the types defined in the template parameter list.

Supports up to 8 types.

Definition at line 113 of file variant.h.


Member Typedef Documentation

typedef reader_type<T1, T2, T3, T4, T5, T6, T7, T8> reader

The base type for derived readers.

Definition at line 658 of file variant.h.


Constructor & Destructor Documentation

~variant (  )

Destructor.

Definition at line 195 of file variant.h.

variant (  )

Default constructor.

Sets the state of the instance to containing no valid data.

Definition at line 664 of file variant.h.

variant ( const T &  value )

Constructor that catches any types that are not supported.

Forces a STATIC_ASSERT.

Definition at line 674 of file variant.h.

variant ( const variant< T1, T2, T3, T4, T5, T6, T7, T8 > &  other )

Copy constructor.

Parameters:
otherThe other variant object to copy.

Definition at line 686 of file variant.h.


Member Function Documentation

void call ( reader reader )

Calls the supplied reader instance.

The 'read' function appropriate to the current type is called with the stored value.

Definition at line 789 of file variant.h.

void clear (  )

Clears the value to 'no valid stored value'.

Definition at line 827 of file variant.h.

T& get (  )

Gets the value stored as the specified template type.

Throws a variant_incorrect_type_exception if the actual type is not that specified.

Returns:
A reference to the value.

Definition at line 838 of file variant.h.

const T& get (  ) const

Gets the value stored as the specified template type.

Throws a variant_incorrect_type_exception if the actual type is not that specified.

Returns:
A const reference to the value.

Definition at line 852 of file variant.h.

bool is_same_type ( const variant< T1, T2, T3, T4, T5, T6, T7, T8 > &  other ) const

Checks if the type is the same as the current stored type.

For variants with the same type declarations.

Returns:
true if the types are the same, otherwise false.

Definition at line 754 of file variant.h.

bool is_same_type ( const variant< U1, U2, U3, U4, U5, U6, U7, U8 > &  other ) const

Checks if the type is the same as the current stored type.

For variants with differing declarations.

Returns:
true if the types are the same, otherwise false.

Definition at line 765 of file variant.h.

static bool is_supported_type (  ) [static]

Checks if the template type is supported by the implementation of variant.

Returns:
true if the type is supported, otherwise false.

Definition at line 897 of file variant.h.

bool is_type (  ) const

Checks to see if the type currently stored is the same as that specified in the template parameter.

Returns:
true if it is the specified type, otherwise false.

Definition at line 819 of file variant.h.

bool is_valid (  ) const

Checks whether a valid value is currently stored.

Returns:
true if the value is valid, otherwise false.

Definition at line 809 of file variant.h.

operator T1 & (  )

Conversion operators for each type.

Definition at line 883 of file variant.h.

variant& operator= ( const variant< T1, T2, T3, T4, T5, T6, T7, T8 > &  other )

Assignment operator for variant type.

Parameters:
otherThe variant to assign.

Definition at line 724 of file variant.h.

variant& operator= ( const T &  value )

Assignment operator for T1 type.

Parameters:
valueThe value to assign.

Definition at line 709 of file variant.h.

TBase& upcast (  )

Gets the value stored as the specified template type.

Returns:
A reference to the value.

Definition at line 865 of file variant.h.

const TBase& upcast (  ) const

Gets the value stored as the specified template type.

Returns:
A const reference to the value.

Definition at line 875 of file variant.h.