diff --git a/research/try.cpp b/research/try.cpp index 21e904649..e108c4e0d 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -244,6 +244,12 @@ applyTuple (FUN& fun) } }; +using lib::meta::Yes_t; +using lib::meta::No_t; + +META_DETECT_FUNCTION(void, cloneInto, (void*) const); +META_DETECT_FUNCTION_NAME(cloneInto); + int main (int, char**) @@ -275,6 +281,19 @@ main (int, char**) // recy.grrrn (std::get<0>(trp), Trackr(5)); holyh.applyTo (recy); + cout << "---Types---"<; + using CloneI = lib::polyvalue::CloneValueSupport; + SHOW_TYPE(BussI); + SHOW_EXPR (lib::polyvalue::exposes_CloneFunction::value) + SHOW_EXPR (HasFunSig_cloneInto::value) + SHOW_EXPR (HasFunSig_cloneInto::value) + SHOW_EXPR (HasFunName_cloneInto::value) + SHOW_EXPR (HasFunName_cloneInto::value) + using BussP = decltype(&BussI::cloneInto); + SHOW_TYPE(BussP) + + cout << "\n.gulp.\n"; return 0; } diff --git a/src/lib/polymorphic-value.hpp b/src/lib/polymorphic-value.hpp index 1d96edac6..2bbfc609a 100644 --- a/src/lib/polymorphic-value.hpp +++ b/src/lib/polymorphic-value.hpp @@ -68,7 +68,7 @@ ** Moreover, the PolymorphicValue container provides static builder functions, ** allowing to place a concrete instance of a subclass into the content buffer. ** After construction, the actual type of this instance will be forgotten - ** (``type erasure''), but because of the embedded vtable, on access the + ** (``type erasure''), but because of the embedded vtable, on access, the ** proper implementation functions will be invoked. ** ** Expanding on that pattern, the copying and cloning operations of the whole @@ -230,11 +230,11 @@ namespace lib { class exposes_CloneFunction { - META_DETECT_FUNCTION(void, cloneInto, (void*) const); + META_DETECT_FUNCTION_NAME(cloneInto); public: - enum{ value = HasFunSig_cloneInto::value - }; + enum{ value = HasFunName_cloneInto::value + }; // warning: match on the function name only }; /** @@ -373,7 +373,7 @@ namespace lib { > class PolymorphicValue { - + public: typedef polyvalue::Trait _Traits; typedef typename _Traits::CopyAPI _CopyHandlingAdapter; typedef typename _Traits::Assignment _AssignmentPolicy; /////////////////TICKET #1197 : confusingly indirect decision logic diff --git a/src/lib/verb-visitor.hpp b/src/lib/verb-visitor.hpp index 29f1484d4..181811f5c 100644 --- a/src/lib/verb-visitor.hpp +++ b/src/lib/verb-visitor.hpp @@ -72,9 +72,11 @@ namespace lib { } } + using EmptyBasE = struct { }; + template struct VerbInvoker - : polyvalue::CloneValueSupport // mark and mix-in virtual copy construction support + : polyvalue::CloneValueSupport // mark and mix-in virtual copy construction support { virtual ~VerbInvoker() { } diff --git a/tests/library/verb-visitor-dispatch-test.cpp b/tests/library/verb-visitor-dispatch-test.cpp index a3f6d0480..29deb3001 100644 --- a/tests/library/verb-visitor-dispatch-test.cpp +++ b/tests/library/verb-visitor-dispatch-test.cpp @@ -130,6 +130,10 @@ namespace test{ +#define SHOW_TYPE(_TY_) \ + cout << "typeof( " << STRINGIFY(_TY_) << " )= " << lib::meta::typeStr<_TY_>() < - - + + @@ -19986,15 +19986,136 @@ - + + + + + + +

+ ...denn diese Duck-Detector-Metafunktion bildet den Typ eines Member-Pointers, +

+

+ und dieser Typ enthält explizit den statischen Namen der Klasse, welche die gewünschte Methode trägt. +

+

+ Und wenn man eine Methode bloß erbt, dann existiert diese Methode, statisch, nur auf der Basisklasse. +

+

+ Also ist das sogar das korrekte Verhalten. +

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

+ d.h. wenn zufällig das Interface auch eine Methode CloneInto() enthält, aber mit einer unpassenden Signatur +

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

+ weil ich dann explizit ein bestimmtes Basis-Interface verlangen werde, +

+

+ nämlich VirtualCopySupport<IFA> +

+

+ +

+

+ das ist auch gut so, zu viel Flexibilität schadet (besonders, wenn man sie dann gar nicht unterstützt) +

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

+ weil nämlich der Trait, für den optimalen Fall, ebenfalls die EmptyBase verwendet, um den Mix-In zu deaktivieren. +

+

+ Leider haben wir dann zweimal die gleiche Basisklasse in beiden Zweigen der multiple inheritance... +

+ + +
+
+ + + + + + +

+ nämlich immer dann, wenn man tatsächlich den CopySupport oder CloneSupport als Basis des Interfaces verwendet... +

+

+ (was ich bisher in der Praxis so noch nie gemacht habe) +

+ + +
+
+ + + + + + +

+ ...was sich dann in einer Static-Assertion-Failure äußert. +

+

+ hab das ganz explizit ausgeknobelt, es fehlt hier genau dieser eine zusätzliche "Slot" +

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