enum_name
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
mgutility Namespace Reference

Checks for MSVC compiler version. More...

Classes

struct  custom_enum
 Provides the custom names map for an enumeration type. More...
 
struct  custom_enum< color >
 
struct  custom_enum< Position >
 
class  enum_for_each
 A class template for iterating over enum values. More...
 
struct  enum_name_buffer
 Provides the name buffer size for an enumeration type. More...
 
struct  enum_range
 Provides the range for an enumeration type. More...
 
struct  enum_range< color >
 
struct  enum_range< Position >
 
struct  pair
 

Typedefs

template<typename T >
using flat_map = pair<T, const char *>[]
 

Functions

template<typename Enum >
constexpr auto enum_to_underlying (Enum enumValue) noexcept -> detail::underlying_type_t< Enum >
 Converts an enum value to its underlying integer value.
 
template<int Min, int Max, typename Enum >
MGUTILITY_CNSTXPR auto enum_name (Enum enumValue) noexcept -> detail::string_or_view_t< Enum >
 Gets the name of an enum value.
 
template<typename Enum , int Min = static_cast<int>(enum_range<Enum>::min), int Max = static_cast<int>(enum_range<Enum>::max), detail::enable_if_t<!detail::has_bit_or< Enum >::value, bool > = true>
MGUTILITY_CNSTXPR auto to_enum (mgutility::string_view str) noexcept -> mgutility::optional< Enum >
 Converts a string to an enum value.
 
template<typename Enum , int Min = static_cast<int>(enum_range<Enum>::min), int Max = static_cast<int>(enum_range<Enum>::max)>
MGUTILITY_CNSTXPR auto enum_cast (int value) noexcept -> mgutility::optional< Enum >
 Casts an integer value to an enum value.
 

Detailed Description

Checks for MSVC compiler version.

If the MSVC version is less than 2017, an error is raised.

Defines the MGUTILITY_CPLUSPLUS macro for MSVC and other compilers.

For MSVC, it uses _MSVC_LANG. For other compilers, it uses __cplusplus.

Function Documentation

◆ enum_cast()

template<typename Enum , int Min = static_cast<int>(enum_range<Enum>::min), int Max = static_cast<int>(enum_range<Enum>::max)>
MGUTILITY_CNSTXPR auto mgutility::enum_cast ( int value) -> mgutility::optional<Enum>
noexcept

Casts an integer value to an enum value.

Template Parameters
EnumThe enum type.
MinThe minimum enum value, default is enum_range<Enum>::min.
MaxThe maximum enum value, default is enum_range<Enum>::max.
Parameters
valueThe integer value to cast.
Returns
An optional enum value.

◆ enum_name()

template<int Min, int Max, typename Enum >
MGUTILITY_CNSTXPR auto mgutility::enum_name ( Enum enumValue) -> detail::string_or_view_t<Enum>
noexcept

Gets the name of an enum value.

Template Parameters
MinThe minimum enum value.
MaxThe maximum enum value.
EnumThe enum type.
Parameters
eThe enum value.
Returns
A string view or string representing the name of the enum value.
Template Parameters
EnumThe enum type.
MinThe minimum enum value, default is enum_range<Enum>::min.
MaxThe maximum enum value, default is enum_range<Enum>::max.
Parameters
eThe enum value.
Returns
A string view or string representing the name of the enum value.

◆ enum_to_underlying()

template<typename Enum >
constexpr auto mgutility::enum_to_underlying ( Enum enumValue) -> detail::underlying_type_t<Enum>
constexprnoexcept

Converts an enum value to its underlying integer value.

Template Parameters
EnumThe enum type.
Parameters
eThe enum value.
Returns
The underlying integer value of the enum.

◆ to_enum()

template<typename Enum , int Min = static_cast<int>(enum_range<Enum>::min), int Max = static_cast<int>(enum_range<Enum>::max), detail::enable_if_t<!detail::has_bit_or< Enum >::value, bool > = true>
MGUTILITY_CNSTXPR auto mgutility::to_enum ( mgutility::string_view str) -> mgutility::optional<Enum>
noexcept

Converts a string to an enum value.

Converts a string to an enum bitmask value.

Template Parameters
EnumThe enum type.
MinThe minimum enum value, default is enum_range<Enum>::min.
MaxThe maximum enum value, default is enum_range<Enum>::max.
Parameters
strThe string view representing the enum name.
Returns
An optional enum value.
Template Parameters
EnumThe enum type.
MinThe minimum enum value, default is enum_range<Enum>::min.
MaxThe maximum enum value, default is enum_range<Enum>::max.
Parameters
strThe string view representing the enum name.
Returns
An optional enum bitmask value.