#include <Explicit.h>
| 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 | |
| T | value | 
| The actual fundamental value. | |
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.
| icl_core::Explicit< T, Meaning >::Explicit | ( | ) |  [inline] | 
Default constructor does not initialize the value.
Definition at line 70 of file Explicit.h.
| icl_core::Explicit< T, Meaning >::Explicit | ( | T | value | ) |  [inline] | 
Construction from a fundamental value.
Definition at line 76 of file Explicit.h.
| 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.
| T icl_core::Explicit< T, Meaning >::value | 
The actual fundamental value.
Definition at line 84 of file Explicit.h.