std::ranges...brange::prev(3)
β¨ NAME β¨
okay so this is the std::ranges...brange::prev(3) page from the C++ Standard Libary, and bestie, the main character is literally std::ranges::subrange::prev β like, the name is right there twice: std::ranges::subrange::prev - std::ranges::subrange::prev. π
πΈ Synopsis πΈ
hereβs the whole vibe check, no cap:
[[nodiscard]] constexpr subrange prev( std::iter_difference_t<I> n =
1 ) const
this one is (since C++20) and it has a requirement: requires std::bidirectional_iterator<I>; β so bidirectional iterators only, bestie. π«Ά
It gives you a subrange whose iterator is decremented by n times, or incremented by min(-n, size()) times relative to that of *this, when n >= 0 or n < 0 respectively. Literally equivalent to auto tmp = *this; tmp.advance(-n); return tmp;. And the serious warning: the behavior is undefined if the iterator is decremented after being a non-decrementable value. Thatβs a hard no π.
π Parameters π
nβ number of minimal decrements of the iterator.
π Return value π
A subrange whose iterator is decremented by n times or incremented by min(-n, size()) times relative to that of *this, when n >= 0 or n < 0 respectively. Same energy as above, just the return-value section saying it again. β¨
π¦ Complexity π¦
Generally n decrements or min(-n, size()) increments on the iterator, when n >= 0 or n < 0 respectively.
Constant if I models random_access_iterator, and either n >= 0 or std::sized_sentinel_for<S, I> is modeled. slay for random access π.
π Example π
This section is incomplete.
Reason: no example.
so no example here β the docs are literally telling on themselves π.
π See also π
next(C++20)β obtains a copy of the subrange with its iterator advanced by a given distance (public member function)advance(C++20)β advances the iterator by given distance (public member function)prev(C++11)β decrement an iterator (function template)ranges::prev(C++20)β decrement an iterator by a given distance or to a bound (niebloid)
π Category π
Todo no example
before you close the tab: this page is from http://cppreference.com, dated 2024.06.10, and the footer title is std::ranges...brange::prev(3). mwah πβ¨
π¦ 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