std::ranges...r::operator*(3)
β¨ NAME β¨
okay so bestie, this is the std::ranges...r::operator*(3) page from the C++ Standard Libary manual (yes, the header literally spells it βLibaryβ β we love a typo era π
), and itβs all about dereferencing an iterator from elements_view. Letβs get into it π«Ά
std::ranges::elements_view::iterator::operator* β std::ranges::elements_view::iterator::operator*
πΈ SYNOPSIS πΈ
constexpr decltype(auto) operator*() const; (since C++20)
This returns the element into V that the underlying iterator points to. No cap, thatβs the whole vibe β¨
Effectively returns /*get-element*/(this->base()), where for an expression e, /*get-element*/(e) is:
*std::get<N>(*e), ifranges::range_reference_t<Base>is a reference type. Otherwise,static_cast<E>(std::get<N>(*e)), whereEisstd::remove_cv_t<std::tuple_element_t<N, ranges::range_reference_t<Base>>>.
π PARAMETERS π
(none) β zero parameters, bestie. Itβs giving βno thoughts, just vibesβ π
π RETURN VALUE π
The current element. Thatβs it, thatβs the tea π
π¦ NOTES π¦
operator-> is not provided. So donβt go looking for it, okay? π
β¨ EXAMPLE β¨
// Run this code
#include <iostream>
#include <ranges>
#include <string_view>
#include <tuple>
int main()
{
using T = std::tuple<int, char, std::string_view>;
const auto il = {
T{1, 'A', "Ξ±"},
T{2, 'B', "Ξ²"},
T{3, 'C', "Ξ³"},
};
const auto view {il | std::views::elements<2>};
const auto iter {view.begin() + 1};
std::cout << *iter << '\n';
}
π Output π
Ξ²
π SEE ALSO π
operator[]β accesses an element by index (C++20) (public member function)
mwah π β source: http://cppreference.com, version/date 2024.06.10, page std::ranges...r::operator*(3). bye bestie, go dereference responsibly ππ«Ά
π¦ 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