From 5f2fdb01bdb9892cb8cf5bf1b1787db36587e1d6 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 20 Jan 2015 17:06:20 +0100 Subject: 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 --- src/list/operation/higher/query.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/list/operation/higher/query.h (limited to 'src/list/operation/higher/query.h') 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 class Function, + typename List +> +using Any = Fold< + Or, + Boolean, + typename Map::type +>; + +template < + template class Function, + typename List +> +using All = Fold< + And, + Boolean, + typename Map::type +>; + +} + +#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_ -- cgit v1.2.3