OpenTTD Source 20260421-master-gc2fbc6fdeb
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 (const Index &pos)
Container::const_reference at (const Index &pos) const
Container::reference operator[] (const Index &pos)
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/2]

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

Definition at line 249 of file enum_type.hpp.

◆ at() [2/2]

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

Definition at line 251 of file enum_type.hpp.

◆ operator[]() [1/2]

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

Definition at line 253 of file enum_type.hpp.

◆ operator[]() [2/2]

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

Definition at line 255 of file enum_type.hpp.


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