Gromacs  2021.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
gmx::EnumerationArray< EnumType, DataType, ArraySize > Struct Template Reference

#include <gromacs/utility/enumerationhelpers.h>


template<typename EnumType, typename DataType, EnumType ArraySize>
struct gmx::EnumerationArray< EnumType, DataType, ArraySize >

Wrapper for a C-style array with size and indexing defined by an enum. Useful for declaring arrays of enum names for debug or other printing. An ArrayRef<DataType> may be constructed from an object of this type.

See file documentation for usage example.

Template Parameters
EnumTypeThe enum (class) type.
DataTypeType of the data stored in the array.
ArraySizeSize in entries of the array.

Public Types

using EnumerationWrapperType = EnumerationWrapper< EnumType, ArraySize >
 Convenience alias.
using iterator = DataType *
 Range iterators (unchecked)
using const_iterator = const DataType *
using reverse_iterator = std::reverse_iterator< iterator >
using const_reverse_iterator = std::reverse_iterator< const_iterator >
using pointer = DataType *
 Pointers (unchecked)
using const_pointer = const DataType *

Public Member Functions

const_pointer data () const
 Returns a const raw pointer to the contents of the array.
pointer data ()
 Returns a raw pointer to the contents of the array.
DataType & operator[] (const std::size_t index)
 Array access with asserts:
const DataType & operator[] (const std::size_t index) const
DataType & operator[] (const EnumType index)
const DataType & operator[] (const EnumType index) const
iterator begin ()
 Getters for forward iterators for ranges.
iterator end ()
const_iterator begin () const
const_iterator end () const
reverse_iterator rbegin ()
 Getters for reverse iterators for ranges.
reverse_iterator rend ()
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const

Static Public Member Functions

static constexpr
keys ()
 Returns an object that provides iterators over the keys.
static constexpr std::size_t size ()
 Returns the size of the enumeration.

Public Attributes

DataType m_elements [std::size_t(ArraySize)]
 Data for names. More...

Member Data Documentation

template<typename EnumType, typename DataType, EnumType ArraySize>
DataType gmx::EnumerationArray< EnumType, DataType, ArraySize >::m_elements[std::size_t(ArraySize)]

Data for names.

Data is kept public so we can use direct aggregate initialization just like in a plain C-style array.

The documentation for this struct was generated from the following files: