diff --git a/src/lib/diff/tree-diff-mutator-binding.hpp b/src/lib/diff/tree-diff-mutator-binding.hpp index 7707f7070..e90dcb0f4 100644 --- a/src/lib/diff/tree-diff-mutator-binding.hpp +++ b/src/lib/diff/tree-diff-mutator-binding.hpp @@ -82,22 +82,77 @@ namespace diff{ /* ======= derive a TreeMutator binding for a given opaque data structure ======= */ + + using meta::enable_if; + using meta::Yes_t; + using meta::No_t; + using std::is_same; + using std::__not_; + using std::declval; + + /** + * helper to detect presence of a + * TreeMutator builder function + */ + template + class exposes_MutatorBuilder + { + + META_DETECT_FUNCTION (void, buildMutator, (TreeMutator::Handle)); + + public: + enum{ value = HasFunSig_buildMutator::value + }; + }; + + + + + template struct MutatorBinding { - ///////////////TODO - - operator DiffMutable& () - { - UNIMPLEMENTED ("how to build and pass the closure safely"); - } + static_assert (!sizeof(TAR), "MutatorBinding: Unable to access or build a TreeMutator for this target data."); }; template - DiffMutable& - mutatorBinding (TAR& subject) + struct MutatorBinding>> + { + using Ret = DiffMutable&; + }; + + template + struct MutatorBinding>> + { + class Wrapper + : public DiffMutable + { + TAR& subject_; + + /** implement the TreeMutator interface, + * by forwarding to a known implementation function + * on the wrapped target data type */ + virtual void + buildMutator (TreeMutator::Handle handle) + { + subject_.buildMutator (handle); + } + + public: + Wrapper(TAR& subj) + : subject_(subj) + { } + }; + + using Ret = Wrapper; + }; + + template + auto + mutatorBinding (TAR& subject) -> typename MutatorBinding::Ret { - UNIMPLEMENTED ("how to detect, create and pass a suitable mutator building closure"); + using Wrapper = typename MutatorBinding::Ret; + return Wrapper{subject}; } diff --git a/src/lib/polymorphic-value.hpp b/src/lib/polymorphic-value.hpp index 54d6297a6..b17ea5ca0 100644 --- a/src/lib/polymorphic-value.hpp +++ b/src/lib/polymorphic-value.hpp @@ -215,7 +215,7 @@ namespace lib { - /** + /** * helper to detect presence of a function * to support clone operations */ diff --git a/tests/library/diff/diff-virtualised-application-test.cpp b/tests/library/diff/diff-virtualised-application-test.cpp index 6fd0b2a49..bb99ee832 100644 --- a/tests/library/diff/diff-virtualised-application-test.cpp +++ b/tests/library/diff/diff-virtualised-application-test.cpp @@ -208,7 +208,7 @@ namespace test{ run (Arg) { Opaque subject; - DiffMutable& target = mutatorBinding (subject); + auto target = mutatorBinding (subject); DiffApplicator application(target); // // TODO verify results diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 593df658a..c13c32bcd 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1144,8 +1144,7 @@ Wichtigster solcher Fall ist die Bindung auf Objekt-Felder

- - + @@ -2885,8 +2884,7 @@ "nicht nutzen" : meint ignorieren und verwerfen der Information

- - +
@@ -3163,8 +3161,7 @@ thus always available

- - +
@@ -3232,8 +3229,7 @@ Somit könnten sofort Zuweisungen als Nächstes passieren

- - +
@@ -3287,8 +3283,7 @@ das heißt, es findet keine Verifikation statt

- - +
@@ -3369,8 +3364,7 @@ zumal das erhebliche Statefulness bewirkt

- - +
@@ -3415,8 +3409,7 @@ denn der Setter nimmt eine GenNode

- - +
@@ -3454,8 +3447,7 @@ injectNew tolerieren

- - + @@ -3467,8 +3459,7 @@ ....man könnte genausogut auch beim ersten Mal zuweisen

- -
+
@@ -3491,8 +3482,7 @@ - - + @@ -3551,8 +3541,7 @@ damit wir nicht in die ganzen Ungewissheiten der widening conversions laufen!

- - + @@ -3577,8 +3566,7 @@ d.h. der Attributwert hat Wertsemantik und wird einfach zugewiesen

- - + @@ -3590,8 +3578,7 @@ ...d.h. der Attributwert ist ein Objekt und damit ein nested Scope

- -
+
@@ -3606,8 +3593,7 @@ Problem: immutable values

- - + @@ -3634,8 +3620,7 @@ das alles passiert dann im Lambda

- - +
@@ -3650,8 +3635,7 @@ Dilemma: defaultable fields

- - + @@ -3680,8 +3664,7 @@ muß dies als INS geschehen, denn eine Zuweisung an nicht aufgeführtes Element ist verboten

- - +
@@ -3699,8 +3682,7 @@ zu erkennen, wenn wir fertig sind

- - +
@@ -3720,8 +3702,7 @@ Aber es ist kein optional field, d.h. wir haben keine Flag, die es als "defaulted" kennzeichnet

- - +
@@ -3738,8 +3719,7 @@ Lösung: alles immer explizit

- - +
@@ -3798,8 +3778,7 @@ Also dann besser klar und ehrlich!

- - + @@ -3828,8 +3807,7 @@ immer noch die Möglichkeit, die Attribute explizit als Sammlung darzustellen.

- - + @@ -3843,8 +3821,7 @@ auf die empty-Prüfung am Ende verzichten

- - + @@ -3866,8 +3843,7 @@ bevor ein anderes Verifikations-Prädikat angewendet wird.

- - + @@ -3937,8 +3913,7 @@ Das ist hier tatsächlich viel schlechter, als das bischen lineare Suche

- - +
@@ -3958,8 +3933,7 @@ für den ich damals gezwungen war, die GenNode zu erfinden :)

- - + @@ -4013,8 +3987,7 @@ gleiches Argument...

- - +
@@ -4029,8 +4002,7 @@ Dann kann man sich immer noch überlegen, ob man dann an dieser Stelle bereinigt

- -
+
@@ -4089,8 +4061,7 @@ Keine klare Linie

- - + @@ -4171,8 +4142,7 @@ - - + @@ -4191,8 +4161,7 @@ also repräsentiert als Rec<GenNode>

- - +
@@ -4244,12 +4213,13 @@ - - - + + + + - + @@ -4261,13 +4231,13 @@ - - - + + + - - - + + + @@ -4291,8 +4261,8 @@ - - + + @@ -4335,8 +4305,7 @@ auf Basis des neu geschaffenen TreeMutators

- -
+ @@ -4362,8 +4331,7 @@ - - + @@ -4407,6 +4375,71 @@ + + + + + + + + + + + + + + + + + + +

+ ....daß ein unbedarfter client diesen Trick übershieht +

+

+ und daher den Rückgabewert wegwirft. +

+

+ +

+

+ Argument: we soweit einsteigt, die Metaprogramming-Lösung zu nutzen, +

+

+ sollte auch intelligent genug sein, die API-Doc zu lesen. +

+

+ +

+

+ Standard == Interface DiffMutable implementieren +

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

+ Client soll direkt mutatorBinding bieten +

+ + +
+
+
+
+
@@ -4427,8 +4460,7 @@ TreeMutator-Binding muß opaque bleiben

- - +
@@ -4440,8 +4472,7 @@ Buffer-Größen-Management vorsehen

- -
+ @@ -4462,8 +4493,7 @@ - - +