/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_VIEW_DROP_WHILE_HPP #define RANGES_V3_VIEW_DROP_WHILE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-views /// @{ template struct drop_while_view : view_interface, is_finite::value ? finite : unknown> { private: Rng rng_; RANGES_NO_UNIQUE_ADDRESS semiregular_box_t pred_; detail::non_propagating_cache> begin_; iterator_t get_begin_() { if(!begin_) begin_ = find_if_not(rng_, std::ref(pred_)); return *begin_; } public: drop_while_view() = default; drop_while_view(Rng rng, Pred pred) : rng_(std::move(rng)) , pred_(std::move(pred)) {} iterator_t begin() { return get_begin_(); } sentinel_t end() { return ranges::end(rng_); } Rng base() const { return rng_; } }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 CPP_template(typename Rng, typename Fun)(requires copy_constructible) drop_while_view(Rng &&, Fun) ->drop_while_view, Fun>; #endif namespace views { struct drop_while_fn { private: friend view_access; template static constexpr auto bind(drop_while_fn drop_while, Pred pred) { return make_pipeable(bind_back(drop_while, std::move(pred))); } template static constexpr auto bind(drop_while_fn drop_while, Pred pred, Proj proj) { return make_pipeable( bind_back(drop_while, std::move(pred), std::move(proj))); } public: template auto operator()(Rng && rng, Pred pred) const -> CPP_ret(drop_while_view, Pred>)( // requires viewable_range && input_range && indirect_unary_predicate>) { return {all(static_cast(rng)), std::move(pred)}; } template auto operator()(Rng && rng, Pred pred, Proj proj) const -> CPP_ret(drop_while_view, composed>)( // requires viewable_range && input_range && indirect_unary_predicate, iterator_t>) { return {all(static_cast(rng)), compose(std::move(pred), std::move(proj))}; } }; /// \relates drop_while_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(view, drop_while) } // namespace views namespace cpp20 { namespace views { using ranges::views::drop_while; } CPP_template(typename Rng, typename Pred)( // requires viewable_range && input_range && indirect_unary_predicate>) // using drop_while_view = ranges::drop_while_view; } // namespace cpp20 /// @} } // namespace ranges #include RANGES_SATISFY_BOOST_RANGE(::ranges::drop_while_view) #endif