|
Gromacs
2026.0-dev-20251109-f20ba35
|
#include <cstddef>#include <cstdint>#include <iterator>#include <type_traits>#include <gromacs/external/boost/stl_interfaces/iterator_interface.hpp>#include "gromacs/utility/gmxassert.h"
Include dependency graph for enumerationhelpers.h:
This graph shows which files directly or indirectly include this file:Defines helper types for class enumerations.
These helper types facilitate iterating over class enums, and maintaining a type-safe and value-safe matching list of names. The code is closely based on the public-domain code by Guilherme R. Lampert, found in commit c94c18a of https://github.com/glampert/enum_helpers/blob/master/enum_helpers.hpp Thanks Guilherme!
NOTE This functionality only works for enumerations of monotonically increasing values, starting with the value zero.
Usage examples:
enum class Foo : int { Bar, Baz, Fooz, Count };
for (Foo c : EnumerationWrapper<Foo>{}) { // 'c' is a constant from Foo }
const EnumerationArray<Foo, std::string> fooStrings = { { "Bar", "Baz", "Fooz" } }; std::cout << fooStrings[Foo::Baz]; std::cout << fooStrings[Foo::Count]; // Triggers an assertion
for (Foo c : keysOf(fooStrings)) { print(fooStrings[c]); }
ArrayRef<const std::string> namesRef(fooStrings);
Classes | |
| class | gmx::EnumClassSuitsEnumerationArray< EnumToTest > |
| Helper class to determine whether a template type that is an enum class has a Count field. More... | |
Functions | |
| template<typename EnumerationArrayType > | |
| EnumerationArrayType::EnumerationWrapperType | gmx::keysOf (const EnumerationArrayType &) |
Returns an object that provides iterators over the keys associated with EnumerationArrayType. More... | |
1.8.5