#ifndef SPROUT_ITERATOR_REPLACE_ITERATOR_HPP #define SPROUT_ITERATOR_REPLACE_ITERATOR_HPP #include #include namespace sprout { // // replace_value_if // template class replace_value_if { public: typedef Predicate predicate_type; typedef T result_type; typedef T const& argument_type; private: Predicate pred_; T new_; public: SPROUT_CONSTEXPR replace_value_if(Predicate pred, T const& new_value) : pred_(pred) , new_(new_value) {} SPROUT_CONSTEXPR T operator()(T const& value) const { return pred_(value) ? new_ : value; } }; // // make_replace_if_iterator // template inline SPROUT_CONSTEXPR sprout::transform_iterator, Iterator> make_replace_if_iterator(Iterator it, Predicate pred, T const& new_value) { return sprout::transform_iterator, Iterator>( it, sprout::replace_value_if(pred, new_value) ); } } // namespace sprout #endif // #ifndef SPROUT_ITERATOR_REPLACE_ITERATOR_HPP