Horizon
Loading...
Searching...
No Matches
copy.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2013-present
5//
6// Use, modification and distribution is subject to the
7// Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// Project home: https://github.com/ericniebler/range-v3
12//
13#ifndef RANGES_V3_ALGORITHM_COPY_HPP
14#define RANGES_V3_ALGORITHM_COPY_HPP
15
16#include <functional>
17#include <utility>
18
20
21#include <range/v3/algorithm/result_types.hpp>
29#include <range/v3/utility/static_const.hpp>
30
31#include <range/v3/detail/prologue.hpp>
32
33namespace ranges
34{
37 template<typename I, typename O>
38 using copy_result = detail::in_out_result<I, O>;
39
40 RANGES_HIDDEN_DETAIL(namespace _copy CPP_PP_LBRACE())
41 RANGES_FUNC_BEGIN(copy)
42
44 template(typename I, typename S, typename O)(
45 requires input_iterator<I> AND sentinel_for<S, I> AND
47 constexpr copy_result<I, O> RANGES_FUNC(copy)(I first, S last, O out) //
48 {
49 for(; first != last; ++first, ++out)
50 *out = *first;
51 return {first, out};
52 }
53
55 template(typename Rng, typename O)(
58 constexpr copy_result<borrowed_iterator_t<Rng>, O> //
59 RANGES_FUNC(copy)(Rng && rng, O out) //
60 {
61 return (*this)(begin(rng), end(rng), std::move(out));
62 }
63
64 RANGES_FUNC_END(copy)
65 RANGES_HIDDEN_DETAIL(CPP_PP_RBRACE())
66
67#ifndef RANGES_DOXYGEN_INVOKED
68 struct copy_fn
70 , _copy::copy_fn
71 {
72 using aux::copy_fn::operator();
73 using _copy::copy_fn::operator();
74 };
75 RANGES_INLINE_VARIABLE(copy_fn, copy)
76#endif
77
78 namespace cpp20
79 {
80 using ranges::copy_result;
81 using ranges::RANGES_HIDDEN_DETAIL(_copy::) copy;
82 } // namespace cpp20
83
85} // namespace ranges
86
87#include <range/v3/detail/epilogue.hpp>
88
89#endif
The indirectly_copyable concept.
The input_iterator concept.
The input_range concept.
The sentinel_for concept.
The weakly_incrementable concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
Definition copy.hpp:32
Definition copy.hpp:71