From 0e4155540218d9a81255cb57534f08bdd86352e7 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 5 Dec 2015 01:31:23 +0100 Subject: [PATCH] extensible filter: add re-evaluation (test PASS) this is the tiny bit of operational functionality needed on top: whenever we're reconfiguring the predicate, we need to re-trigger the evaluation (and clear the cached value) n.b.: I've verified in debugger that the closure is allocated on the heap and the functors are passed by value --- src/lib/itertools.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/itertools.hpp b/src/lib/itertools.hpp index 967d77f87..47b91f797 100644 --- a/src/lib/itertools.hpp +++ b/src/lib/itertools.hpp @@ -366,6 +366,13 @@ namespace lib { typedef FilterCore _Filter; typedef typename _Filter::Val Val; + void + reEvaluate() + { + this->core_.cached_ = false; + this->hasData(); // re-evaluate head element + } + public: ExtensibleFilterIter() { } @@ -374,6 +381,7 @@ namespace lib { : FilterIter(src, initialFilterPredicate) { } + template ExtensibleFilterIter& andFilter (COND conjunctiveClause) @@ -385,6 +393,7 @@ namespace lib { return filter(val) and conjunctiveClause(val); }; + reEvaluate(); return *this; } };