#ifndef SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP #define SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace adaptors { // // removed_if_range // template class removed_if_range : public sprout::adaptors::detail::adapted_range_default< Range, sprout::filter_iterator< sprout::remove_if_filter, typename sprout::container_traits::iterator > > { public: typedef Predicate predicate_type; typedef sprout::adaptors::detail::adapted_range_default< Range, sprout::filter_iterator< sprout::remove_if_filter, typename sprout::container_traits::iterator > > base_type; typedef typename base_type::range_type range_type; typedef typename base_type::iterator iterator; public: removed_if_range() = default; removed_if_range(removed_if_range const&) = default; SPROUT_CONSTEXPR removed_if_range(range_type& range, Predicate pred) : base_type( iterator(sprout::begin(range), typename iterator::predicate_type(pred)), iterator(sprout::end(range), typename iterator::predicate_type(pred)) ) {} }; // // remove_if_holder // template class remove_if_holder { public: typedef Predicate predicate_type; private: Predicate pred_; public: explicit SPROUT_CONSTEXPR remove_if_holder(Predicate pred) : pred_(pred) {} SPROUT_CONSTEXPR Predicate const& predicate() const { return pred_; } }; // // removed_if_forwarder // class removed_if_forwarder { public: template SPROUT_CONSTEXPR sprout::adaptors::remove_if_holder operator()(Predicate pred) const { return sprout::adaptors::remove_if_holder(pred); } }; // // removed_if // namespace { SPROUT_STATIC_CONSTEXPR sprout::adaptors::removed_if_forwarder removed_if = {}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR sprout::adaptors::removed_if_range< Predicate, typename std::remove_reference::type>::type > operator|(Range&& lhs, sprout::adaptors::remove_if_holder const& rhs) { return sprout::adaptors::removed_if_range< Predicate, typename std::remove_reference::type>::type >( sprout::lvalue_forward(lhs), rhs.predicate() ); } } // namespace adaptors // // container_construct_traits // template struct container_construct_traits > : public sprout::container_construct_traits::base_type> {}; } // namespace sprout #endif // #ifndef SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP