diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index 20e036cc1..25bff8f7c 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -549,8 +549,6 @@ namespace lib { iterNext(); // consume current head element if (not isnil(expanded)) expansions_.push (move(expanded)); - - SRC::expandChildren(); } /** diagnostics: current level of nested child expansion */ @@ -593,6 +591,25 @@ namespace lib { + template + class AutoExpander + : public SRC + { + static_assert(is_StateCore::value, "need wrapped state as predecessor in pipeline"); + + public: + /** pass through ctor */ + using SRC::SRC; + + void + iterNext() + { + SRC::expandChildren(); + } + }; + + + /** * @internal Decorator for TreeExplorer to map a transformation function on all results. * The transformation function is invoked on demand, and only once per item to be treated, @@ -968,8 +985,10 @@ namespace lib { auto expandAll() { - UNIMPLEMENTED ("automatically expand all elements"); - return *this; + using ResCore = iter_explorer::AutoExpander; + using ResIter = typename _DecoratorTraits::SrcIter; + + return TreeExplorer (ResCore {move(*this)}); } diff --git a/tests/library/iter-tree-explorer-test.cpp b/tests/library/iter-tree-explorer-test.cpp index 1ab5ef475..96597c831 100644 --- a/tests/library/iter-tree-explorer-test.cpp +++ b/tests/library/iter-tree-explorer-test.cpp @@ -807,12 +807,13 @@ namespace test{ void verify_depthFirstExploration() { - cout << materialise( + CHECK (materialise( treeExplore(CountDown{4}) .expand([](uint j){ return CountDown{j-1}; }) .expandAll() .transform([](int i){ return i*10; }) - ) < + + + - - + + + + + @@ -6768,8 +6774,8 @@ - - + +