Back to home page

EIC code displayed by LXR

 
 

    


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

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_REVERSE_COPY_HPP
0014 #define RANGES_V3_ALGORITHM_REVERSE_COPY_HPP
0015 
0016 #include <meta/meta.hpp>
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 reverse_copy_result = detail::in_out_result<I, O>;
0038 
0039     RANGES_FUNC_BEGIN(reverse_copy)
0040 
0041         /// \brief function template \c reverse_copy
0042         template(typename I, typename S, typename O)(
0043             requires bidirectional_iterator<I> AND sentinel_for<S, I> AND
0044             weakly_incrementable<O> AND indirectly_copyable<I, O>)
0045         constexpr reverse_copy_result<I, O> RANGES_FUNC(reverse_copy)(I first, S end_, O out) //
0046         {
0047             I last = ranges::next(first, end_), res = last;
0048             for(; first != last; ++out)
0049                 *out = *--last;
0050             return {res, out};
0051         }
0052 
0053         /// \overload
0054         template(typename Rng, typename O)(
0055             requires bidirectional_range<Rng> AND weakly_incrementable<O> AND
0056             indirectly_copyable<iterator_t<Rng>, O>)
0057         constexpr reverse_copy_result<borrowed_iterator_t<Rng>, O> //
0058         RANGES_FUNC(reverse_copy)(Rng && rng, O out)            //
0059         {
0060             return (*this)(begin(rng), end(rng), std::move(out));
0061         }
0062 
0063     RANGES_FUNC_END(reverse_copy)
0064 
0065     namespace cpp20
0066     {
0067         using ranges::reverse_copy;
0068         using ranges::reverse_copy_result;
0069     } // namespace cpp20
0070     /// @}
0071 } // namespace ranges
0072 
0073 #include <range/v3/detail/epilogue.hpp>
0074 
0075 #endif