From 5d4f1015aa0fca66f8d8a0f398aabe9cfd380ad2 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 8 Sep 2018 23:32:32 +0200 Subject: [PATCH] TreeExplorer: consider refactoring of the functor adaptatiion mechanism ...and in preparation start with some renamings... The overall goal is to simplify the type signatures and thereby to make the generates pipelines more assignment compatible. The debugging experience form the last days indicated that the current design is not maintainable on the long run. Both the template instantiation chains and the call stacks are way to complicated and hard to understand and diagnose --- src/lib/iter-chain-search.hpp | 2 +- src/lib/iter-tree-explorer.hpp | 26 +++---- wiki/thinkPad.ichthyo.mm | 131 +++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 14 deletions(-) diff --git a/src/lib/iter-chain-search.hpp b/src/lib/iter-chain-search.hpp index 30d0779d5..4065cccd2 100644 --- a/src/lib/iter-chain-search.hpp +++ b/src/lib/iter-chain-search.hpp @@ -95,7 +95,7 @@ namespace iter { using Filter = decltype( buildSearchFilter(std::declval()).asIterator() ); using StepFunctor = std::function; - using StepWrapper = typename iter_explorer::_BoundFunctor::Functor; + using StepWrapper = typename iter_explorer::_FunTraits::Functor; // ^^^^^^^^^^^^^ used as argument on generic lambda using Pipeline = decltype( buildExplorer (std::declval(), std::declval()) ); diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index def63b5a2..46debeb6d 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -473,7 +473,7 @@ namespace lib { * @tparam SRC the source iterator type to apply when attempting to use a generic lambda as functor */ template - struct _BoundFunctor + struct _FunTraits { /** handle all regular "function-like" entities */ template @@ -500,7 +500,7 @@ namespace lib { /** adapt to a functor, which accesses the source iterator or embedded "state core" */ template - struct ArgAccessor + struct ArgAdapter { using FunArgType = remove_reference_t; static_assert (std::is_convertible::value, @@ -511,7 +511,7 @@ namespace lib { /** adapt to a functor, which accepts the value type of the source sequence ("monadic" usage pattern) */ template - struct ArgAccessor + struct ArgAdapter ,__not_>>>> // need to exclude the latter, since IterableDecorator { // often seems to accept IT::value_type (while in fact it doesn't) static auto build() { return [](auto& iter) { return *iter; }; } @@ -519,7 +519,7 @@ namespace lib { /** adapt to a functor collaborating with an IterSource based iterator pipeline */ template - struct ArgAccessor, typename IT::Source> + struct ArgAdapter, typename IT::Source> , is_base_of, remove_reference_t> > >> { @@ -538,7 +538,7 @@ namespace lib { Res operator() (ARG& arg) const { - auto accessArg = ArgAccessor::build(); + auto accessArg = ArgAdapter::build(); return boundFunction (accessArg (arg)); } @@ -593,7 +593,7 @@ namespace lib { * the source iterator wrapped by this decorator. * @remark since we allow a lot of leeway regarding the actual form and definition of the * _expansion functor_, there is a lot of minute technical details, mostly confined - * within the _BoundFunctor traits. + * within the _FunTraits traits. * @tparam SRC the wrapped source iterator, typically a TreeExplorer or nested decorator. * @tparam FUN the concrete type of the functor passed. Will be dissected to find the signature */ @@ -602,7 +602,7 @@ namespace lib { : public SRC { static_assert(can_IterForEach::value, "Lumiera Iterator required as source"); - using _Traits = _BoundFunctor; + using _Traits = _FunTraits; using ExpandFunctor = typename _Traits::Functor; using ResIter = typename _DecoratorTraits::SrcIter; @@ -782,7 +782,7 @@ namespace lib { : public SRC { static_assert(can_IterForEach::value, "Lumiera Iterator required as source"); - using _Traits = _BoundFunctor; + using _Traits = _FunTraits; using Res = typename _Traits::Res; using TransformFunctor = typename _Traits::Functor; @@ -869,7 +869,7 @@ namespace lib { : public SRC { static_assert(can_IterForEach::value, "Lumiera Iterator required as source"); - using _Traits = _BoundFunctor; + using _Traits = _FunTraits; using Res = typename _Traits::Res; static_assert(std::is_constructible::value, "Functor must be a predicate"); @@ -967,7 +967,7 @@ namespace lib { * be mixed and combined. To allow for this flexibility, we need to drive the _base class_ * with the most general form of a predicate functor, corresponding to `bool`. * Hereby we exploit the fact that the _wrapped filter,_ i.e. the Functor type constructed - * in the _BoundFunctor traits, boils down to that most generic form, adapting the arguments + * in the _FunTraits traits, boils down to that most generic form, adapting the arguments * automatically. Thus the initial functor, the one passed to the ctor of this class, is * effectively wrapped twice, so it can be combined later on with any other form and * shape of functor. And since everything is inline, the compiler will remove any @@ -975,9 +975,9 @@ namespace lib { */ template class MutableFilter - : public Filter::Functor> + : public Filter::Functor> { - using _Traits = _BoundFunctor; + using _Traits = _FunTraits; using FilterPredicate = typename _Traits::Functor; using _Base = Filter; @@ -1119,7 +1119,7 @@ namespace lib { void remouldFilter (COND&& additionalClause, COMB buildCombinedClause) { - using _ChainTraits = _BoundFunctor; + using _ChainTraits = _FunTraits; using Res = typename _ChainTraits::Res; static_assert(std::is_constructible::value, "Chained Functor must be a predicate"); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index fc46297ea..d66335796 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -25129,6 +25129,56 @@ + + + + + + +

+ ...ist mir nicht völlig klar, warum das bei einigen Includes auftritt, +

+

+ und bei anderen nicht. Beispiel +

+

+ +

+

+ In file included from src/lib/diff/test-mutation-target.hpp:55:0, +

+

+                  from tests/library/diff/diff-complex-application-test.cpp:35: +

+

+ src/lib/test/event-log.hpp:96:9: warning: 'lib::test::EventMatch' has a field 'lib::test::EventMatch::solution_' whose type uses the anonymous namespace [-Wsubobject-linkage] +

+

+    class EventMatch +

+

+          ^~~~~~~~~~ +

+

+ In file included from src/lib/diff/test-mutation-target.hpp:55:0, +

+

+                  from tests/library/diff/tree-mutator-binding-test.cpp:32: +

+

+ src/lib/test/event-log.hpp:96:9: warning: 'lib::test::EventMatch' has a field 'lib::test::EventMatch::solution_' whose type uses the anonymous namespace [-Wsubobject-linkage] +

+

+    class EventMatch +

+

+          ^~~~~~~~~~ +

+ + +
+ +
@@ -31176,6 +31226,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Konsequenz: brauche Template Funktions-Operator +

+ + +
+
+
+
+
+
+ + + + + + + + + + + + +

+ der Funktor für den Expander wird explizit als Sonderfall  aufgefaßt +

+ + +
+ + + + + +

+ das eigentliche Problem mit der bestehenden Lösung ist, +

+

+ daß ich ausgerechnet mit diesem Sonderfall angefangen habe. +

+

+ Daher ist jetzt das gesamte Design "anders herum" +

+ + +
+
+ +