/// \file // Range v3 library // // Copyright Andrey Diduh 2019 // // 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_REMOVE_HPP #define RANGES_V3_VIEW_REMOVE_HPP #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-views /// @{ namespace views { struct remove_base_fn { private: template struct pred_ { Value value_; template(typename T)( requires equality_comparable_with) bool operator()(T && other) const { return static_cast(other) == value_; } }; public: template(typename Rng, typename Value)( requires move_constructible AND viewable_range AND input_range AND indirectly_comparable, Value const *, equal_to>) constexpr auto operator()(Rng && rng, Value value) const { return remove_if(static_cast(rng), pred_{std::move(value)}); } template(typename Rng, typename Value, typename Proj)( requires move_constructible AND viewable_range AND input_range AND indirectly_comparable, Value const *, equal_to, Proj>) constexpr auto operator()(Rng && rng, Value value, Proj proj) const { return remove_if(static_cast(rng), pred_{std::move(value)}, std::move(proj)); } }; struct remove_bind_fn { template constexpr auto operator()(Value value) const // TODO: underconstrained { return make_view_closure(bind_back(remove_base_fn{}, std::move(value))); } template(typename Value, typename Proj)( requires (!range)) // TODO: underconstrained constexpr auto operator()(Value && value, Proj proj) const { return make_view_closure(bind_back( remove_base_fn{}, static_cast(value), std::move(proj))); } }; struct RANGES_EMPTY_BASES remove_fn : remove_base_fn, remove_bind_fn { using remove_base_fn::operator(); using remove_bind_fn::operator(); }; /// \relates remove_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(remove_fn, remove) } // namespace views /// @} } // namespace ranges #include #endif // RANGES_V3_VIEW_REMOVE_HPP