diff --git a/src/lib/meta/function-closure.hpp b/src/lib/meta/function-closure.hpp index ad8f35b0d..05d95c9ad 100644 --- a/src/lib/meta/function-closure.hpp +++ b/src/lib/meta/function-closure.hpp @@ -412,6 +412,20 @@ namespace func{ }; + template> + auto + bindArgTuple (FUN&& fun, TUP&& tuple) + { + return std::apply ([functor = forward(fun)] + (auto&&... args) + { + return std::bind (move(functor) + ,forward (args) ...); + } + ,std::forward (tuple)); + } + + /** * Closing a function over its arguments. @@ -429,11 +443,11 @@ namespace func{ function closure_; public: - FunctionClosure (SIG& f, Tuple& arg) - : closure_(TupleApplicator(arg).bind(f)) + FunctionClosure (SIG& f, Tuple& args) + : closure_{bindArgTuple (f, args)} { } - FunctionClosure (function const& f, Tuple& arg) - : closure_(TupleApplicator(arg).bind(f)) + FunctionClosure (function const& f, Tuple& args) + : closure_{bindArgTuple (f, args)} { } Ret operator() () { return closure_(); } @@ -535,17 +549,18 @@ namespace func{ * @param arg value tuple, used to close function arguments starting from left * @return new function object, holding copies of the values and using them at the * closed arguments; on invocation, only the remaining arguments need to be supplied. - * @note BuildL, and consequently TupleApplicator _must take the arguments by-value._ Any attempt + * @note BuildL, and consequently std::bind _must take the arguments by-value._ Any attempt * towards »perfect-forwarding« would be potentially fragile and not worth the effort, * since the optimiser sees the operation as a whole. * @todo 2/2025 However, the LeftReplacedArgs _could_ then possibly moved into the bind function, * as could the functor, once we replace the Apply-template by STDLIB features. + * @todo 5/2025 seems indeed we could perfect-forward everything into the binder object. */ static LeftReducedFunc bindFront (SIG const& f, Tuple arg) { LeftReplacedArgs params {BuildL(std::move(arg))}; - return func::Apply::template bind (f, params); + return bindArgTuple (f, params); } /** do a partial function application, closing the last arguments
@@ -560,7 +575,7 @@ namespace func{ bindBack (SIG const& f, Tuple arg) { RightReplacedArgs params {BuildR(std::move(arg))}; - return func::Apply::template bind (f, params); + return bindArgTuple (f, params); } }; @@ -611,6 +626,7 @@ namespace func{ { Tuple params {BuildPreparedArgs{std::make_tuple (val)}}; return func::Apply::template bind (f, params); +// return bindArgTuple (f, params); ///////////////////////////////////////////////////////OOO does not compile when pos > length of ArgList } }; @@ -622,18 +638,11 @@ namespace func{ using util::unConst; - template - struct _Sig - { - using Type = typename BuildFunType::Sig; - using Applicator = TupleApplicator; - }; - template struct _Clo { using Ret = typename _Fun::Ret; - using Signature = typename _Sig::Type; + using Signature = typename BuildFunType::Sig; using Type = FunctionClosure; }; diff --git a/src/stage/interact/view-spec-dsl.hpp b/src/stage/interact/view-spec-dsl.hpp index de7eb0c0b..becf03a12 100644 --- a/src/stage/interact/view-spec-dsl.hpp +++ b/src/stage/interact/view-spec-dsl.hpp @@ -208,7 +208,6 @@ namespace interact { using lib::meta::Split; using lib::meta::Tuple; using lib::meta::TySeq; - using lib::meta::func::_Sig; using lib::meta::func::PApply; typedef typename _Fun::Ret Ret; diff --git a/tests/library/meta/function-closure-test.cpp b/tests/library/meta/function-closure-test.cpp index ae452535f..a7939df1b 100644 --- a/tests/library/meta/function-closure-test.cpp +++ b/tests/library/meta/function-closure-test.cpp @@ -84,6 +84,7 @@ namespace test { using func::Apply; using func::TupleApplicator; + using func::bindArgTuple; using func::FunctionClosure; using func::closure; @@ -208,6 +209,10 @@ namespace test { Tuple> tup1 (11); Tuple> tup2 (11,12); Tuple> tup3 (11,12,13); + DUMPVAL (tup0); + DUMPVAL (tup1); + DUMPVAL (tup2); + DUMPVAL (tup3); typedef function BoundFun; @@ -221,10 +226,10 @@ namespace test { CHECK (11+12 == functor2() ); CHECK (11+12+13 == functor3() ); - functor0 = TupleApplicator (tup0).bind (fun0); - functor1 = TupleApplicator (tup1).bind (fun1); - functor2 = TupleApplicator (tup2).bind (fun2); - functor3 = TupleApplicator (tup3).bind (fun3); + functor0 = bindArgTuple (fun0, tup0); + functor1 = bindArgTuple (fun1, tup1); + functor2 = bindArgTuple (fun2, tup2); + functor3 = bindArgTuple (fun3, tup3); CHECK (-1 == functor0() ); CHECK (11 == functor1() ); @@ -258,10 +263,10 @@ namespace test { CHECK (11+12 == functor2() ); CHECK (11+12+13 == functor3() ); - functor0 = TupleApplicator (tup0).bind (unbound_functor0); - functor1 = TupleApplicator (tup1).bind (unbound_functor1); - functor2 = TupleApplicator (tup2).bind (unbound_functor2); - functor3 = TupleApplicator (tup3).bind (unbound_functor3); + functor0 = bindArgTuple (unbound_functor0, tup0); + functor1 = bindArgTuple (unbound_functor1, tup1); + functor2 = bindArgTuple (unbound_functor2, tup2); + functor3 = bindArgTuple (unbound_functor3, tup3); CHECK (-1 == functor0() ); CHECK (11 == functor1() ); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7ef93d4f5..49d456c92 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -164397,6 +164397,137 @@ Since then others have made contributions, see the log for the history. + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ da es auf std::get<i> mit frest verdrahtetem Index aufsetzt +

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

+ d.h.: für die Back-Berchnung +

+

+ wird die Länge der Overlay-Liste +

+

+ nicht richtig gerechnet +

+

+ » off by one « +

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