OpenTTD Source 20260218-master-g2123fca5ea
EnumClassIndexContainer< Container, Index > Class Template Reference

A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific enum class. More...

#include <enum_type.hpp>

Inheritance diagram for EnumClassIndexContainer< Container, Index >:

Public Member Functions

Container::reference at (size_t pos)
Container::reference at (const Index &pos)
Container::const_reference at (size_t pos) const
Container::const_reference at (const Index &pos) const
Container::reference operator[] (size_t pos)
Container::reference operator[] (const Index &pos)
Container::const_reference operator[] (size_t pos) const
Container::const_reference operator[] (const Index &pos) const

Detailed Description

template<typename Container, typename Index>
class EnumClassIndexContainer< Container, Index >

A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific enum class.

This to prevent having to call 'to_underlying()' for many container accesses, whilst preventing accidental use of the wrong index type.

Template Parameters
ContainerA base container.
IndexThe enum class to use for indexing.

Definition at line 247 of file enum_type.hpp.

Member Function Documentation

◆ at() [1/4]

template<typename Container, typename Index>
Container::reference EnumClassIndexContainer< Container, Index >::at ( const Index & pos)
inline

Definition at line 250 of file enum_type.hpp.

◆ at() [2/4]

template<typename Container, typename Index>
Container::const_reference EnumClassIndexContainer< Container, Index >::at ( const Index & pos) const
inline

Definition at line 253 of file enum_type.hpp.

◆ at() [3/4]

template<typename Container, typename Index>
Container::reference EnumClassIndexContainer< Container, Index >::at ( size_t pos)
inline

Definition at line 249 of file enum_type.hpp.

◆ at() [4/4]

template<typename Container, typename Index>
Container::const_reference EnumClassIndexContainer< Container, Index >::at ( size_t pos) const
inline

Definition at line 252 of file enum_type.hpp.

◆ operator[]() [1/4]

template<typename Container, typename Index>
Container::reference EnumClassIndexContainer< Container, Index >::operator[] ( const Index & pos)
inline

Definition at line 256 of file enum_type.hpp.

◆ operator[]() [2/4]

template<typename Container, typename Index>
Container::const_reference EnumClassIndexContainer< Container, Index >::operator[] ( const Index & pos) const
inline

Definition at line 259 of file enum_type.hpp.

◆ operator[]() [3/4]

template<typename Container, typename Index>
Container::reference EnumClassIndexContainer< Container, Index >::operator[] ( size_t pos)
inline

Definition at line 255 of file enum_type.hpp.

◆ operator[]() [4/4]

template<typename Container, typename Index>
Container::const_reference EnumClassIndexContainer< Container, Index >::operator[] ( size_t pos) const
inline

Definition at line 258 of file enum_type.hpp.


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