aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher/filter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/list/operation/higher/filter.h')
-rw-r--r--src/list/operation/higher/filter.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h
new file mode 100644
index 0000000..8788aed
--- /dev/null
+++ b/src/list/operation/higher/filter.h
@@ -0,0 +1,34 @@
+#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_
+#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_
+
+#include "fold.h"
+#include "conditional/if.h"
+
+namespace tav {
+
+template <
+ template<typename> class Function,
+ typename List
+>
+class Filter {
+ private:
+ template <
+ typename Current,
+ typename Previous
+ >
+ struct function_wrapper {
+ typedef If<
+ Function<Current>::type::value,
+ Cons<Current, Previous>,
+ Previous
+ > type;
+ };
+
+ public:
+ typedef typename Fold<function_wrapper, void, List>::type type;
+
+};
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_