DockAccess: solution how to bind partial application into generic lambda

...as it turned out, the result type was the problem: the lambda we provide
typically does not yield an Allocator, but only its baseclass function<UICoord(UICoord)>

solution: make Allocator a typedef, we don't expect any further functionality
This commit is contained in:
Fischlurch 2018-01-13 00:20:01 +01:00
parent 5dea8eea1f
commit 90a5d76fc9
2 changed files with 14 additions and 16 deletions

View file

@ -157,11 +157,7 @@ namespace interact {
* in creation or allocation of the view. The result of this invocation are the UI coordinates
* of an existing or newly created view.
*/
class Allocator
: public std::function<UICoord(UICoord)>
{
};
using Allocator = std::function<UICoord(UICoord)>;
/**
@ -202,8 +198,8 @@ namespace interact {
// typedef Tuple<ArgTypeSeq> ArgTuple;
// ArgTuple val(arg);
// return PApply<SIG,ArgTypeSeq>::bindBack (f, val);
/////////////////////////////////////////////////TODO looks like we need to *instantiate* the generic lambda before being able to bind it into a function
return [=](auto&&... args)
return [=](auto&&... args) -> Allocator
{
ArgTuple params {forward<decltype(args)> (args)...};
return PApply<FUN const&,FurtherArgs>::bindBack (fun, params);
@ -213,10 +209,8 @@ namespace interact {
public:
template<class FUN>
AllocSpec(FUN fun)
// : std::function<Allocator(ARGS&&...)> (buildPartialApplicator (forward<FUN> (fun)))
{
UNIMPLEMENTED ("generate an allocator builder functor by partial function application");
}
: std::function<Allocator(ARGS&&...)> (buildPartialApplicator (forward<FUN> (fun)))
{ }
};
}}// namespace gui::interact

View file

@ -9157,10 +9157,10 @@
<node CREATED="1515726268721" ID="ID_243053845" MODIFIED="1515726329213" TEXT="welches intern PApply aufruft"/>
</node>
<node CREATED="1515732350136" ID="ID_1294398139" MODIFIED="1515732355403" TEXT="technisch....">
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1515732356319" ID="ID_1071937152" MODIFIED="1515732381516" TEXT="Problem generisches Lambda">
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1515732356319" ID="ID_1071937152" MODIFIED="1515798985447" TEXT="Problem: generisches Lambda in std::function binden">
<icon BUILTIN="broken-line"/>
</node>
<node CREATED="1515732383331" ID="ID_1688687565" MODIFIED="1515732413862">
<node CREATED="1515732383331" ID="ID_1688687565" MODIFIED="1515797049652">
<richcontent TYPE="NODE"><html>
<head>
@ -9172,11 +9172,15 @@
</body>
</html>
</richcontent>
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1515797030493" ID="ID_973074141" MODIFIED="1515799063868" TEXT="Nein: es ist wohl ehr der R&#xfc;ckgabetyp">
<icon BUILTIN="button_ok"/>
<node CREATED="1515798991747" ID="ID_1053457138" MODIFIED="1515799030345" TEXT="Allocator erbt nur von function"/>
<node CREATED="1515799031197" ID="ID_516020279" MODIFIED="1515799045183" TEXT="Lambda liefert aber nur UICoord(UICoord)"/>
<node CREATED="1515799046027" ID="ID_1437287913" MODIFIED="1515799056910" TEXT="L&#xf6;sung: Allocator als reine Typedef">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1515732415503" ID="ID_1684331001" MODIFIED="1515732424394" TEXT="...bevor wir es in std::function binden k&#xf6;nnen"/>
<node CREATED="1515732427637" ID="ID_1533625561" MODIFIED="1515732445688" TEXT="Alternativ: old-style Binder konstruieren....?">
<icon BUILTIN="idea"/>
</node>
</node>
</node>