OpenTTD Source 20260129-master-g2bb01bd0e4
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 212 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 215 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 218 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 214 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 217 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 221 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 224 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 220 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 223 of file enum_type.hpp.


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