From 23c9da7c62c280609ea6543d57ed3295e3a0c25c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 9 May 2019 23:40:47 +0200 Subject: [PATCH] Library: solve the dilemma by inheriting from VerbToken ...which, in the end, can even be considered the more logical design choice, since the "verb visitor" is a more elaborated and sophisiticated Verb-Token, adding the special twist of embedded storage for variable function arguments --- src/lib/verb-token.hpp | 2 +- src/lib/verb-visitor.hpp | 7 ++- tests/library/verb-visitor-dispatch-test.cpp | 2 +- wiki/thinkPad.ichthyo.mm | 61 ++++++++++++++++---- 4 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/lib/verb-token.hpp b/src/lib/verb-token.hpp index 532bb0dab..cf0594a59 100644 --- a/src/lib/verb-token.hpp +++ b/src/lib/verb-token.hpp @@ -83,7 +83,7 @@ namespace lib { public: typedef RET (REC::*Handler) (ARGS...); - private: + protected: Handler handler_; Literal token_; diff --git a/src/lib/verb-visitor.hpp b/src/lib/verb-visitor.hpp index d556080ac..29f1484d4 100644 --- a/src/lib/verb-visitor.hpp +++ b/src/lib/verb-visitor.hpp @@ -87,6 +87,7 @@ namespace lib { template struct Holder : VerbInvoker + , VerbToken { using Verb = VerbToken; using Args = std::tuple; @@ -94,11 +95,10 @@ namespace lib { /** meta-sequence to pick argument values from the storage tuple */ using SequenceIterator = typename meta::BuildIdxIter::Ascending; - Verb verb_; Args args_; Holder (typename Verb::Handler handlerRef, Literal verbID, ARGS&&... args) - : verb_{handlerRef, verbID} + : Verb{handlerRef, verbID} , args_{std::forward (args)...} { } @@ -108,11 +108,12 @@ namespace lib { return invokeVerb (receiver, SequenceIterator()); } + private: template RET invokeVerb (REC& receiver, meta::IndexSeq) { //////////////////////////////////////////TICKET #1006 | TICKET #1184 why do we need std::forward here? the target is a "perfect forwarding" function, which should be able to receive a LValue reference to the tuple element just fine... - return verb_.applyTo (receiver, std::get (std::forward(args_))...); + return (receiver.*Verb::handler_)(std::get (args_)...); } }; diff --git a/tests/library/verb-visitor-dispatch-test.cpp b/tests/library/verb-visitor-dispatch-test.cpp index bfa493334..a3f6d0480 100644 --- a/tests/library/verb-visitor-dispatch-test.cpp +++ b/tests/library/verb-visitor-dispatch-test.cpp @@ -174,8 +174,8 @@ namespace test{ TokenSeq build_and_copy_tokens () { - Token bigWoof(&Receiver::woof, "woof", true, 2u); Token littleWoof(&Receiver::woof, "woof", false, 3u); + Token bigWoof(&Receiver::woof, "woof", true, 2u); Token quack(&Receiver::honk, "honk", string{"quaack"}); Token honk(&Receiver::honk, "honk", string{"Hoonk"}); Token moo(&Receiver::moo, "moo", Trackr(3)); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 74c0bd02e..0da664c7b 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -19733,7 +19733,8 @@ - + + @@ -19773,13 +19774,19 @@ + + + + + - - + + + @@ -19789,8 +19796,8 @@ - - + + @@ -19855,10 +19862,11 @@ - - + + - + + @@ -19888,20 +19896,51 @@ - + + + + + + + + + + +

+ steht in keinem Verhältnis zum Zweck +

+ + +
+
+ + + +
- - + + + + + + + + + + + + +