/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under 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) =============================================================================*/ #ifndef SPROUT_RANGE_ADAPTOR_REMOVED_HPP #define SPROUT_RANGE_ADAPTOR_REMOVED_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace adaptors { // // removed_range // template class removed_range : public sprout::adaptors::detail::adapted_range_default< Range, sprout::filter_iterator< sprout::remove_filter::value_type>, typename sprout::container_traits::iterator > > { public: typedef sprout::adaptors::detail::adapted_range_default< Range, sprout::filter_iterator< sprout::remove_filter::value_type>, typename sprout::container_traits::iterator > > base_type; typedef typename base_type::range_type range_type; typedef typename base_type::iterator iterator; typedef typename base_type::value_type value_type; public: SPROUT_CONSTEXPR removed_range() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL removed_range(removed_range const&) = default; SPROUT_CONSTEXPR removed_range(range_type& range, value_type const& value) : base_type( iterator(sprout::begin(range), typename iterator::predicate_type(value)), iterator(sprout::end(range), typename iterator::predicate_type(value)) ) {} }; // // remove_holder // template class remove_holder { public: typedef T value_type; private: value_type value_; public: explicit SPROUT_CONSTEXPR remove_holder(value_type const& value) : value_(value) {} SPROUT_CONSTEXPR value_type const& value() const { return value_; } }; // // removed_forwarder // class removed_forwarder { public: template SPROUT_CONSTEXPR sprout::adaptors::remove_holder operator()(T const& value) const { return sprout::adaptors::remove_holder(value); } }; // // removed // namespace { SPROUT_STATIC_CONSTEXPR sprout::adaptors::removed_forwarder removed = {}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR sprout::adaptors::removed_range< typename std::remove_reference::type>::type > operator|(Range&& lhs, sprout::adaptors::remove_holder const& rhs) { return sprout::adaptors::removed_range< typename std::remove_reference::type>::type >( sprout::lvalue_forward(lhs), rhs.value() ); } } // 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_HPP