Namespaces
Variants
Views
Actions

std::rbegin(std::initializer_list)

From cppreference.com
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (C++20)
Dynamic memory management
Program utilities
Coroutine support (C++20)
Variadic functions
Debugging support
(C++26)
Three-way comparison
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(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++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)

 
 
Defined in header <iterator>
template <class E>
std::reverse_iterator<const E*> rbegin( std::initializer_list<E> il );
(since C++14)

The overload of std::rbegin for initializer_list returns an std::reverse_iterator pointing at the last element of il.

Contents

[edit] Parameters

il - an initializer_list

[edit] Return value

std::reverse_iterator<const E*>(il.end()).

[edit] Exceptions

May throw implementation-defined exceptions.

[edit] Notes

This overload is necessary because std::initializer_list does not have a member function rbegin. No overload is needed for std::crbegin because it is implemented in terms of std::rbegin.

[edit] Example

#include <iostream>
#include <iterator>
 
int main() 
{
    auto il = { 3, 1, 4 };
    for (auto it = std::rbegin(il); it != std::rend(il); ++it)
        std::cout << *it << ' '; 
}

Output:

4 1 3

[edit] See also

returns a reverse iterator to the beginning of a container or array
(function template) [edit]
(C++14)
returns a reverse end iterator for a container or array
(function template) [edit]