BiVariant< _First, _Second > Class Template Reference


Detailed Description

template<typename _First, typename _Second>
class lemon::BiVariant< _First, _Second >

Simple Variant type for two types. The Variant type is a type safe union. The C++ has strong limitations for using unions, by example we can not store type with non default constructor or destructor in an union. This class always knowns the current state of the variant and it cares for the proper construction and destruction. #include <lemon/bits/variant.h>

List of all members.

Public Types

typedef _First First
 The First type.
typedef _Second Second
 The Second type.

Public Member Functions

 BiVariant ()
 Constructor.
 BiVariant (const First &f)
 Constructor.
 BiVariant (const Second &s)
 Constructor.
 BiVariant (const BiVariant &bivariant)
 Copy constructor.
 ~BiVariant ()
 Destrcutor.
BiVariantsetFirst ()
 Set to the default value of the First type.
BiVariantsetFirst (const First &f)
 Set to the given value of the First type.
BiVariantsetSecond ()
 Set to the default value of the Second type.
BiVariantsetSecond (const Second &s)
 Set to the given value of the Second type.
BiVariantoperator= (const First &f)
 Operator form of the setFirst().
BiVariantoperator= (const Second &s)
 Operator form of the setSecond().
BiVariantoperator= (const BiVariant &bivariant)
 Assign operator.
Firstfirst ()
 Reference to the value.
const Firstfirst () const
 Const reference to the value.
 operator First & ()
 Operator form of the first().
 operator const First & () const
 Operator form of the const first().
Secondsecond ()
 Reference to the value.
const Secondsecond () const
 Const reference to the value.
 operator Second & ()
 Operator form of the second().
 operator const Second & () const
 Operator form of the const second().
bool firstState () const
 True when the variant is in the first state
bool secondState () const
 True when the variant is in the second state


Constructor & Destructor Documentation

BiVariant (  )  [inline]

This constructor initalizes to the default value of the First type.

BiVariant ( const First f  )  [inline]

This constructor initalizes to the given value of the First type.

BiVariant ( const Second s  )  [inline]

This constructor initalizes to the given value of the Second type.

BiVariant ( const BiVariant< _First, _Second > &  bivariant  )  [inline]

Copy constructor

~BiVariant (  )  [inline]

Destructor


Member Function Documentation

BiVariant& setFirst (  )  [inline]

This function sets the variant to the default value of the First type.

BiVariant& setFirst ( const First f  )  [inline]

This function sets the variant to the given value of the First type.

BiVariant& setSecond (  )  [inline]

This function sets the variant to the default value of the Second type.

BiVariant& setSecond ( const Second s  )  [inline]

This function sets the variant to the given value of the Second type.

First& first (  )  [inline]

Reference to the value of the First type.

Precondition:
The BiVariant should store value of First type.

const First& first (  )  const [inline]

Const reference to the value of the First type.

Precondition:
The BiVariant should store value of First type.

Second& second (  )  [inline]

Reference to the value of the Second type.

Precondition:
The BiVariant should store value of Second type.

const Second& second (  )  const [inline]

Const reference to the value of the Second type.

Precondition:
The BiVariant should store value of Second type.

bool firstState (  )  const [inline]

True when the variant stores value of the First type.

bool secondState (  )  const [inline]

True when the variant stores value of the Second type.


Generated on Thu Jun 4 04:06:43 2009 for LEMON by  doxygen 1.5.9