From 0cec3490fe62e9130af677089e0234de4f37b2fc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 3 Jul 2015 18:08:28 +0200 Subject: [PATCH] WIP: Forwarding ctor shadows standard copy operations (#963) unsuccssful attempt to come up with a generic remedy. Aborted this attempt and stashed it away as TICKET #963 --- src/lib/diff/gen-node.hpp | 44 +++++++++++++++++++++++++++------------ src/lib/variant.hpp | 7 +++++-- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index 09ad59421..2f6f08aa7 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -121,6 +121,33 @@ namespace diff{ using std::string; + namespace {//////TODO this is a prototype, to be factored out + + template + struct ShaddowCopyCtor + { + operator bool() const { return true; } + }; + + template + struct ShaddowCopyCtor + { + // no bool conversion -> substitution fails. + }; + template + struct ShaddowCopyCtor + { + // no bool conversion -> substitution fails. + }; + template + struct ShaddowCopyCtor + { + // no bool conversion -> substitution fails. + }; + + }//(End) copy shaddowing solution + + class GenNode; using Rec = Record; @@ -146,15 +173,11 @@ namespace diff{ { public: template - DataCap(X&& x) + DataCap(X&& x, bool = ShaddowCopyCtor()) : Variant(std::forward(x)) { } - DataCap(DataCap const& o) =default; - DataCap(DataCap&& o) =default; - DataCap(DataCap& o) - : DataCap((DataCap const&)o) - { } + ////////////////////////TICKET #963 Forwarding shadows copy operations -- generic solution?? }; @@ -183,8 +206,9 @@ namespace diff{ ID idi; DataCap data; + template - GenNode(X&& val) + GenNode(X&& val, bool = ShaddowCopyCtor()) : idi(&val, buildChildID()) , data(std::forward(val)) { } @@ -203,12 +227,6 @@ namespace diff{ : GenNode(string(text)) { } - GenNode(GenNode const& o) =default; - GenNode(GenNode&& o) =default; - GenNode(GenNode& o) - : GenNode((GenNode const&)o) - { } - // default copy assignable diff --git a/src/lib/variant.hpp b/src/lib/variant.hpp index 2ffb00143..6a6640e7b 100644 --- a/src/lib/variant.hpp +++ b/src/lib/variant.hpp @@ -142,12 +142,11 @@ namespace lib { = meta::InstantiateForEach; - /////TODO: - is it possible directly to forward the constructor invocation to the object within the buffer? Beware of unverifiable generic solutions! - }//(End) implementation helpers + /** * Typesafe union record. * A Variant element may carry an embedded value of any of the predefined types. @@ -160,6 +159,10 @@ namespace lib { * in question, but type mismatch will provoke an exception at runtime. * Generic access is possible using a visitor. * @warning not threadsafe + * @todo we need to define all copy operations explicitly, due to the + * templated one-arg ctor to wrap the actual values. + * There might be a generic solution for that ////////////////////////TICKET #963 Forwarding shadows copy operations -- generic solution?? + * But -- Beware of unverifiable generic solutions! */ template class Variant