std::revers...erator::base(3)
π
std::reverse_iterator::base π
okay bestie, welcome to the C++ Standard Library manual page for std::reverse_iterator::base β yes, the whole manual name is getting folded in right here at the top like a little name tag π«Ά
β¨ NAME β¨
std::reverse_iterator::base β std::reverse_iterator::base
π Synopsis π
iterator_type base() const; (until C++17)
constexpr iterator_type base() const; (since C++17)
Returns the underlying base iterator. That is std::reverse_iterator(it).base() == it.
The base iterator refers to the element that is next (from the std::reverse_iterator::iterator_type perspective) to the element the reverse_iterator is currently pointing to. That is &*(rit.base() - 1) == &*rit.
πΈ Parameters πΈ
(none)
π Return value π
The underlying iterator.
π Exceptions π
May throw implementation-defined exceptions.
π¦ Example π¦
// Run this code
#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>;
const auto it = v.begin() + 3;
RevIt r_it{it};
std::cout << "*it == " << *it << '\n'
<< "*r_it == " << *r_it << '\n'
<< "*r_it.base() == " << *r_it.base() << '\n'
<< "*(r_it.base()-1) == " << *(r_it.base() - 1) << '\n';
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';
for (auto it = r_begin; it != r_end; ++it)
std::cout << *it << ' ';
std::cout << '\n';
}
π Output π
*it == 3
*r_it == 2
*r_it.base() == 3
*(r_it.base()-1) == 2
0 1 2 3 4 5
5 4 3 2 1 0
π See also π
operator*β accesses the pointed-to elementoperator->β (public member function)
byeee bestie π this pageβs source/version is http://cppreference.com, dated 2024.06.10 β go slay some iterators β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms