Public Member Functions | Public Attributes
icl_core::Explicit< T, Meaning > Struct Template Reference

#include <Explicit.h>

List of all members.

Public Member Functions

 Explicit ()
 Default constructor does not initialize the value.
 Explicit (T value)
 Construction from a fundamental value.
 operator T () const
 Implicit conversion back to the fundamental data type.

Public Attributes

value
 The actual fundamental value.

Detailed Description

template<typename T, typename Meaning>
struct icl_core::Explicit< T, Meaning >

A thin wrapper around fundamental data types to give them a specific meaning and purpose. With this, you can write functions expecting, for example, an integer with a specific meaning, and forbidding integers with different meanings. The Meaning must be a "tag", i.e., an empty struct, whose name uniquely identifies the explicit class.

Usage example:

  struct IndexTag { }; // Meaning of the value is "Index"
  struct FrameNumber { }; // Meaning of the value is "FrameNumber"
  // An integer that has the meaning "Index".
  typedef Explicit<int, IndexTag> Index;
  // An integer that has the meaning "FrameNumber".
  typedef Explicit<int, IndexTag> FrameNumber;
  ...
  Index i = 23, i2 = 25;
  FrameNumber f(42);
  i = 24; // This is OK
  i = i2; // This is also OK
  i = f;  // Error: incompatible types (even though both are integers).

Definition at line 67 of file Explicit.h.


Constructor & Destructor Documentation

template<typename T , typename Meaning >
icl_core::Explicit< T, Meaning >::Explicit ( ) [inline]

Default constructor does not initialize the value.

Definition at line 70 of file Explicit.h.

template<typename T , typename Meaning >
icl_core::Explicit< T, Meaning >::Explicit ( value) [inline]

Construction from a fundamental value.

Definition at line 76 of file Explicit.h.


Member Function Documentation

template<typename T , typename Meaning >
icl_core::Explicit< T, Meaning >::operator T ( ) const [inline]

Implicit conversion back to the fundamental data type.

Definition at line 81 of file Explicit.h.


Member Data Documentation

template<typename T , typename Meaning >
T icl_core::Explicit< T, Meaning >::value

The actual fundamental value.

Definition at line 84 of file Explicit.h.


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


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:20