From a8bec66b05eece7b8a39102fb1b0ba8f778eb9fe Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 19 Feb 2015 13:45:07 +0100 Subject: Reimplemented `Find` in terms of `ListIndex` * `ListIndex` already implements the necessary partial template specializations for finding elements matching a predicate * reimplemented `Cond` using `detail::find_variadic` as `Find` depends on `Apply` which in turn depends on `Cond` ** it is useful if core functionality such as the branched conditional `Cond` do not require higher order functionality such as `Find` *** otherwise one can not use core functionality in the implementation of higher order functionality * introduced `utility::predicate_guard` helper template ** checks a given value using a predicate and only forwards the value to the guarded function if this check is successful ** if check is unsuccessful it returns a surrogate value simmilar to `utility::predicate_assurance` --- src/utility/predicate.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/utility/predicate.h') diff --git a/src/utility/predicate.h b/src/utility/predicate.h index f06fcee..e84b18f 100644 --- a/src/utility/predicate.h +++ b/src/utility/predicate.h @@ -21,6 +21,28 @@ struct predicate_assurance { >; }; +template < + template class Function, + typename... Arguments +> +struct defer_eval { + typedef Function type; +}; + +template < + template class Predicate, + template class Charge, + typename Surrogate +> +struct predicate_guard { + template + using check = Eval>, + defer_eval, + Surrogate + >>; +}; + template class Predicate> struct predicate_negator { template -- cgit v1.2.3