std::rbegin(std::initializer_list) (3) - Linux Manuals

std::rbegin(std::initializer_list): std::rbegin(std::initializer_list)

NAME

std::rbegin(std::initializer_list) - std::rbegin(std::initializer_list)

Synopsis


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


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

Parameters


il - an initializer_list

Return value


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

Exceptions


(none)

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.

Example


// Run this code


  #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 << '\n';
  }

Output:


  4
  1
  3

See also


rbegin returns a reverse iterator to a container or array
crbegin (function template)


(C++14)


rend returns a reverse end iterator for a container or array
crend (function template)


(C++14)