diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index a730f3833..c51d10d98 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -92,6 +92,7 @@ namespace lib { using std::move; using std::forward; using std::function; + using util::isnil; namespace iter_explorer { @@ -235,7 +236,6 @@ namespace lib { using meta::_Fun; using std::__and_; using std::__not_; - using std::is_constructible; using meta::can_IterForEach; using meta::can_STL_ForEach; @@ -287,37 +287,7 @@ namespace lib { }; - template - struct ArgAccessor - { - using FunArg = typename std::remove_reference< - typename _Fun::Args::List::Head>::type; - static_assert (std::is_convertible::value, - "the expansion functor must accept the source iterator or state core as parameter"); - - static auto accessor() { return [](ARG& arg) -> ARG& { return arg; }; } - }; - template - struct ArgAccessor::Args::List::Head>>> - { - static auto accessor() { return [](auto iter) { return *iter; }; } - }; - - template - struct ExpaFunc - { - function expandFun; - - template - auto - operator() (ARG& arg) - { - auto accessArg = ArgAccessor::accessor(); - - return expandFun (accessArg (arg)); - } - }; template struct _ExpansionTraits @@ -337,17 +307,43 @@ namespace lib { }; using Sig = typename FunDetector::Sig; + using Arg = typename _Fun::Args::List::Head; + using Res = typename _Fun::Ret; - using ExpandedChildren = typename _Fun::Ret; + using ResultIter = typename _TreeExplorerTraits::SrcIter; - using Core = typename _TreeExplorerTraits::SrcIter; - - static_assert (std::is_convertible::value, + static_assert (std::is_convertible::value, "the iterator from the expansion must yield compatible values"); -// using Arg = typename _Fun::Args::List::Head; + template + struct ArgAccessor + { + using FunArgType = typename std::remove_reference::type; + static_assert (std::is_convertible::value, + "the expansion functor must accept the source iterator or state core as parameter"); + + static auto build() { return [](ARG& arg) -> ARG& { return arg; }; } + }; - using Functor = ExpaFunc; + template + struct ArgAccessor>> + { + static auto build() { return [](auto iter) { return *iter; }; } + }; + + struct Functor + { + function expandFun; + + template + auto + operator() (ARG& arg) + { + auto accessArg = ArgAccessor::build(); + + return expandFun (accessArg (arg)); + } + }; }; }//(End) TreeExplorer traits @@ -361,12 +357,12 @@ namespace lib { : public SRC { using SrcIter = typename SRC::SrcIter; - using _Config = _ExpansionTraits; - using Core = typename _Config::Core; - using ExpandFunctor = typename _Config::Functor; + using _Traits = _ExpansionTraits; + using ResIter = typename _Traits::ResultIter; + using ExpandFunctor = typename _Traits::Functor; ExpandFunctor expandChildren_; - IterStack expansions_; + IterStack expansions_; public: Expander() =default; @@ -385,10 +381,10 @@ namespace lib { { REQUIRE (checkPoint(*this), "attempt to expand an empty explorer"); - Core expanded = 0 < depth()? expandChildren_(*expansions_) - : expandChildren_(*this); + ResIter expanded = 0 < depth()? expandChildren_(*expansions_) + : expandChildren_(*this); iterNext (*this); // consume current head element - if (expanded.isValid()) + if (not isnil(expanded)) expansions_.push (move(expanded)); return *this; @@ -443,8 +439,7 @@ namespace lib { * * @todo WIP -- preliminary draft as of 11/2017 */ - template + template class TreeExplorer : public SRC { @@ -488,6 +483,7 @@ namespace lib { return ExpandableExplorer{move(*this), forward(expandFunctor)}; } + private: }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 69fcb7789..509530f6e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -5348,6 +5348,16 @@ + + + + + + + + + + @@ -5374,7 +5384,8 @@ - + +