header_utils
Loading...
Searching...
No Matches
ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE > Struct Template Reference

Same as std::array except it takes an enum type instead of the size, and uses magic_enum to determine the array size; also allows for indexing with the enum type. More...

#include <enums.h>

Inherits std::array< VALUE_TYPE, magic_enum::enum_count< ENUM_TYPE >()>.

Public Types

using array_type = std::array< VALUE_TYPE, magic_enum::enum_count< ENUM_TYPE >()>
 
using value_type = array_type::value_type
 
using size_type = array_type::size_type
 
using difference_type = array_type::difference_type
 
using pointer = array_type::pointer
 
using const_pointer = array_type::const_pointer
 
using reference = array_type::reference
 
using const_reference = array_type::const_reference
 
using iterator = array_type::iterator
 
using const_iterator = array_type::const_iterator
 
using reverse_iterator = array_type::reverse_iterator
 
using const_reverse_iterator = array_type::const_reverse_iterator
 
using enum_type = ENUM_TYPE
 

Public Member Functions

constexpr reference at (ENUM_TYPE pos)
 
constexpr const_reference at (ENUM_TYPE pos) const
 
constexpr reference operator[] (ENUM_TYPE pos) noexcept
 
constexpr const_reference operator[] (ENUM_TYPE pos) const noexcept
 

Detailed Description

template<typename VALUE_TYPE, typename ENUM_TYPE>
requires std::is_enum_v<ENUM_TYPE>
struct ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >

Same as std::array except it takes an enum type instead of the size, and uses magic_enum to determine the array size; also allows for indexing with the enum type.

Definition at line 22 of file enums.h.

Member Typedef Documentation

◆ array_type

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::array_type = std::array<VALUE_TYPE, magic_enum::enum_count<ENUM_TYPE>()>

Definition at line 24 of file enums.h.

◆ const_iterator

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::const_iterator = array_type::const_iterator

Definition at line 34 of file enums.h.

◆ const_pointer

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::const_pointer = array_type::const_pointer

Definition at line 30 of file enums.h.

◆ const_reference

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::const_reference = array_type::const_reference

Definition at line 32 of file enums.h.

◆ const_reverse_iterator

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::const_reverse_iterator = array_type::const_reverse_iterator

Definition at line 36 of file enums.h.

◆ difference_type

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::difference_type = array_type::difference_type

Definition at line 28 of file enums.h.

◆ enum_type

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::enum_type = ENUM_TYPE

Definition at line 38 of file enums.h.

◆ iterator

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::iterator = array_type::iterator

Definition at line 33 of file enums.h.

◆ pointer

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::pointer = array_type::pointer

Definition at line 29 of file enums.h.

◆ reference

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::reference = array_type::reference

Definition at line 31 of file enums.h.

◆ reverse_iterator

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::reverse_iterator = array_type::reverse_iterator

Definition at line 35 of file enums.h.

◆ size_type

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::size_type = array_type::size_type

Definition at line 27 of file enums.h.

◆ value_type

template<typename VALUE_TYPE , typename ENUM_TYPE >
using ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::value_type = array_type::value_type

Definition at line 26 of file enums.h.

Member Function Documentation

◆ at() [1/2]

template<typename VALUE_TYPE , typename ENUM_TYPE >
constexpr reference ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::at ( ENUM_TYPE  pos)
inlineconstexpr

Definition at line 40 of file enums.h.

◆ at() [2/2]

template<typename VALUE_TYPE , typename ENUM_TYPE >
constexpr const_reference ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::at ( ENUM_TYPE  pos) const
inlineconstexpr

Definition at line 44 of file enums.h.

◆ operator[]() [1/2]

template<typename VALUE_TYPE , typename ENUM_TYPE >
constexpr const_reference ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::operator[] ( ENUM_TYPE  pos) const
inlineconstexprnoexcept

Definition at line 52 of file enums.h.

◆ operator[]() [2/2]

template<typename VALUE_TYPE , typename ENUM_TYPE >
constexpr reference ghassanpl::enum_array< VALUE_TYPE, ENUM_TYPE >::operator[] ( ENUM_TYPE  pos)
inlineconstexprnoexcept

Definition at line 48 of file enums.h.