std::ranges::subrange<I,S,K>::prev
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Ranges library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++23)(C++23)
  (C++26)(C++26)
(C++23)(C++23)
  (C++26)(C++26)
(C++26)(C++26)
  (C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
  (C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
std::ranges::subrange 
 
subrange::prev
constexpr subrange prev( std::iter_difference_t <I> n = 1 ) const
requires std::bidirectional_iterator <I>;
 
 (since C++20) 
requires std::bidirectional_iterator <I>;
Returns a copy of *this whose begin_  is decremented (or incremented if n is negative). The actual decrement (or increment) operation is performed by advance().
Equivalent to:auto tmp = *this;
tmp.advance(-n);
return tmp;.
Contents
[edit] Parameters
 n
 -
 number of decrements of the iterator
[edit] Return value
As described above.
[edit] Notes
The difference between this function and advance() is that the latter performs the decrement (or increment) in place.
[edit] Example
Run this code
#include <iterator> #include <list> #include <print> #include <ranges> int main() { std::list list{1, 2, 3, 4, 5}; std::ranges::subrange sub{std::next (list.begin(), 2), std::prev (list.end(), 2)}; std::println ("{} {} {}", sub, sub.prev(), sub.prev(2)); }
Output:
[3] [2, 3] [1, 2, 3]
[edit] See also
 
 obtains a copy of the 
(public member function) [edit]
subrange with its iterator advanced by a given distance (public member function) [edit]