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 2013-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_HPP
0014 #define RANGES_V3_ALGORITHM_COPY_HPP
0015 
0016 #include <functional>
0017 #include <utility>
0018 
0019 #include <range/v3/range_fwd.hpp>
0020 
0021 #include <range/v3/algorithm/result_types.hpp>
0022 #include <range/v3/iterator/concepts.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/copy.hpp>
0029 #include <range/v3/utility/static_const.hpp>
0030 
0031 #include <range/v3/detail/prologue.hpp>
0032 
0033 namespace ranges
0034 {
0035     /// \addtogroup group-algorithms
0036     /// @{
0037     template<typename I, typename O>
0038     using copy_result = detail::in_out_result<I, O>;
0039 
0040     RANGES_HIDDEN_DETAIL(namespace _copy CPP_PP_LBRACE())
0041     RANGES_FUNC_BEGIN(copy)
0042 
0043         /// \brief function template \c copy
0044         template(typename I, typename S, typename O)(
0045             requires input_iterator<I> AND sentinel_for<S, I> AND
0046             weakly_incrementable<O> AND indirectly_copyable<I, O>)
0047         constexpr copy_result<I, O> RANGES_FUNC(copy)(I first, S last, O out) //
0048         {
0049             for(; first != last; ++first, ++out)
0050                 *out = *first;
0051             return {first, out};
0052         }
0053 
0054         /// \overload
0055         template(typename Rng, typename O)(
0056             requires input_range<Rng> AND weakly_incrementable<O> AND
0057             indirectly_copyable<iterator_t<Rng>, O>)
0058         constexpr copy_result<borrowed_iterator_t<Rng>, O> //
0059         RANGES_FUNC(copy)(Rng && rng, O out)  //
0060         {
0061             return (*this)(begin(rng), end(rng), std::move(out));
0062         }
0063 
0064     RANGES_FUNC_END(copy)
0065     RANGES_HIDDEN_DETAIL(CPP_PP_RBRACE())
0066 
0067 #ifndef RANGES_DOXYGEN_INVOKED
0068     struct copy_fn
0069       : aux::copy_fn
0070       , _copy::copy_fn
0071     {
0072         using aux::copy_fn::operator();
0073         using _copy::copy_fn::operator();
0074     };
0075     RANGES_INLINE_VARIABLE(copy_fn, copy)
0076 #endif
0077 
0078     namespace cpp20
0079     {
0080         using ranges::copy_result;
0081         using ranges::RANGES_HIDDEN_DETAIL(_copy::) copy;
0082     } // namespace cpp20
0083 
0084     /// @}
0085 } // namespace ranges
0086 
0087 #include <range/v3/detail/epilogue.hpp>
0088 
0089 #endif