mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-11-14 10:39:05 +00:00
9a593cbb81
support STL container: some algorithms
39 lines
1 KiB
C++
39 lines
1 KiB
C++
#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:
|
|
SPROUT_CONSTEXPR remove_if_filter(Predicate pred)
|
|
: 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
|