aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher/filter.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-30 19:07:22 +0100
committerAdrian Kummerlaender2015-01-30 19:07:22 +0100
commite176dbe160eff01d172a11e7a191f756d4c87712 (patch)
tree4f1da0fd7421e4e17a5cc1cec73d09f66f3d095b /src/list/operation/higher/filter.h
parent5f98c3eb62f3085a69f8df36de663bb7c6107341 (diff)
downloadTypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar.gz
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar.bz2
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar.lz
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar.xz
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.tar.zst
TypeAsValue-e176dbe160eff01d172a11e7a191f756d4c87712.zip
Separated `Map` and `Filter`
* there is no reason to keep them in the same header
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_