OpenTTD Source 20261112-master-gbcbec5e63f
SDLRange< T > Class Template Reference

Helper to map some SDL functions to behave like a std::range. More...

Public Member Functions

template<typename Func, typename ... Args>
 SDLRange (Func func, Args... args)
 Create the range.
 ~SDLRange ()
 Free the data.
 SDLRange (SDLRange &)=delete
 Do not copy.
SDLRange & operator= (const SDLRange &)=delete
 Do not assign.
constexpr T * begin () const
 Iterator to the begin of the data.
constexpr T * end () const
 Iterator to the end of the data.
constexpr size_t size () const
 The number of elements in this range.

Private Attributes

T * data = nullptr
 The base pointer of the array.
int count = 0
 The number of elements.

Detailed Description

template<typename T>
class SDLRange< T >

Helper to map some SDL functions to behave like a std::range.

The kinds of functions this can be used on are those for which the last parameter is a reference to a count, that return a pointer to an array of elements that needs to be freed using SDL_free once not needed anymore.

Definition at line 52 of file sdl3_v.cpp.

Constructor & Destructor Documentation

◆ SDLRange()

template<typename T>
template<typename Func, typename ... Args>
SDLRange< T >::SDLRange ( Func func,
Args... args )
inline

Create the range.

Parameters
funcThe function that returns the pointer.
argsExtra arguments to pass to the function.

Definition at line 62 of file sdl3_v.cpp.

Referenced by operator=(), and SDLRange().

◆ ~SDLRange()

template<typename T>
SDLRange< T >::~SDLRange ( )
inline

Free the data.

Definition at line 64 of file sdl3_v.cpp.

Member Function Documentation

◆ begin()

template<typename T>
T * SDLRange< T >::begin ( ) const
inlineconstexpr

Iterator to the begin of the data.

Returns
The begin.

Definition at line 73 of file sdl3_v.cpp.

References T.

◆ end()

template<typename T>
T * SDLRange< T >::end ( ) const
inlineconstexpr

Iterator to the end of the data.

Returns
The end.

Definition at line 79 of file sdl3_v.cpp.

References count, and T.

◆ size()

template<typename T>
size_t SDLRange< T >::size ( ) const
inlineconstexpr

The number of elements in this range.

Returns
The size of the range.

Definition at line 85 of file sdl3_v.cpp.

Referenced by FindStartupDisplay().

Field Documentation

◆ count

template<typename T>
int SDLRange< T >::count = 0
private

The number of elements.

Definition at line 54 of file sdl3_v.cpp.

Referenced by end().

◆ data

template<typename T>
T* SDLRange< T >::data = nullptr
private

The base pointer of the array.

Definition at line 53 of file sdl3_v.cpp.


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