libcppa  Version 0.1
Public Member Functions | Related Functions
cppa::primitive_variant Class Reference

#include <primitive_variant.hpp>

List of all members.

Public Member Functions

 primitive_variant ()
template<typename V >
 primitive_variant (V &&value)
 primitive_variant (primitive_type pt)
 primitive_variant (const primitive_variant &other)
 primitive_variant (primitive_variant &&other)
template<typename V >
primitive_variantoperator= (V &&value)
primitive_variantoperator= (const primitive_variant &other)
primitive_variantoperator= (primitive_variant &&other)
primitive_type ptype () const
const std::type_info & type () const

Related Functions

(Note that these are not member functions.)

enum  primitive_type {
  pt_int8,
  pt_int16,
  pt_int32,
  pt_int64,
  pt_uint8,
  pt_uint16,
  pt_uint32,
  pt_uint64,
  pt_float,
  pt_double,
  pt_long_double,
  pt_u8string,
  pt_u16string,
  pt_u32string,
  pt_null
}
template<typename T >
const T & get (const primitive_variant &pv)
template<typename T >
T & get_ref (primitive_variant &pv)
template<primitive_type PT>
const T & get_ref (const primitive_variant &pv)
template<primitive_type PT>
T & get_ref (primitive_variant &pv)

Detailed Description

An union container for primitive data types.


Constructor & Destructor Documentation

cppa::primitive_variant::primitive_variant ( )

Creates an empty variant.

Postcondition:
ptype() == pt_null && type() == typeid(void).
template<typename V >
cppa::primitive_variant::primitive_variant ( V &&  value)

Creates a variant from value.

Parameters:
valueA primitive value.
Precondition:
value does have a primitive type.
cppa::primitive_variant::primitive_variant ( primitive_type  pt)

Creates a variant with type pt.

Parameters:
ptRequestet type.
Postcondition:
ptype() == pt.
cppa::primitive_variant::primitive_variant ( const primitive_variant other)

Creates a copy from other.

Parameters:
otherA primitive variant.
cppa::primitive_variant::primitive_variant ( primitive_variant &&  other)

Creates a new variant and move the value from other to it.

Parameters:
otherA primitive variant rvalue.

Member Function Documentation

template<typename V >
primitive_variant& cppa::primitive_variant::operator= ( V &&  value)

Moves value to this variant if value is an rvalue; otherwise copies the value of value.

Parameters:
valueA primitive value.
Returns:
*this.
primitive_variant& cppa::primitive_variant::operator= ( const primitive_variant other)

Copies the content of other to this.

Parameters:
otherA primitive variant.
Returns:
*this.
primitive_variant& cppa::primitive_variant::operator= ( primitive_variant &&  other)

Moves the content of other to this.

Parameters:
otherA primitive variant rvalue.
Returns:
*this.
primitive_type cppa::primitive_variant::ptype ( ) const

Gets the type of this.

Returns:
The type of this.
const std::type_info& cppa::primitive_variant::type ( ) const

Gets the RTTI type of this.

Returns:
typeid(void) if ptype() == pt_null; otherwise typeid(T) is returned, where T is the C++ type of this.

Friends And Related Function Documentation

template<primitive_type PT>
T & get_ref ( primitive_variant pv) [related]

Casts a non-const primitive variant to its C++ type.

Template Parameters:
TC++ type equivalent of PT.
Parameters:
pvA primitive variant of type T.
Returns:
A reference to the value of pv of type T.

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