aboutsummaryrefslogtreecommitdiff
path: root/src/list
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-20 17:06:20 +0100
committerAdrian Kummerlaender2015-01-20 17:06:20 +0100
commit5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6 (patch)
tree4ddfb07f8ee8feba27ed82996c7f81c0aad8adca /src/list
parentb5fc92b5377e3effe4410348f4199316b88fba7f (diff)
downloadTypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar.gz
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar.bz2
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar.lz
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar.xz
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.tar.zst
TypeAsValue-5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6.zip
Implemented higher order list queries `All` and `Any`
* in terms of `Fold` and `Map`, not the most efficient but reasonably concise * added appropriate test cases
Diffstat (limited to 'src/list')
-rw-r--r--src/list/operation/higher/query.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/list/operation/higher/query.h b/src/list/operation/higher/query.h
new file mode 100644
index 0000000..56bb203
--- /dev/null
+++ b/src/list/operation/higher/query.h
@@ -0,0 +1,30 @@
+#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_
+#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_
+
+#include "operation/logic.h"
+
+namespace tav {
+
+template <
+ template<typename> class Function,
+ typename List
+>
+using Any = Fold<
+ Or,
+ Boolean<false>,
+ typename Map<Function, List>::type
+>;
+
+template <
+ template<typename> class Function,
+ typename List
+>
+using All = Fold<
+ And,
+ Boolean<true>,
+ typename Map<Function, List>::type
+>;
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_