Gromacs  2020.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions
gmx::EnumerationIterator< EnumType, Last, Step > Class Template Referencefinal

#include <gromacs/utility/enumerationhelpers.h>


template<typename EnumType, EnumType Last = EnumType::Count, unsigned int Step = 1>
class gmx::EnumerationIterator< EnumType, Last, Step >

Allows iterating sequential enumerators.

You can also provide an increment step > 1 if each constant is spaced by a larger value. Terminating constant is assumed to be a 'Count' member, which is never iterated. A different name for the terminating constant can also be specified on declaration.

NOTE This functionality only works for enumerations of monotonically increasing values, starting with the value zero.

See file documentation for usage example.

Template Parameters
EnumTypeThe enum (class) type.
LastLast constant or number thereof (assumes a default 'Count' member).
StepStep increment.

Public Types

using IntegerType = std::underlying_type_t< EnumType >
 Convenience alias.
Iterator type traits

Satisfies the requirements for STL forward iterator.

using iterator_category = std::forward_iterator_tag
using value_type = EnumType
using difference_type = std::ptrdiff_t
using pointer = EnumType *
using reference = EnumType &

Public Member Functions

constexpr EnumerationIterator (const EnumType index) noexcept
 Copy constructor.
EnumerationIterator operator++ ()
 Pre-increment operator.
EnumerationIterator operator++ (int)
 Post-increment operator.
EnumType operator* () const
 Dereference operator.
bool operator== (const EnumerationIterator other) const noexcept
 Comparision operators.
bool operator!= (const EnumerationIterator other) const noexcept
bool operator< (const EnumerationIterator other) const noexcept
bool operator> (const EnumerationIterator other) const noexcept
bool operator<= (const EnumerationIterator other) const noexcept
bool operator>= (const EnumerationIterator other) const noexcept

The documentation for this class was generated from the following file: