Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:42

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 
0014 #ifndef RANGES_V3_ACTION_TRANSFORM_HPP
0015 #define RANGES_V3_ACTION_TRANSFORM_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/action/action.hpp>
0020 #include <range/v3/algorithm/transform.hpp>
0021 #include <range/v3/functional/bind_back.hpp>
0022 #include <range/v3/functional/identity.hpp>
0023 #include <range/v3/iterator/concepts.hpp>
0024 #include <range/v3/iterator/traits.hpp>
0025 #include <range/v3/utility/static_const.hpp>
0026 
0027 #include <range/v3/detail/prologue.hpp>
0028 
0029 namespace ranges
0030 {
0031     /// \addtogroup group-actions
0032     /// @{
0033     namespace actions
0034     {
0035         struct transform_fn
0036         {
0037             template(typename F, typename P = identity)(
0038                 requires (!range<F>))
0039             constexpr auto operator()(F fun, P proj = P{}) const
0040             {
0041                 return make_action_closure(
0042                     bind_back(transform_fn{}, std::move(fun), std::move(proj)));
0043             }
0044 
0045             template(typename Rng, typename F, typename P = identity)(
0046                 requires input_range<Rng> AND copy_constructible<F> AND
0047                     indirectly_writable<
0048                         iterator_t<Rng>,
0049                         indirect_result_t<F &, projected<iterator_t<Rng>, P>>>)
0050             Rng operator()(Rng && rng, F fun, P proj = P{}) const
0051             {
0052                 ranges::transform(rng, begin(rng), std::move(fun), std::move(proj));
0053                 return static_cast<Rng &&>(rng);
0054             }
0055         };
0056 
0057         /// \relates actions::transform_fn
0058         RANGES_INLINE_VARIABLE(transform_fn, transform)
0059     } // namespace actions
0060     /// @}
0061 } // namespace ranges
0062 
0063 #include <range/v3/detail/epilogue.hpp>
0064 
0065 #endif