8#ifndef STLAB_ALGORITHM_REVERSE_HPP
9#define STLAB_ALGORITHM_REVERSE_HPP
22#include <stlab/config.hpp>
29STLAB_VERSION_NAMESPACE_BEGIN()
46template <STLAB_CONCEPT(FORWARD_NODE_ITERATOR) I>
48 while (first != last) {
91template <
class B
idirectionalRange>
92inline void reverse(BidirectionalRange& range) {
93 std::reverse(std::begin(range), std::end(range));
98template <
class B
idirectionalRange,
class OutputIterator>
99inline void reverse_copy(BidirectionalRange& range, OutputIterator result) {
100 std::reverse_copy(std::begin(range), std::end(range), result);
105template <
class B
idirectionalRange,
class OutputIterator>
106inline void reverse_copy(
const BidirectionalRange& range, OutputIterator result) {
107 std::reverse_copy(std::begin(range), std::end(range), result);
117 while (f != m && m != l) {
120 std::iter_swap(f, l);
125 return std::pair<I, I>(f, l);
132STLAB_VERSION_NAMESPACE_END()
Iterator concepts when the compiler supports C++20 concepts.
void reverse(BidirectionalRange &range)
Range-based reverse, will be deprecated in C++20 in favor of std::ranges::reverse.
Definition reverse.hpp:92
void reverse_copy(BidirectionalRange &range, OutputIterator result)
Range-based reverse_copy algorithm, will be deprecated in C++20 in favor of std::ranges::reverse_copy...
Definition reverse.hpp:99
auto reverse_until(I f, I m, I l) -> std::pair< I, I >
Reverses the range [f, l) until m is reached. Returns a range [a, b) of the un-reversed subrange such...
Definition reverse.hpp:116
void set_next(const I &x, const I &y)
Sets the successor of the node referenced by x to y (via set_next_fn<I>).
Definition set_next.hpp:41
Definition reverse.hpp:39
auto reverse_append(I first, I last, I end) -> I
Reverses the range [first, last) and appends end. Returns the beginning of the reversed range such th...
Definition reverse.hpp:47
auto reverse_nodes(I first, I last) -> I
Reverses the range [first, last) and returns the beginning of the reversed range such that [result,...
Definition reverse.hpp:70
Definition reverse.hpp:28
Intrusive forward/bidirectional iterator helpers (set_next, splice, skip).