From 2ca3e95e9e6595b50f1fcdd3449c7b97292f13fb Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 11 Sep 2018 04:04:32 +0200 Subject: [PATCH] ChainSearch: allow for overconstrained search ...which just turns the pipeline into exhausted state, instead of raising an Assertion failure The point is, expandChildren() does not guard itself, since it _requires_ an non-empty iterator as precondition. Thus, any function downstream, which invokes expandChildren(), has to check and guard this call apropriately. In the concrete case at hand we just stop adding further constraints when the pipeline is already in exhausted state --- src/lib/iter-chain-search.hpp | 19 +++++++++++-------- src/lib/iter-tree-explorer.hpp | 3 +++ wiki/thinkPad.ichthyo.mm | 17 ++++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/lib/iter-chain-search.hpp b/src/lib/iter-chain-search.hpp index beeb69469..c662fb926 100644 --- a/src/lib/iter-chain-search.hpp +++ b/src/lib/iter-chain-search.hpp @@ -181,14 +181,17 @@ namespace iter { IterChainSearch&& > search (FUN&& configureSearchStep) { - Step nextStep{forward (configureSearchStep)}; - - if (_Base::isDisabled()) - this-> filter() = move (nextStep (*this)); // immediately apply first step - else // - stepChain_.emplace_back (move (nextStep)); // append all further steps into the chain... - // then establish invariant: - this->iterNext(); // expand to leaf and forward to first match + if (not this->empty()) + { + Step nextStep{forward (configureSearchStep)}; + + if (_Base::isDisabled()) + this-> filter() = move (nextStep (*this)); // immediately apply first step + else // + stepChain_.emplace_back (move (nextStep)); // append all further steps into the chain... + // then establish invariant: + this->iterNext(); // expand to leaf and forward to first match + } return move(*this); } diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index 650e161f1..8e73566a4 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -187,6 +187,7 @@ namespace lib { COR & _core() { return static_cast (*this); } COR const& _core() const { return static_cast (*this); } + protected: void __throw_if_empty() const { @@ -754,6 +755,7 @@ namespace lib { void iterNext() { + SRC::__throw_if_empty(); SRC::expandChildren(); } }; @@ -786,6 +788,7 @@ namespace lib { { if (shallExpand_) { + SRC::__throw_if_empty(); SRC::expandChildren(); shallExpand_ = false; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 886e792a8..7a982f05f 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -32106,8 +32106,6 @@ - - @@ -32120,17 +32118,22 @@ + + - - + + + + + + + + - - -