File indexing completed on 2025-12-16 10:27:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_ALGORITHM_COPY_BACKWARD_HPP
0014 #define RANGES_V3_ALGORITHM_COPY_BACKWARD_HPP
0015
0016 #include <utility>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/algorithm/result_types.hpp>
0021 #include <range/v3/iterator/concepts.hpp>
0022 #include <range/v3/iterator/operations.hpp>
0023 #include <range/v3/iterator/traits.hpp>
0024 #include <range/v3/range/access.hpp>
0025 #include <range/v3/range/concepts.hpp>
0026 #include <range/v3/range/dangling.hpp>
0027 #include <range/v3/range/traits.hpp>
0028 #include <range/v3/utility/static_const.hpp>
0029
0030 #include <range/v3/detail/prologue.hpp>
0031
0032 namespace ranges
0033 {
0034
0035
0036 template<typename I, typename O>
0037 using copy_backward_result = detail::in_out_result<I, O>;
0038
0039 RANGES_FUNC_BEGIN(copy_backward)
0040
0041
0042 template(typename I, typename S, typename O)(
0043 requires bidirectional_iterator<I> AND sentinel_for<S, I> AND
0044 bidirectional_iterator<O> AND indirectly_copyable<I, O>)
0045 constexpr copy_backward_result<I, O> RANGES_FUNC(copy_backward)(I first, S end_, O out)
0046 {
0047 I i = ranges::next(first, end_), last = i;
0048 while(first != i)
0049 *--out = *--i;
0050 return {last, out};
0051 }
0052
0053
0054 template(typename Rng, typename O)(
0055 requires bidirectional_range<Rng> AND bidirectional_iterator<O> AND
0056 indirectly_copyable<iterator_t<Rng>, O>)
0057 copy_backward_result<borrowed_iterator_t<Rng>, O>
0058 constexpr RANGES_FUNC(copy_backward)(Rng && rng, O out)
0059 {
0060 return (*this)(begin(rng), end(rng), std::move(out));
0061 }
0062 RANGES_FUNC_END(copy_backward)
0063
0064 namespace cpp20
0065 {
0066 using ranges::copy_backward;
0067 using ranges::copy_backward_result;
0068 }
0069
0070 }
0071
0072 #include <range/v3/detail/epilogue.hpp>
0073
0074 #endif