FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
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.
 
constexpr const T * end () const
 One past the last element of this initializer_list.
 

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_ist argument is done through a standard C++ iterator loop:

void f(initializer_list<int> list) {
for (auto x : list)
cout << *x << endl;
}

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;
}
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.


The documentation for this class was generated from the following file:
streams::endl
void endl(FSTREAM &stream)
Manipulator for an output stream, which will insert a new-line character and flush the stream buffer.
Definition: streams.h:722