/// \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_DELIMIT_HPP #define RANGES_V3_VIEW_DELIMIT_HPP #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-views /// @{ template struct delimit_view : view_adaptor, Rng, is_finite::value ? finite : unknown> { private: friend range_access; Val value_; struct sentinel_adaptor : adaptor_base { sentinel_adaptor() = default; sentinel_adaptor(Val value) : value_(std::move(value)) {} template bool empty(I const & it, S const & last) const { return it == last || *it == value_; } Val value_; }; sentinel_adaptor end_adaptor() const { return {value_}; } public: delimit_view() = default; constexpr delimit_view(Rng rng, Val value) : delimit_view::view_adaptor{std::move(rng)} , value_(std::move(value)) {} }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 CPP_template(typename Rng, typename Val)(requires copy_constructible) delimit_view(Rng &&, Val) ->delimit_view, Val>; #endif namespace views { struct delimit_impl_fn { private: friend view_access; template static constexpr auto bind(delimit_impl_fn delimit, Val value) { return make_pipeable(bind_back(delimit, std::move(value))); } public: template constexpr auto operator()(Rng && rng, Val value) const -> CPP_ret( delimit_view, Val>)( // requires viewable_range && input_range && semiregular && equality_comparable_with>) { return {all(static_cast(rng)), std::move(value)}; } }; struct delimit_fn : view { using view::operator(); template> constexpr auto operator()(I_ && begin_, Val value) const -> CPP_ret(delimit_view, Val>)( // requires(!range && convertible_to && input_iterator && semiregular && equality_comparable_with>)) { return {{static_cast(begin_), {}}, std::move(value)}; } }; /// \relates delimit_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(delimit_fn, delimit) } // namespace views /// @} } // namespace ranges #include RANGES_SATISFY_BOOST_RANGE(::ranges::delimit_view) #endif