|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
CRTP base class for enum–string mappers. More...
#include <EnumMapper.h>
Static Public Member Functions | |
| static std::string | str (Enum e) |
| Returns the string representation of an enum value. | |
| static Enum | enum_elt (const std::string &name) |
| Returns the enum value associated to a given string. | |
| static std::vector< std::string > | get_str () |
| Returns all string representations defined in the mapping. | |
| static std::vector< Enum > | get_enum () |
| Returns all enum values defined in the mapping. | |
CRTP base class for enum–string mappers.
This template implements a small set of convenience functions relying on a Derived class that must provide:
The design is based on CRTP (Curiously Recurring Template Pattern): struct MyEnumMap : EnumMapperBase<MyEnum, MyEnumMap> { ... };
The implementation assumes that:
| Enum | Enum type being mapped. |
| Derived | CRTP derived type implementing mapping() / inverse_mapping(). |
Definition at line 47 of file EnumMapper.h.
|
inlinestatic |
Returns the enum value associated to a given string.
This function forwards to Derived::inverse_mapping().at(name). If name is not present in the inverse mapping, std::out_of_range is thrown.
| name | String representation of the enum value. |
| std::out_of_range | if the string is not in the inverse mapping. |
Definition at line 76 of file EnumMapper.h.
|
inlinestatic |
Returns all enum values defined in the mapping.
The enum values are returned in the iteration order of Derived::mapping(), i.e. the key order of the underlying std::map<Enum, std::string>.
Definition at line 104 of file EnumMapper.h.
|
inlinestatic |
Returns all string representations defined in the mapping.
The strings are returned in the iteration order of Derived::mapping(), which is the key order of the underlying std::map<Enum, std::string>.
Definition at line 88 of file EnumMapper.h.
|
inlinestatic |
Returns the string representation of an enum value.
This function simply forwards to Derived::mapping().at(e). If e is not present in the mapping, std::out_of_range is thrown.
| e | Enum value to convert. |
| std::out_of_range | if the enum value is not in the mapping. |
Definition at line 60 of file EnumMapper.h.