Files
@ r27383:44f4e925c6f0
Branch filter:
Location: cpp/openttd-patchpack/source/src/core/enum_type.hpp - annotation
r27383:44f4e925c6f0
2.2 KiB
text/x-c++hdr
Codechange: Swap SocketList map key/value around.
This map is used store socket and address together, and, other than
checking that the address does not already have a socket, the data layout
does not seem particularly important.
However, as address is the key, technically it should not be modified,
and address may self-modify itself during comparisons.
This map is used store socket and address together, and, other than
checking that the address does not already have a socket, the data layout
does not seem particularly important.
However, as address is the key, technically it should not be modified,
and address may self-modify itself during comparisons.
r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r23641:bcbf9c9bc8b1 r26093:d8f54f067391 r8100:d1eb5523ede7 r23641:bcbf9c9bc8b1 r23641:bcbf9c9bc8b1 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r26093:d8f54f067391 r8100:d1eb5523ede7 r23641:bcbf9c9bc8b1 r23641:bcbf9c9bc8b1 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r8100:d1eb5523ede7 r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r27142:7dfdfdd9ecab r8100:d1eb5523ede7 r8100:d1eb5523ede7 r10699:4939ee218211 | /*
* This file is part of OpenTTD.
* OpenTTD 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.
* OpenTTD 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.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file enum_type.hpp Type (helpers) for enums */
#ifndef ENUM_TYPE_HPP
#define ENUM_TYPE_HPP
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
#define DECLARE_POSTFIX_INCREMENT(enum_type) \
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; \
}
/** Operators to allow to work with enum as with type safe bit set in C++ */
#define DECLARE_ENUM_AS_BIT_SET(enum_type) \
inline constexpr enum_type operator | (enum_type m1, enum_type m2) {return (enum_type)((std::underlying_type<enum_type>::type)m1 | (std::underlying_type<enum_type>::type)m2);} \
inline constexpr enum_type operator & (enum_type m1, enum_type m2) {return (enum_type)((std::underlying_type<enum_type>::type)m1 & (std::underlying_type<enum_type>::type)m2);} \
inline constexpr enum_type operator ^ (enum_type m1, enum_type m2) {return (enum_type)((std::underlying_type<enum_type>::type)m1 ^ (std::underlying_type<enum_type>::type)m2);} \
inline constexpr enum_type& operator |= (enum_type& m1, enum_type m2) {m1 = m1 | m2; return m1;} \
inline constexpr enum_type& operator &= (enum_type& m1, enum_type m2) {m1 = m1 & m2; return m1;} \
inline constexpr enum_type& operator ^= (enum_type& m1, enum_type m2) {m1 = m1 ^ m2; return m1;} \
inline constexpr enum_type operator ~(enum_type m) {return (enum_type)(~(std::underlying_type<enum_type>::type)m);}
#endif /* ENUM_TYPE_HPP */
|