Namespaces
Variants
Views
Actions

std::reverse_iterator::base

From cppreference.com
< cpp‎ | iterator‎ | reverse iterator
Revision as of 11:29, 26 April 2013 by Eendy (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl ">

<td class="t-dcl-nopad">
Iterator base() const;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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 std::reverse_iterator(it).base() == std::next(it).

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

Template:cpp/iterator/adaptor/dcl list operator*