GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
stream_filter.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_STREAM_FILTER_H
22 #define GRPPI_STREAM_FILTER_H
23 
24 #include "common/patterns.h"
25 
26 namespace grppi {
27 
46 template <typename Predicate>
47 auto keep(Predicate && predicate_op)
48 {
49  return filter_t<Predicate>{std::forward<Predicate>(predicate_op)};
50 }
51 
62 template <typename Predicate>
63 auto discard(Predicate && predicate_op)
64 {
65  return keep([&](auto val) { return !predicate_op(val); });
66 }
67 
73 }
74 
75 #endif
auto keep(Predicate &&predicate_op)
Invoke Filter pattern on a data stream that can be composed in other streaming patterns. This function keeps in the stream only those items that satisfy the predicate.
Definition: stream_filter.h:47
Definition: callable_traits.h:26
auto discard(Predicate &&predicate_op)
Invoke Filter pattern on a data stream that can be composed in other streaming patterns. This function discards from the stream those items that satisfy the predicate.
Definition: stream_filter.h:63
Representation of filter pattern. Represents a filter that can be used as a stage on a pipeline...
Definition: filter_pattern.h:33