Namespaces
Variants
Views
Actions

std::reverse_iterator<Iter>::base

From cppreference.com
 
 
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
 
Iterator base() const;

Returns the underlying base iterator.

The base iterator refers to the element that is next to the element the reverse_iterator is currently pointing to. That is &*(rit.base() - 1) == &*rit.

Contents

Parameters

(none)

Return value

The underlying iterator.

Exceptions

(none)

Example

#include <iostream>
#include <iterator>
#include <vector>
 
int main()
{
    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
 
    using RevIt = std::reverse_iterator<std::vector<int>::iterator>;
    RevIt r_end(v.begin());
    RevIt r_begin(v.end());
 
    for (auto it = r_end.base(); it != r_begin.base(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << "\n";
}

Output:

0 1 2 3 4 5

See also

accesses the pointed-to element
(public member function) [edit]