2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2011-2013 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)
|
|
|
|
=============================================================================*/
|
2013-01-19 23:53:20 +00:00
|
|
|
#ifndef SPROUT_ITERATOR_REMOVE_IF_ITERATOR_HPP
|
|
|
|
#define SPROUT_ITERATOR_REMOVE_IF_ITERATOR_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/filter_iterator.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// remove_if_filter
|
|
|
|
//
|
|
|
|
template<typename Predicate>
|
|
|
|
class remove_if_filter {
|
|
|
|
public:
|
|
|
|
typedef bool result_type;
|
|
|
|
private:
|
|
|
|
Predicate pred_;
|
|
|
|
public:
|
2013-01-26 14:51:43 +00:00
|
|
|
explicit SPROUT_CONSTEXPR remove_if_filter(Predicate pred)
|
2013-01-19 23:53:20 +00:00
|
|
|
: pred_(pred)
|
|
|
|
{}
|
|
|
|
template<typename U>
|
|
|
|
SPROUT_CONSTEXPR bool operator()(U const& value) const {
|
|
|
|
return !pred_(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// make_remove_if_iterator
|
|
|
|
//
|
|
|
|
template<typename Predicate, typename Iterator>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::filter_iterator<sprout::remove_if_filter<Predicate>, Iterator>
|
|
|
|
make_remove_if_iterator(Predicate pred, Iterator it, Iterator last = Iterator()) {
|
|
|
|
return sprout::filter_iterator<sprout::remove_if_filter<Predicate>, Iterator>(
|
|
|
|
sprout::remove_if_filter<Predicate>(pred), it, last
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // SPROUT_ITERATOR_REMOVE_IF_ITERATOR_HPP
|