Namespaces
Variants
Views
Actions

std::end(std::initializer_list)

From cppreference.com
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)

(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
 
template< class E >
const E* end( initializer_list<E> il ) noexcept;
(since C++11)
template< class E >
constexpr const E* end( initializer_list<E> il ) noexcept;
(since C++11)
(until C++14)

The overload of std::end for initializer_list returns a pointer to one past the last element of il.

Contents

[edit] Parameters

il - an initializer_list

[edit] Return value

il.end()

[edit] Example

#include <iostream>
 
int main() 
{
    // range-based for uses std::begin and std::end to iterate
    // over a given range; in this case, it's an initializer list
    for (int i : {3, 1, 4, 1}) {
        std::cout << i << '\n';
    }
}

Output:

3
1
4
1

[edit] See also

returns a pointer to one past the last element
(public member function) [edit]