2
* This file is part of FreeRCT.
3
* FreeRCT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4
* FreeRCT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FreeRCT. If not, see <http://www.gnu.org/licenses/>.
8
/** @file enum_type.h Some enum templates. */
13
/* Copied from OpenTTD. */
16
* Operators to allow to work with enum as with type safe bit set in C++.
17
* @tparam mask_t Enum type.
19
#define DECLARE_ENUM_AS_BIT_SET(mask_t) \
20
inline mask_t operator | (mask_t m1, mask_t m2) { return (mask_t)((int)m1 | m2); } \
21
inline mask_t operator & (mask_t m1, mask_t m2) { return (mask_t)((int)m1 & m2); } \
22
inline mask_t operator ^ (mask_t m1, mask_t m2) { return (mask_t)((int)m1 ^ m2); } \
23
inline mask_t &operator |= (mask_t &m1, mask_t m2) { m1 = m1 | m2; return m1; } \
24
inline mask_t &operator &= (mask_t &m1, mask_t m2) { m1 = m1 & m2; return m1; } \
25
inline mask_t &operator ^= (mask_t &m1, mask_t m2) { m1 = m1 ^ m2; return m1; } \
26
inline mask_t operator ~ (mask_t m) { return (mask_t)(~(int)m); }
28
/** Add post-increment and post-decrement operators to an enum. */
29
#define DECLARE_POSTFIX_INCREMENT(type) \
30
inline type operator ++(type& e, int) \
33
e = (type)((int)e + 1); \
36
inline type operator --(type& e, int) \
39
e = (type)((int)e - 1); \