std::experi...es::advance(3)
π NAME π
Okay so this page is std::experi...es::advance(3) from the C++ Standard Libary manual, section 3 β and the name is std::experimental::ranges::advance, which is also std::experimental::ranges::advance. Yes bestie, it said the same thing twice, and honestly? iconic π
.
β¨ Synopsis β¨
Defined in header <experimental/ranges/iterator>.
namespace {
constexpr /* unspecified */ advance = /* unspecified */;
}
The namespace block is tagged (ranges TS), and the advance thing is a (customization point object).
π¦ Call signature π¦
(1)
template< Iterator I >
constexpr void advance( I& i, ranges::difference_type_t<I> n );
(2)
template< Iterator I, Sentinel<I> S >
constexpr void advance( I& i, S bound );
(3)
template< Iterator I, Sentinel<I> S >
constexpr ranges::difference_type_t<I> advance( I& i, ranges::difference_type_t<I> n, S bound );
Advances the iterator i n times, or until bound is reached, whichever comes first. π«
- Overload (1) β If
ImodelsRandomAccessIterator, itβs equivalent toi += n. Otherwise, it increments (or decrements ifnis negative)intimes.
The behavior is undefined ifnis negative andIdoes not modelBidirectionalIterator. π
- Overload (2) β If
Assignable<I&, S>is satisfied, itβs equivalent toi = std::move(bound). Otherwise, if[i, bound)does not denote a range, the behavior is undefined. Otherwise, ifSizedSentinel<S, I>is satisfied, itβs equivalent toranges::advance(i, bound - i). Otherwise, it incrementsiuntili == bound. - Overload (3) β If
SizedSentinel<S, I>is satisfied, itβs equivalent toranges::advance(i, bound)if|n| >= |bound - i|, andranges::advance(i, n)otherwise. Otherwise, it increments (or decrements ifnis negative)ieitherntimes or untili == bound, whichever comes first.
If n > 0, [i, bound) shall denote a range; if n == 0, either [i, bound) or [bound, i) shall denote a range; if n < 0, [bound, i) shall denote a range, I and S shall be the same type, and I must model BidirectionalIterator. Otherwise, the behavior is undefined.
πΈ Return value πΈ
- 1, 2) β
(none) - 3) β The number of increment/decrements not performed due to reaching
bound. In other words,n - M, whereMis the distance from the starting position ofito the ending position and is negative if the ending position is before the starting position.
π¦ Example π¦
This section is incomplete.
Reason: no example
π See also π
advanceβ advances an iterator by given distance (function template)distanceβ returns the distance between an iterator and a sentinel, or between the beginning and the end of a range (function template)nextβ increment an iterator (function template)prevβ decrement an iterator (function template)
π Category π
- Todo no example
okay thatβs the whole page, bestie π
β source: http://cppreference.com, version/date: 2024.06.10, page: std::experi...es::advance(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