UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
EnumRange.h File Reference
#include "CoreTypes.h"
#include <type_traits>

Go to the source code of this file.

Classes

struct  NEnumRangePrivate::TEnumRangeTraits< EnumType >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, RangeType >
 
struct  NEnumRangePrivate::TEnumContiguousIterator< EnumType >
 
struct  NEnumRangePrivate::TEnumValueArrayIterator< EnumType >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, 0 >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, 1 >
 
struct  UE::EnumFlags::Private::TIterator< EnumType >
 
struct  UE::EnumFlags::Private::TRange< EnumType >
 
struct  TEnumRange< EnumType >
 

Namespaces

namespace  NEnumRangePrivate
 
namespace  UE
 
namespace  UE::EnumFlags
 
namespace  UE::EnumFlags::Private
 

Macros

#define ENUM_RANGE_BY_COUNT(EnumType, Count)   ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, 0, (std::underlying_type_t<EnumType>)(Count) - 1)
 
#define ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, First, Last)
 
#define ENUM_RANGE_BY_VALUES(EnumType, ...)
 

Functions

template<typename EnumType >
UE::EnumFlags::Private::TRange< EnumType > MakeFlagsRange (EnumType Flags)
 

Macro Definition Documentation

◆ ENUM_RANGE_BY_COUNT

#define ENUM_RANGE_BY_COUNT (   EnumType,
  Count 
)    ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, 0, (std::underlying_type_t<EnumType>)(Count) - 1)

Defines a contiguous enum range containing Count values, starting from zero:

Example:

enum class ECountedThing { First, Second, Third,

Count };

// Defines iteration over ECountedThing to be: First, Second, Third ENUM_RANGE_BY_COUNT(ECountedThing, ECountedThing::Count)

◆ ENUM_RANGE_BY_FIRST_AND_LAST

#define ENUM_RANGE_BY_FIRST_AND_LAST (   EnumType,
  First,
  Last 
)
Value:
template <> \
{ \
enum { RangeType = 0 }; \
static constexpr std::underlying_type_t<EnumType> Begin = (std::underlying_type_t<EnumType>)(First); \
static constexpr std::underlying_type_t<EnumType> End = (std::underlying_type_t<EnumType>)(Last) + 1; \
};
Definition EnumRange.h:92
@ RangeType
Definition EnumRange.h:93

Defines a contiguous enum range with specific start and end values:

Example:

enum class EDoubleEndedThing { Invalid,

First, Second, Third,

Count };

// Defines iteration over EDoubleEndedThing to be: First, Second, Third ENUM_RANGE_BY_FIRST_AND_LAST(EDoubleEndedThing, EDoubleEndedThing::First, EDoubleEndedThing::Third)

◆ ENUM_RANGE_BY_VALUES

#define ENUM_RANGE_BY_VALUES (   EnumType,
  ... 
)
Value:
template <> \
{ \
enum { RangeType = 1 }; \
template <typename Dummy> \
static const EnumType* GetPointer(bool bLast) \
{ \
static constexpr EnumType Values[] = { __VA_ARGS__ }; \
return bLast ? Values + sizeof(Values) / sizeof(EnumType) : Values; \
} \
};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127

Defines a non-contiguous enum range with specific individual values:

Example:

enum class ERandomValuesThing { First = 2, Second = 3, Third = 5, Fourth = 7, Fifth = 11 };

// Defines iteration over ERandomValuesThing to be: First, Second, Third, Fourth, Fifth ENUM_RANGE_BY_VALUES(ERandomValuesThing, ERandomValuesThing::First, ERandomValuesThing::Second, ERandomValuesThing::Third, ERandomValuesThing::Fourth, ERandomValuesThing::Fifth)

Function Documentation

◆ MakeFlagsRange()

template<typename EnumType >
UE::EnumFlags::Private::TRange< EnumType > MakeFlagsRange ( EnumType  Flags)

Make a range for iterating over set flags in a flags enum.

Example:

EFlagThing Flags = EFlagThing::A | EFlagThing::B; for (EFlagThing Flag : MakeFlagsRange(Flags)) { // Loop is run twice, once with Flag = EFlagThing::A, once with Flag = EFlagThing::B ... }