true_typedef Class Template Reference
[Utility Library]

#include <stlsoft/util/true_typedef.hpp>

List of all members.


Detailed Description

template<typename T, typename U>
class stlsoft::true_typedef< T, U >

This class is used to create strong types from base types, to facilitate type disambiguation, overloading and mutual incompatibility.

For example, the following code creates two types based on the int type:

  STLSOFT_GEN_OPAQUE(h_protocol_tt)
  STLSOFT_GEN_OPAQUE(h_port_tt)
  typedef true_typedef<long, h_protocol_tt>  protocol_tt;
  typedef true_typedef<long, h_port_tt>      port_tt;

  protocol_tt pro1(3);    // Ok
  port_tt     prt1(8088); // Ok
  protocol_tt pro2(pro1); // Ok, can copy from another protocol_tt
  port_tt     prt2(pro2); // Error, cannot copy from a protocol_tt

Parameters:
T The base type, e.g. int, std::wstring
U The unique type, usually created by using STLSOFT_GEN_OPAQUE()

Public Types

typedef T value_type
 The value type.
typedef U unique_type
 The unique type.
typedef true_typedef< T, U > class_type
 The type of the current parameterisation.
typedef T & reference
 The reference type.
typedef T const & const_reference
 The non-mutating (const) reference type.

Public Member Functions

 true_typedef ()
 Default constructor.
 true_typedef (value_type const &value)
 Construct from a value type instance.
 true_typedef (class_type const &rhs)
 Copy constructor.
class_type const & operator= (class_type const &rhs)
 Copy assignment operator.
const_reference base_type_value () const
 Provides non-mutating (const) access to the base type value.
reference base_type_value ()
 Provides mutating access to the base type value.

Member Typedef Documentation

typedef T value_type

The value type.

typedef U unique_type

The unique type.

typedef true_typedef<T, U> class_type

The type of the current parameterisation.

typedef T& reference

The reference type.

typedef T const& const_reference

The non-mutating (const) reference type.


Constructor & Destructor Documentation

true_typedef (  )  [inline]

Default constructor.

true_typedef ( value_type const &  value  )  [inline, explicit]

Construct from a value type instance.

true_typedef ( class_type const &  rhs  )  [inline]

Copy constructor.


Member Function Documentation

class_type const& operator= ( class_type const &  rhs  )  [inline]

Copy assignment operator.

References true_typedef::m_value.

const_reference base_type_value (  )  const [inline]

Provides non-mutating (const) access to the base type value.

reference base_type_value (  )  [inline]

Provides mutating access to the base type value.


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

Generated on Thu Jun 10 08:59:03 2010 for STLSoft by  doxygen 1.5.6