Back to home page

EIC code displayed by LXR

 
 

    


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

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_COPY_N_HPP
0014 #define RANGES_V3_ALGORITHM_COPY_N_HPP
0015 
0016 #include <functional>
0017 #include <tuple>
0018 #include <utility>
0019 
0020 #include <range/v3/range_fwd.hpp>
0021 
0022 #include <range/v3/algorithm/result_types.hpp>
0023 #include <range/v3/functional/identity.hpp>
0024 #include <range/v3/iterator/concepts.hpp>
0025 #include <range/v3/iterator/operations.hpp>
0026 #include <range/v3/iterator/traits.hpp>
0027 #include <range/v3/range/access.hpp>
0028 #include <range/v3/range/concepts.hpp>
0029 #include <range/v3/range/traits.hpp>
0030 #include <range/v3/utility/static_const.hpp>
0031 
0032 #include <range/v3/detail/prologue.hpp>
0033 
0034 namespace ranges
0035 {
0036     /// \addtogroup group-algorithms
0037     /// @{
0038     template<typename I, typename O>
0039     using copy_n_result = detail::in_out_result<I, O>;
0040 
0041     RANGES_FUNC_BEGIN(copy_n)
0042 
0043         /// \brief function template \c copy_n
0044         template(typename I, typename O, typename P = identity)(
0045             requires input_iterator<I> AND weakly_incrementable<O> AND
0046             indirectly_copyable<I, O>)
0047         constexpr copy_n_result<I, O> RANGES_FUNC(copy_n)(I first, iter_difference_t<I> n, O out)
0048         {
0049             RANGES_EXPECT(0 <= n);
0050             auto norig = n;
0051             auto b = uncounted(first);
0052             for(; n != 0; ++b, ++out, --n)
0053                 *out = *b;
0054             return {recounted(first, b, norig), out};
0055         }
0056 
0057     RANGES_FUNC_END(copy_n)
0058 
0059     namespace cpp20
0060     {
0061         using ranges::copy_n;
0062         using ranges::copy_n_result;
0063     } // namespace cpp20
0064     /// @}
0065 } // namespace ranges
0066 
0067 #include <range/v3/detail/epilogue.hpp>
0068 
0069 #endif