Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:54

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2014-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 #ifndef RANGES_V3_ALGORITHM_MOVE_BACKWARD_HPP
0014 #define RANGES_V3_ALGORITHM_MOVE_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     /// \addtogroup group-algorithms
0035     /// @{
0036     template<typename I, typename O>
0037     using move_backward_result = detail::in_out_result<I, O>;
0038 
0039     RANGES_FUNC_BEGIN(move_backward)
0040 
0041         /// \brief function template \c move_backward
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_movable<I, O>)
0045         constexpr move_backward_result<I, O> RANGES_FUNC(move_backward)(I first, S end_, O out) //
0046         {
0047             I i = ranges::next(first, end_), last = i;
0048             while(first != i)
0049                 *--out = iter_move(--i);
0050             return {last, out};
0051         }
0052 
0053         /// \overload
0054         template(typename Rng, typename O)(
0055             requires bidirectional_range<Rng> AND bidirectional_iterator<O> AND
0056             indirectly_movable<iterator_t<Rng>, O>)
0057         constexpr move_backward_result<borrowed_iterator_t<Rng>, O> //
0058         RANGES_FUNC(move_backward)(Rng && rng, O out)            //
0059         {
0060             return (*this)(begin(rng), end(rng), std::move(out));
0061         }
0062 
0063     RANGES_FUNC_END(move_backward)
0064 
0065     namespace cpp20
0066     {
0067         using ranges::move_backward;
0068         using ranges::move_backward_result;
0069     } // namespace cpp20
0070     /// @}
0071 } // namespace ranges
0072 
0073 #include <range/v3/detail/epilogue.hpp>
0074 
0075 #endif