/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_ALGORITHM_COPY_BACKWARD_HPP #define RANGES_V3_ALGORITHM_COPY_BACKWARD_HPP #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-algorithms /// @{ template using copy_backward_result = detail::in_out_result; RANGES_BEGIN_NIEBLOID(copy_backward) /// \brief function template \c copy_backward template auto RANGES_FUN_NIEBLOID(copy_backward)(I first, S end_, O out) ->CPP_ret(copy_backward_result)( // requires bidirectional_iterator && sentinel_for && bidirectional_iterator && indirectly_copyable) { I i = ranges::next(first, end_), last = i; while(first != i) *--out = *--i; return {last, out}; } /// \overload template auto RANGES_FUN_NIEBLOID(copy_backward)(Rng && rng, O out) ->CPP_ret(copy_backward_result, O>)( // requires bidirectional_range && bidirectional_iterator && indirectly_copyable, O>) { return (*this)(begin(rng), end(rng), std::move(out)); } RANGES_END_NIEBLOID(copy_backward) namespace cpp20 { using ranges::copy_backward; using ranges::copy_backward_result; } // namespace cpp20 /// @} } // namespace ranges #endif // include guard