std::ranges...::operator[](3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… NAME πŸ’…

Bestie, the full name is std::ranges::enumerate_view::iterator::operator[] β€” and yeah, they listed it twice, so we're listing it twice too: std::ranges::enumerate_view::iterator::operator[]. It's giving "government name plus middle names plus confirmation name" energy, but we respect it 🫢. Also quick heads up, this page lives in the C++ Standard Libary manual β€” that's their spelling, not mine, we love them anyway ✨.


🌟 Synopsis 🌟

Okay so here's the whole entire vibe:

constexpr auto operator[]( difference_type n ) const  (since C++23)
    requires ranges::random_access_range<Base>

That (since C++23)? New era, fresh start, main character debut πŸ’–. And the requires ranges::random_access_range<Base> line is the vibe check β€” your Base has to be a random access range or this whole function simply does not apply to you, periodt.

She returns an element at a specified relative location. Equivalent to:

return reference-type(pos_ + n, current_[n]);.

(Yeah the trailing period is part of it, keep it exactly, don't come for me πŸ™ˆ.)

πŸŽ€ Parameters πŸŽ€

  • n β€” position relative to current location. That's the whole parameter, she's simple, she's effective, she's booked and busy.

🌸 Return value 🌸

The element at displacement n relative to the current location. You point at a spot, she hands you the element, iconic behavior honestly πŸ’….

πŸ¦‹ Example πŸ¦‹

This section is incomplete Reason: no example

Not them leaving us on read 😭. No example yet bestie, we wait patiently, we stay hydrated πŸ“.

πŸ‘‘ See also πŸ‘‘

  • operator* β€” accesses the element (C++23) (public member function). Your other bestie for getting your hands on the goods πŸ”₯.

πŸ’œ Category πŸ’œ

  • Todo: no example. Yeah they really said "figure it out yourself" πŸ™ˆ β€” same energy as the Example section, consistent queen.

That's the page, bestie! It's from the C++ Standard Libary manual over at cppreference.com, dated 2024.06.10, for std::ranges...::operator[](3). Go forth and random-access-range responsibly, ily, bye πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from