FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
std::initializer_list< T > Class Template Reference

C++ standard support for "initializer_list". More...

#include <fastarduino/initializer_list.h>

Public Member Functions

constexpr initializer_list ()=default
 Create an empty initializer list.
 
constexpr size_t size () const
 The size of this initializer_list. More...
 
constexpr const T * begin () const
 The first element of this initializer_list. More...
 
constexpr const T * end () const
 One past the last element of this initializer_list. More...
 

Detailed Description

template<class T>
class std::initializer_list< T >

C++ standard support for "initializer_list".

This creates a temporary array in C++11 list-initialization and then references it. An initializer_list instance is automatically constructed when a braced-init-list is used to list-initialize an object, where the corresponding constructor accepts an initializer_list parameter.

Using an initializer_list argument is done through a standard C++ iterator loop:

void f(initializer_list<int> list) {
for (auto x : list)
cout << *x << endl;
}
C++ standard support for "initializer_list".

where the iterator type is simply const T*. That code could also be written in a more traditional and more verbose way:

void f(initializer_list<int> list) {
for (const int* x = list.begin(); x != list.end(); ++x)
cout << *x << endl;
}
constexpr const T * begin() const
The first element of this initializer_list.
constexpr const T * end() const
One past the last element of this initializer_list.
Template Parameters
Tthe type of objects in this initializer_list

Definition at line 56 of file initializer_list.h.

Member Function Documentation

◆ size()

template<class T >
constexpr size_t std::initializer_list< T >::size ( ) const
inlineconstexpr

The size of this initializer_list.


Definition at line 73 of file initializer_list.h.

◆ begin()

template<class T >
constexpr const T * std::initializer_list< T >::begin ( ) const
inlineconstexpr

The first element of this initializer_list.

Definition at line 79 of file initializer_list.h.

◆ end()

template<class T >
constexpr const T * std::initializer_list< T >::end ( ) const
inlineconstexpr

One past the last element of this initializer_list.

Definition at line 85 of file initializer_list.h.


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