Skip to content

vector_pro::rbegin

C++
iterator_pro<value_type> rbegin() const noexcept;

Return iterator to reverse beginning

Returns an iterator_pro pointing to the last element in the container and grows in a reverse way.

Parameters

none

Return value

An iterator_pro to the reverse beginning of the sequence.

Example

C++
// vector_pro::rbegin/rend
#include <iostream>
#include "vector_pro.h"

/**
 * Output:
 * myvector contains: 5 4 3 2 1
 */

int main ()
{
  vector_pro<int> myvector (5, 0);  // 5 default-constructed ints

  int i=0;

  iterator_pro<int> rit = myvector.rbegin();
  for (; rit!= myvector.rend(); ++rit)
    *rit = ++i;

  std::cout << "myvector contains:";
  for (auto it = myvector.begin(); it != myvector.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}

Complexity

Constant.