diff --git a/Src/Base/AMReX_Enum.H b/Src/Base/AMReX_Enum.H index b94e30d396..a3263492ee 100644 --- a/Src/Base/AMReX_Enum.H +++ b/Src/Base/AMReX_Enum.H @@ -128,6 +128,17 @@ namespace amrex { return std::string(ET::class_name); } + + /** Return the underlying (u)int of an enum value + * + * Useful when building bitmasks. + */ + template , + std::enable_if_t = 0> + constexpr auto toUnderlying (T v) noexcept + { + return static_cast>(v); + } } #define AMREX_ENUM(CLASS, ...) \