Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_Enum.H File Reference

Enum reflection utilities and the AMREX_ENUM macro. More...

#include <AMReX_String.H>
#include <algorithm>
#include <array>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  amrex
 

Macros

#define AMREX_ENUM(CLASS, ...)
 Declare a scoped enum with reflection support.
 
#define AMREX_ENUM_IN_CLASS(CLASS, ...)
 

Typedefs

template<typename T >
using amrex_enum_traits = decltype(amrex_get_enum_traits(std::declval< T >()))
 

Functions

template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
std::vector< std::pair< std::string, T > > const & amrex::getEnumNameValuePairs ()
 Return all (name, value) pairs for an AMREX_ENUM-declared enum type.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
amrex::getEnum (std::string_view const &s)
 Convert a string to an enum value.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
amrex::getEnumCaseInsensitive (std::string_view const &s)
 Convert a string case-insensitively to an enum value.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
std::string amrex::getEnumNameString (T const &v)
 Get the name string of an enum value.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
std::vector< std::string > amrex::getEnumNameStrings ()
 Return a list of all enumerator name strings for an AMREX_ENUM-declared type.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
std::string amrex::getEnumClassName ()
 Return the class name string of an AMREX_ENUM-declared enum type.
 
template<typename T , typename ET = amrex_enum_traits<T>>
requires (ET::value)
constexpr auto amrex::toUnderlying (T v) noexcept
 Return the underlying integer value of an enum enumerator.
 

Detailed Description

Enum reflection utilities and the AMREX_ENUM macro.

Macro Definition Documentation

◆ AMREX_ENUM_IN_CLASS

#define AMREX_ENUM_IN_CLASS (   CLASS,
  ... 
)
Value:
enum class CLASS : int { __VA_ARGS__ }; \
\
struct CLASS##_EnumTraits { \
using enum_class_t = CLASS; \
static constexpr bool value = true; \
static constexpr std::string_view class_name{#CLASS}; \
static constexpr std::string_view enum_names{#__VA_ARGS__}; \
}; \
\
friend CLASS##_EnumTraits amrex_get_enum_traits(CLASS) { return {}; } \
/* This gets rid of trailing semicolon warning. */ static_assert(true, "")
GrowthStrategy_EnumTraits amrex_get_enum_traits(GrowthStrategy)

Typedef Documentation

◆ amrex_enum_traits

template<typename T >
using amrex_enum_traits = decltype(amrex_get_enum_traits(std::declval<T>()))