std::ranges::elements_view<V,F>::iterator<Const>::operator*

From cppreference.com
< cpp‎ | ranges‎ | elements view‎ | iterator
 
 
Ranges library
Range access
Range conversions
(C++23)
Range primitives



Dangling iterator handling
Range concepts
Views

Range factories
Range adaptors
Range generators
Range adaptor objects
Range adaptor closure objects
Helper items
(until C++23)(C++23)


 
 
constexpr decltype(auto) operator*() const;
(since C++20)

Returns the element into V the underlying iterator points to.

Effectively returns /*get-element*/(this->base()), where for an expression e, /*get-element*/(e) is

Parameters

(none)

Return value

The current element.

Notes

operator-> is not provided.

Example

#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

accesses an element by index
(public member function)