Public Types | Public Member Functions | Data Fields | Static Public Attributes
TinyEnumT< Tenum_t > Struct Template Reference

In some cases we use byte or uint16 to store values that are defined as enum. More...

#include <enum_type.hpp>

Public Types

typedef Tenum_t enum_type
 expose our enumeration type (i.e. Trackdir) to outside
typedef EnumPropsT< Tenum_t > Props
 make easier access to our enumeration properties
typedef Props::storage storage_type
 small storage type

Public Member Functions

 operator enum_type () const
 Cast operator - invoked then the value is assigned to the Tenum_t type.
TinyEnumToperator= (enum_type e)
 Assignment operator (from Tenum_t type)
TinyEnumToperator= (uint u)
 Assignment operator (from Tenum_t type)
TinyEnumT operator++ (int)
 postfix ++ operator on tiny type
TinyEnumToperator++ ()
 prefix ++ operator on tiny type

Data Fields

storage_type m_val
 here we hold the actual value in small (i.e. byte) form

Static Public Attributes

static const enum_type begin = Props::begin
 enum beginning (i.e. TRACKDIR_BEGIN)
static const enum_type end = Props::end
 enum end (i.e. TRACKDIR_END)
static const enum_type invalid = Props::invalid
 invalid value (i.e. INVALID_TRACKDIR)

Detailed Description

template<typename Tenum_t>
struct TinyEnumT< Tenum_t >

In some cases we use byte or uint16 to store values that are defined as enum.

The general declaration of TinyEnumT<> (above)

It is necessary in order to control the sizeof() such values. Some compilers make enum the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict compiler type - checking causes errors like: 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when u->u.rail.railtype is passed as argument or type RailType. In such cases it is better to teach the compiler that u->u.rail.railtype is to be treated as RailType.

Definition at line 86 of file enum_type.hpp.

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