#include "Stroika/Foundation/StroikaPreComp.h"#include <array>#include <optional>#include <type_traits>#include <utility>#include <vector>#include "Stroika/Foundation/Common/Common.h"#include "Enumeration.inl"Go to the source code of this file.
Classes | |
| struct | Stroika::Foundation::Common::DefaultNames< ENUM_TYPE > |
Namespaces | |
| namespace | Stroika::Foundation |
| namespace | Stroika::Foundation::Common |
Concepts | |
| concept | Stroika::Foundation::Common::IBoundedEnum |
Macros | |
| #define | Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM) eSTART = FIRST_ITEM, eEND = LAST_ITEM + 1, eLAST = LAST_ITEM, eCOUNT = eEND - eSTART, |
Functions | |
| template<typename ENUM > | |
| constexpr ENUM | Stroika::Foundation::Common::Inc (ENUM e) |
| Increment the given enumeration safely, without a bunch of casts. | |
| template<typename ENUM > | |
| constexpr underlying_type_t< ENUM > | Stroika::Foundation::Common::ToInt (ENUM e) |
| Cast the given enum to an int (like static_cast<int>()) - but check range. | |
| template<typename ENUM > | |
| constexpr make_unsigned_t< underlying_type_t< ENUM > > | Stroika::Foundation::Common::GetDistanceSpanned (ENUM e) |
| return the distance spanned by an enum, e.g. for use in an array | |
| template<typename ENUM > | |
| constexpr ENUM | Stroika::Foundation::Common::ToEnum (underlying_type_t< ENUM > e) |
| Cast the given int to the given ENUM type - (like static_cast<int>()) - but check range. | |
| template<typename ENUM > | |
| constexpr make_unsigned_t< underlying_type_t< ENUM > > | Stroika::Foundation::Common::OffsetFromStart (ENUM e) |
| offset of given enum from ENUM::eSTART | |
TODO:
@todo http://stroika-bugs.sophists.com/browse/STK-549 - RequireItemsOrderedByEnumValue and
static_cast usage confusion.
@todo I tried using EnumNames<> as an alias for initializer_list, but then I couldn't add the
GetNames () method. I tried subclassing, but then I ran into lifetime issues. I tried aggregation,
but this has the same lifetime issues with subclassing std::initializer_list. In the end I had
to copy. That maybe a poor tradeoff. The only reason for not using aliases was to add
the Peek/GetName methods, but those could have been global functions? Hmmm.
Definition in file Enumeration.h.
| #define Stroika_Define_Enum_Bounds | ( | FIRST_ITEM, | |
| LAST_ITEM | |||
| ) | eSTART = FIRST_ITEM, eEND = LAST_ITEM + 1, eLAST = LAST_ITEM, eCOUNT = eEND - eSTART, |
Define meta information on enums using standardized names, so you can generically
write things like:
for (auto i = X::eSTART; i != X::eEND; i = Inc (i));
Definition at line 109 of file Enumeration.h.