OpenTTD Source 20250607-master-g6b5cde463a
|
Type (helpers) for enums. More...
#include "base_bitset_type.hpp"
Go to the source code of this file.
Data Structures | |
struct | is_enum_incrementable< enum_type > |
Trait to enable prefix/postfix incrementing operators. More... | |
struct | is_enum_sequential< enum_type > |
Trait to enable prefix/postfix incrementing operators. More... | |
struct | EnumBitSetMask< Tstorage, Tenum, Tend_value > |
Helper template structure to get the mask for an EnumBitSet from the end enum value. More... | |
class | EnumBitSet< Tenum, Tstorage, Tend_value > |
Enum-as-bit-set wrapper. More... | |
Macros | |
#define | DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type) |
For some enums it is useful to have pre/post increment/decrement operators. | |
#define | DECLARE_ENUM_AS_SEQUENTIAL(enum_type) |
For some enums it is useful to add/sub more than 1. | |
#define | DECLARE_ENUM_AS_BIT_SET(enum_type) |
Operators to allow to work with enum as with type safe bit set in C++. | |
#define | DECLARE_ENUM_AS_ADDABLE(EnumType) |
Operator that allows this enumeration to be added to any other enumeration. | |
Functions | |
template<typename enum_type > | |
constexpr std::underlying_type_t< enum_type > | to_underlying (enum_type e) |
Implementation of std::to_underlying (from C++23) | |
template<typename enum_type , std::enable_if_t< is_enum_incrementable_v< enum_type >, bool > = true> | |
constexpr enum_type & | operator++ (enum_type &e) |
Prefix increment. | |
template<typename enum_type , std::enable_if_t< is_enum_incrementable_v< enum_type >, bool > = true> | |
constexpr enum_type | operator++ (enum_type &e, int) |
Postfix increment, uses prefix increment. | |
template<typename enum_type , std::enable_if_t< is_enum_incrementable_v< enum_type >, bool > = true> | |
constexpr enum_type & | operator-- (enum_type &e) |
Prefix decrement. | |
template<typename enum_type , std::enable_if_t< is_enum_incrementable_v< enum_type >, bool > = true> | |
constexpr enum_type | operator-- (enum_type &e, int) |
Postfix decrement, uses prefix decrement. | |
template<typename enum_type , std::enable_if_t< is_enum_sequential_v< enum_type >, bool > = true> | |
constexpr enum_type | operator+ (enum_type e, int offset) |
Add integer. | |
template<typename enum_type , std::enable_if_t< is_enum_sequential_v< enum_type >, bool > = true> | |
constexpr enum_type & | operator+= (enum_type &e, int offset) |
template<typename enum_type , std::enable_if_t< is_enum_sequential_v< enum_type >, bool > = true> | |
constexpr enum_type | operator- (enum_type e, int offset) |
Sub integer. | |
template<typename enum_type , std::enable_if_t< is_enum_sequential_v< enum_type >, bool > = true> | |
constexpr enum_type & | operator-= (enum_type &e, int offset) |
template<typename enum_type , std::enable_if_t< is_enum_sequential_v< enum_type >, bool > = true> | |
constexpr auto | operator- (enum_type a, enum_type b) |
Distance. | |
template<typename T , class = typename std::enable_if_t<std::is_enum_v<T>>> | |
debug_inline constexpr bool | HasFlag (const T x, const T y) |
Checks if a value in a bitset enum is set. | |
template<typename T , class = typename std::enable_if_t<std::is_enum_v<T>>> | |
debug_inline constexpr void | ToggleFlag (T &x, const T y) |
Toggle a value in a bitset enum. | |
Variables | |
template<typename enum_type > | |
constexpr bool | is_enum_incrementable_v = is_enum_incrementable<enum_type>::value |
template<typename enum_type > | |
constexpr bool | is_enum_sequential_v = is_enum_sequential<enum_type>::value |
Type (helpers) for enums.
Definition in file enum_type.hpp.
#define DECLARE_ENUM_AS_ADDABLE | ( | EnumType | ) |
Operator that allows this enumeration to be added to any other enumeration.
Definition at line 129 of file enum_type.hpp.
#define DECLARE_ENUM_AS_BIT_SET | ( | enum_type | ) |
Operators to allow to work with enum as with type safe bit set in C++.
Definition at line 119 of file enum_type.hpp.
#define DECLARE_ENUM_AS_SEQUENTIAL | ( | enum_type | ) |
For some enums it is useful to add/sub more than 1.
Definition at line 113 of file enum_type.hpp.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS | ( | enum_type | ) |
For some enums it is useful to have pre/post increment/decrement operators.
Definition at line 63 of file enum_type.hpp.
|
constexpr |
Checks if a value in a bitset enum is set.
x | The value to check. |
y | The flag to check. |
Definition at line 142 of file enum_type.hpp.
Referenced by DrawLayoutLine(), and ToggleFlag().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Postfix increment, uses prefix increment.
Definition at line 38 of file enum_type.hpp.
|
inlineconstexpr |
Definition at line 85 of file enum_type.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Postfix decrement, uses prefix decrement.
Definition at line 55 of file enum_type.hpp.
|
inlineconstexpr |
Definition at line 99 of file enum_type.hpp.
|
constexpr |
Implementation of std::to_underlying (from C++23)
Definition at line 17 of file enum_type.hpp.
Referenced by AfterLoadGame(), BadgeClassSaveConfigFeature(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), CmdDoTownAction(), CmdPlantTree(), TownAuthorityWindow::DrawActions(), NetworkContentListWindow::DrawDetails(), TownAuthorityWindow::DrawWidget(), GetBadgeClassConfiguration(), GetGlobalVariable(), GetIndustryGamePlayProbability(), GetMaxTreeSpriteSize(), GetScaledIndustryGenerationProbability(), OpenGLBackend::GetSpriteAlignment(), GetStationTileLayout(), GetTownActionCost(), GetTownRadiusGroup(), AirportTileScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), RailTypeScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), RoadTypeScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), IndustriesChangeInfo(), LoadSpriteTables(), MakeStation(), MakeTreeTypeButtons(), ViewportSign::MarkDirty(), MarkViewportDirty(), MoveBuoysToWaypoints(), MoveToNextNewsItem(), MoveToNextTickerItem(), CreateScenarioWindow::OnClick(), SpriteAlignerWindow::OnClick(), CompanyStationsWindow::OnClick(), SpriteAlignerWindow::OnInvalidateData(), BuildRoadToolbarWindow::OnPlaceMouseUp(), OpenGLSprite::OpenGLSprite(), operator+(), operator++(), operator-(), operator-(), operator--(), OutputContentState(), ScaleByZoom(), ScaleByZoomLower(), CombinedAuthenticationServerHandler::SendRequest(), ServerNetworkAdminSocketHandler::SendWelcome(), SetAnimatedTileState(), SetupScreenshotViewport(), SetWaterTileType(), ShowLastNewsMessage(), ShowNewspaper(), SndPlayScreenCoordFx(), NetworkContentListWindow::StateSorter(), TestVehicleBuildProbability(), UnScaleByZoom(), UnScaleByZoomLower(), UpdateTownRadius(), TownAuthorityWindow::UpdateWidgetSize(), ValueStr(), ValueStr(), ValueStr(), and ValueStr().
|
constexpr |
Toggle a value in a bitset enum.
x | The value to change. |
y | The flag to toggle. |
Definition at line 153 of file enum_type.hpp.
References HasFlag().
|
constexpr |
Definition at line 26 of file enum_type.hpp.
|
constexpr |
Definition at line 75 of file enum_type.hpp.