Skip to content

Engine → Core

enum_flags.h

Bitwise operators and helpers for enumerations used as flag sets.

Functions

Public

has_any_flag

template <typename EnumType> requires std::is_enum_v<EnumType> [[nodiscard]] constexpr bool has_any_flag(
    EnumType value,
    EnumType flags) noexcept;

True when at least one bit of flags is set in value.

has_flag

template <typename EnumType> requires std::is_enum_v<EnumType> [[nodiscard]] constexpr bool has_flag(
    EnumType value,
    EnumType flag) noexcept;

True when every bit of flag is set in value.

to_underlying

template <typename EnumType> requires std::is_enum_v<EnumType> [[nodiscard]] constexpr std::underlying_type_t<EnumType> to_underlying(
    EnumType value) noexcept;

Converts an enumeration value to its underlying integer.

with_flag

template <typename EnumType> requires std::is_enum_v<EnumType> [[nodiscard]] constexpr EnumType with_flag(
    EnumType value,
    EnumType flag) noexcept;

Returns value with the bits of flag set.

without_flag

template <typename EnumType> requires std::is_enum_v<EnumType> [[nodiscard]] constexpr EnumType without_flag(
    EnumType value,
    EnumType flag) noexcept;

Returns value with the bits of flag cleared.