Debian Codegraph @

3rd_party/range-v3/range/v3/action/transform.hpp

raw
1 /// \file
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
14 #ifndef RANGES_V3_ACTION_TRANSFORM_HPP
15 #define RANGES_V3_ACTION_TRANSFORM_HPP
16
17 #include <range/v3/range_fwd.hpp>
18
19 #include <range/v3/action/action.hpp>
20 #include <range/v3/algorithm/transform.hpp>
21 #include <range/v3/functional/bind_back.hpp>
22 #include <range/v3/functional/identity.hpp>
23 #include <range/v3/iterator/concepts.hpp>
24 #include <range/v3/iterator/traits.hpp>
25 #include <range/v3/utility/static_const.hpp>
26
27 #include <range/v3/detail/prologue.hpp>
28
29 namespace ranges
30 {
31 /// \addtogroup group-actions
32 /// @{
33 namespace actions
34 {
35 struct transform_fn
36 {
37 template(typename F, typename P = identity)(
38 requires (!range<F>))
39 constexpr auto operator()(F fun, P proj = P{}) const
40 {
41 return make_action_closure(
42 bind_back(transform_fn{}, std::move(fun), std::move(proj)));
43 }
44
45 template(typename Rng, typename F, typename P = identity)(
46 requires input_range<Rng> AND copy_constructible<F> AND
47 indirectly_writable<
48 iterator_t<Rng>,
49 indirect_result_t<F &, projected<iterator_t<Rng>, P>>>)
50 Rng operator()(Rng && rng, F fun, P proj = P{}) const
51 {
52 ranges::transform(rng, begin(rng), std::move(fun), std::move(proj));
53 return static_cast<Rng &&>(rng);
54 }
55 };
56
57 /// \relates actions::transform_fn
58 RANGES_INLINE_VARIABLE(transform_fn, transform)
59 } // namespace actions
60 /// @}
61 } // namespace ranges
62
63 #include <range/v3/detail/epilogue.hpp>
64
65 #endif