Back to home page

EIC code displayed by LXR

 
 

    


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

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_VIEW_MOVE_HPP
0015 #define RANGES_V3_VIEW_MOVE_HPP
0016 
0017 #include <type_traits>
0018 #include <utility>
0019 
0020 #include <range/v3/range_fwd.hpp>
0021 
0022 #include <range/v3/range/access.hpp>
0023 #include <range/v3/range/concepts.hpp>
0024 #include <range/v3/range/primitives.hpp>
0025 #include <range/v3/range/traits.hpp>
0026 #include <range/v3/utility/static_const.hpp>
0027 #include <range/v3/view/adaptor.hpp>
0028 #include <range/v3/view/all.hpp>
0029 #include <range/v3/view/view.hpp>
0030 
0031 #include <range/v3/detail/prologue.hpp>
0032 
0033 namespace ranges
0034 {
0035     /// \addtogroup group-views
0036     /// @{
0037     template<typename Rng>
0038     struct move_view : view_adaptor<move_view<Rng>, Rng>
0039     {
0040     private:
0041         friend range_access;
0042         template<bool Const>
0043         struct adaptor : adaptor_base
0044         {
0045             adaptor() = default;
0046             template(bool Other)(
0047                 requires Const AND CPP_NOT(Other)) //
0048             constexpr adaptor(adaptor<Other>)
0049             {}
0050             using CRng = meta::const_if_c<Const, Rng>;
0051             using value_type = range_value_t<Rng>;
0052             range_rvalue_reference_t<CRng> read(iterator_t<CRng> const & it) const
0053             {
0054                 return ranges::iter_move(it);
0055             }
0056             range_rvalue_reference_t<CRng> iter_move(iterator_t<CRng> const & it) const
0057             {
0058                 return ranges::iter_move(it);
0059             }
0060         };
0061         adaptor<simple_view<Rng>()> begin_adaptor()
0062         {
0063             return {};
0064         }
0065         adaptor<simple_view<Rng>()> end_adaptor()
0066         {
0067             return {};
0068         }
0069         CPP_member
0070         auto begin_adaptor() const //
0071             -> CPP_ret(adaptor<true>)(
0072                 requires input_range<Rng const>)
0073         {
0074             return {};
0075         }
0076         CPP_member
0077         auto end_adaptor() const //
0078             -> CPP_ret(adaptor<true>)(
0079                 requires input_range<Rng const>)
0080         {
0081             return {};
0082         }
0083 
0084     public:
0085         move_view() = default;
0086         explicit move_view(Rng rng)
0087           : move_view::view_adaptor{std::move(rng)}
0088         {}
0089         CPP_auto_member
0090         auto CPP_fun(size)()(const //
0091             requires sized_range<Rng const>)
0092         {
0093             return ranges::size(this->base());
0094         }
0095         CPP_auto_member
0096         auto CPP_fun(size)()(
0097             requires sized_range<Rng>)
0098         {
0099             return ranges::size(this->base());
0100         }
0101     };
0102 
0103     template<typename Rng>
0104     RANGES_INLINE_VAR constexpr bool enable_borrowed_range<move_view<Rng>> =
0105         enable_borrowed_range<Rng>;
0106 
0107 #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17
0108     template<typename Rng>
0109     move_view(Rng &&) //
0110         -> move_view<views::all_t<Rng>>;
0111 #endif
0112 
0113     namespace views
0114     {
0115         struct move_fn
0116         {
0117             template(typename Rng)(
0118                 requires viewable_range<Rng> AND input_range<Rng>)
0119             move_view<all_t<Rng>> operator()(Rng && rng) const
0120             {
0121                 return move_view<all_t<Rng>>{all(static_cast<Rng &&>(rng))};
0122             }
0123         };
0124 
0125         /// \relates move_fn
0126         /// \ingroup group-views
0127         RANGES_INLINE_VARIABLE(view_closure<move_fn>, move)
0128     } // namespace views
0129     /// @}
0130 } // namespace ranges
0131 
0132 #include <range/v3/detail/epilogue.hpp>
0133 #include <range/v3/detail/satisfy_boost_range.hpp>
0134 RANGES_SATISFY_BOOST_RANGE(::ranges::move_view)
0135 
0136 #endif