OpenTTD Source: src/core/enum_type.hpp File Reference

OpenTTD Source 13.1

Data Structures | Macros
enum_type.hpp File Reference

Go to the source code of this file.

## Data Structures
struct | EnumPropsT< Tenum_t >
| Informative template class exposing basic enumeration properties used by several other templates below. More...
struct | MakeEnumPropsT< Tenum_t, Tstorage_t, Tbegin, Tend, Tinvalid, Tnum_bits >
| Helper template class that makes basic properties of given enumeration type visible from outsize. More...

## Macros
#define | DECLARE_POSTFIX_INCREMENT(enum_type)
| Some enums need to have allowed incrementing (i.e. More...
#define | DECLARE_ENUM_AS_BIT_SET(mask_t)
| Operators to allow to work with enum as with type safe bit set in C++. More...

## Detailed Description

Type (helpers) for enums

Definition in file enum_type.hpp.

## Macro Definition Documentation

## ◆ DECLARE_ENUM_AS_BIT_SET

#define DECLARE_ENUM_AS_BIT_SET | ( |  | mask_t | ) |

Value:
inline constexpr mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 | (std::underlying_type<mask_t>::type)m2);} \
inline constexpr mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 & (std::underlying_type<mask_t>::type)m2);} \
inline constexpr mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 ^ (std::underlying_type<mask_t>::type)m2);} \
inline constexpr mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
inline constexpr mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
inline constexpr mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
inline constexpr mask_t operator ~(mask_t m) {return (mask_t)(~(std::underlying_type<mask_t>::type)m);}

Operators to allow to work with enum as with type safe bit set in C++.

Definition at line 31 of file enum_type.hpp.

## ◆ DECLARE_POSTFIX_INCREMENT

#define DECLARE_POSTFIX_INCREMENT | ( |  | enum_type | ) |

Value:
inline constexpr enum_type operator ++(enum_type& e, int) \
{ \
enum_type e_org = e; \
e = (enum_type)((std::underlying_type<enum_type>::type)e + 1); \
return e_org; \
} \
inline constexpr enum_type operator --(enum_type& e, int) \
{ \
enum_type e_org = e; \
e = (enum_type)((std::underlying_type<enum_type>::type)e - 1); \
return e_org; \
}

Some enums need to have allowed incrementing (i.e.

StationClassID)

Definition at line 14 of file enum_type.hpp.