std::ranges...::operator[](3)
πΈ std::ranges...::operator[](3) πΈ
okay so welcome to the C++ Standard Libary manual β yep, "Libary" is the spelling right there in the manual name, no cap π β and this page is the whole vibe for std::ranges::zip_transform_view::iterator::operator[].
π NAME π
std::ranges::zip_transform_view::iterator::operator[] β that's the name, bestie. The page literally lists it as:
std::ranges::zip_transform_view::iterator::operator[]std::ranges::zip_transform_view::iterator::operator[]
so yeah, it's giving "same thing twice" but that's what the manual says π«Ά
π Synopsis π
Here's the signature, copied exactly so you can trust it:
constexpr decltype(auto) operator[]( difference_type n ) const
(since C++23)
requires ranges::random_access_range<Base>;
So it's constexpr, it returns decltype(auto), it takes a difference_type n, it's const, it's since C++23, and there's a requires clause: ranges::random_access_range<Base> β¨
It returns the element at the specified relative location, after transformation. Slay.
It's equivalent to this exact code right here:
return
std::apply
(
[&]<class... Is>(const Is&... iters) -> decltype(auto)
{
return std::invoke(*parent_->fun_,
iters[std::iter_difference_t<Is>(n)]...);
},
inner_.current_
);
where *parent_->fun_ is the transformation function of type F stored in the parent ranges::zip_transform_view, and current_ is the underlying tuple of iterators into Views.... iykyk π
π Parameters π
nβ position relative to current location. That's the whole parameter list, periodt.
π Return value π
The element which is the result of transformation (mapping). That's the return value, fr fr.
β οΈ Notes β οΈ
The behavior is undefined if theparent_pointer to parentranges::zip_transform_viewis null (e.g. if*thisis default constructed). bestie please do not default-construct this and then call it, that's not the move ππ
π§ͺ Example π§ͺ
This section is incomplete.
Reason: no example.
Yeah, the page itself says that. Not me being lazy, I prom π
π·οΈ Category π·οΈ
* Todo no example
π okay final sign-off: source/version/date is http://cppreference.com Β· 2024.06.10 Β· page std::ranges...::operator[](3) β we out, bestie! π«ΆπΈ
π¦ 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