src/core/enum_type.hpp
author skidd13
Sun, 22 Jun 2008 15:21:51 +0000
changeset 11049 f8bbc9635251
parent 10229 fba3f9fa44d7
permissions -rw-r--r--
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     1
/* $Id$ */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     2
8596
27646407e0bc (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 8533
diff changeset
     3
/** @file enum_type.hpp Type (helpers) for enums */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     4
8596
27646407e0bc (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 8533
diff changeset
     5
#ifndef ENUM_TYPE_HPP
27646407e0bc (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 8533
diff changeset
     6
#define ENUM_TYPE_HPP
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     7
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     8
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
     9
#define DECLARE_POSTFIX_INCREMENT(type) \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    10
	FORCEINLINE type operator ++(type& e, int) \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    11
	{ \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    12
		type e_org = e; \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    13
		e = (type)((int)e + 1); \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    14
		return e_org; \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    15
	} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    16
	FORCEINLINE type operator --(type& e, int) \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    17
	{ \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    18
		type e_org = e; \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    19
		e = (type)((int)e - 1); \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    20
		return e_org; \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    21
	}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    22
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    23
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    24
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    25
/** Operators to allow to work with enum as with type safe bit set in C++ */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    26
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    27
	FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    28
	FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    29
	FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    30
	FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    31
	FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    32
	FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    33
	FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    34
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    35
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    36
/** Informative template class exposing basic enumeration properties used by several
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    37
 *  other templates below. Here we have only forward declaration. For each enum type
6455
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    38
 *  we will create specialization derived from MakeEnumPropsT<>.
6456
2b9af36fe022 (svn r8867) -Fix(r8866): revert yapf_costrail.hpp commited by mistake, helpers.hpp had wrong line ending
KUDr
parents: 6455
diff changeset
    39
 *  i.e.:
2b9af36fe022 (svn r8867) -Fix(r8866): revert yapf_costrail.hpp commited by mistake, helpers.hpp had wrong line ending
KUDr
parents: 6455
diff changeset
    40
 *    template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
2b9af36fe022 (svn r8867) -Fix(r8866): revert yapf_costrail.hpp commited by mistake, helpers.hpp had wrong line ending
KUDr
parents: 6455
diff changeset
    41
 *  followed by:
2b9af36fe022 (svn r8867) -Fix(r8866): revert yapf_costrail.hpp commited by mistake, helpers.hpp had wrong line ending
KUDr
parents: 6455
diff changeset
    42
 *    typedef TinyEnumT<Track> TrackByte;
6455
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    43
 */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    44
template <typename Tenum_t> struct EnumPropsT;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    45
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    46
/** Helper template class that makes basic properties of given enumeration type visible
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    47
 *  from outsize. It is used as base class of several EnumPropsT specializations each
6455
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    48
 *  dedicated to one of commonly used enumeration types.
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    49
 *  @param Tenum_t enumeration type that you want to describe
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    50
 *  @param Tstorage_t what storage type would be sufficient (i.e. byte)
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    51
 *  @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    52
 *  @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    53
 *  @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
4b0a3d229026 (svn r8866) -Doc: added more comments to template struct MakeEnumPropsT
KUDr
parents: 6453
diff changeset
    54
 */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    55
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    56
struct MakeEnumPropsT {
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    57
	typedef Tenum_t type;                     ///< enum type (i.e. Trackdir)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    58
	typedef Tstorage_t storage;               ///< storage type (i.e. byte)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    59
	static const Tenum_t begin = Tbegin;      ///< lowest valid value (i.e. TRACKDIR_BEGIN)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    60
	static const Tenum_t end = Tend;          ///< one after the last valid value (i.e. TRACKDIR_END)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    61
	static const Tenum_t invalid = Tinvalid;  ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    62
};
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    63
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    64
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    65
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    66
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    67
	*  necessary in order to control the sizeof() such values. Some compilers make enum
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    68
	*  the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8596
diff changeset
    69
	*  compiler type - checking causes errors like:
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    70
	*     'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    71
	*  u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    72
	*  to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    73
template <typename Tenum_t> struct TinyEnumT;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    74
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    75
/** The general declaration of TinyEnumT<> (above) */
11049
f8bbc9635251 (svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents: 10229
diff changeset
    76
template <typename Tenum_t>
f8bbc9635251 (svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents: 10229
diff changeset
    77
struct TinyEnumT
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    78
{
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    79
	typedef Tenum_t enum_type;                      ///< expose our enumeration type (i.e. Trackdir) to outside
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    80
	typedef EnumPropsT<Tenum_t> Props;              ///< make easier access to our enumeration propeties
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    81
	typedef typename Props::storage storage_type;   ///< small storage type
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    82
	static const enum_type begin = Props::begin;    ///< enum beginning (i.e. TRACKDIR_BEGIN)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    83
	static const enum_type end = Props::end;        ///< enum end (i.e. TRACKDIR_END)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    84
	static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    85
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    86
	storage_type m_val;  ///< here we hold the actual value in small (i.e. byte) form
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    87
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    88
	/** Cast operator - invoked then the value is assigned to the Tenum_t type */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    89
	FORCEINLINE operator enum_type () const
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    90
	{
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    91
		return (enum_type)m_val;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    92
	}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    93
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    94
	/** Assignment operator (from Tenum_t type) */
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    95
	FORCEINLINE TinyEnumT& operator = (enum_type e)
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    96
	{
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    97
		m_val = (storage_type)e; return *this;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    98
	}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
    99
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   100
	/** postfix ++ operator on tiny type */
8334
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   101
	FORCEINLINE TinyEnumT operator ++ (int)
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   102
	{
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   103
		TinyEnumT org = *this;
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   104
		if (++m_val >= end) m_val -= (storage_type)(end - begin);
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   105
		return org;
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   106
	}
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   107
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   108
	/** prefix ++ operator on tiny type */
bca925892b54 (svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
truelight
parents: 8259
diff changeset
   109
	FORCEINLINE TinyEnumT& operator ++ ()
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   110
	{
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   111
		if (++m_val >= end) m_val -= (storage_type)(end - begin);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   112
		return *this;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   113
	}
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   114
};
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   115
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
diff changeset
   116
#endif /* HELPERS_HPP */