std::initializer_list<T>::initializer_list (3) - Linux Manuals
std::initializer_list<T>::initializer_list: std::initializer_list<T>::initializer_list
Command to display std::initializer_list<T>::initializer_list
manual in Linux: $ man 3 std::initializer_list<T>::initializer_list
NAME
std::initializer_list<T>::initializer_list - std::initializer_list<T>::initializer_list
Synopsis
initializer_list() noexcept; (since C++11)
(until C++14)
constexpr initializer_list() noexcept; (since C++14)
Constructs an empty initializer list.
Parameters
(none)
Complexity
Constant
Example
// Run this code
#include <iostream>
#include <initializer_list>
int main()
{
std::initializer_list<int> empty_list;
std::cout << "empty_list.size(): " << empty_list.size() << '\n';
// create initializer lists using list-initialization
std::initializer_list<int> digits {1, 2, 3, 4, 5};
std::cout << "digits.size(): " << digits.size() << '\n';
// special rule for auto means 'fractions' has the
// type std::initializer_list<double>
auto fractions = {3.14159, 2.71828};
std::cout << "fractions.size(): " << fractions.size() << '\n';
}
Output:
empty_list.size(): 0
digits.size(): 5
fractions.size(): 2
Notes
Despite a lack of constructors, it is possible to create non-empty initializer lists. Instances of std::initializer_list are implicitly constructed when:
* a braced-init-list is used in list-initialization, including function-call list initialization and assignment expressions (not to be confused with constructor_initializer_lists)
* a braced-init-list is bound to auto, including in a ranged_for_loop
Pages related to std::initializer_list<T>::initializer_list
- std::initializer_list<T>::begin (3) - std::initializer_list<T>::begin
- std::initializer_list<T>::end (3) - std::initializer_list<T>::end
- std::initializer_list<T>::size (3) - std::initializer_list<T>::size
- std::initializer_list (3) - std::initializer_list
- std::in_place,std::in_place_type,std::in_place_index,std::in_place_t, (3) - std::in_place,std::in_place_type,std::in_place_index,std::in_place_t,
- std::in_place,std::in_place_type,std::in_place_index,std::in_place_t,std::in_place_type_t,std::in_place_index_t (3) - std::in_place,std::in_place_type,std::in_place_index,std::in_place_t,std::in_place_type_t,std::in_place_index_t
- std::includes (3) - std::includes
- std::inclusive_scan (3) - std::inclusive_scan
- std::incrementable_traits (3) - std::incrementable_traits
- std::independent_bits_engine (3) - std::independent_bits_engine
- std::independent_bits_engine<Engine,W,UIntType>::base (3) - std::independent_bits_engine<Engine,W,UIntType>::base