diff --git a/src/lib/diff/tree-mutator-collection-binding.hpp b/src/lib/diff/tree-mutator-collection-binding.hpp index f778ae48c..e90199089 100644 --- a/src/lib/diff/tree-mutator-collection-binding.hpp +++ b/src/lib/diff/tree-mutator-collection-binding.hpp @@ -128,6 +128,12 @@ namespace diff{ , openSub(u) { } + // allow move construction only, + // to enable use of unique_ptr in collections + CollectionBinding(CollectionBinding&&) = default; + CollectionBinding(CollectionBinding&) = delete; + + /* === content manipulation API === */ @@ -259,9 +265,9 @@ namespace diff{ public: - ChildCollectionMutator(BIN wiringClosures, PAR&& chain) + ChildCollectionMutator(BIN&& wiringClosures, PAR&& chain) : PAR(std::forward(chain)) - , binding_(wiringClosures) + , binding_(forward(wiringClosures)) , pos_(binding_.initMutation()) { } @@ -280,7 +286,7 @@ namespace diff{ { if (binding_.isApplicable(n)) { - binding_.inject (binding_.construct(n)); + binding_.inject (std::move (binding_.construct(n))); return true; } else diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index 822a7bebf..5c74bae99 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -411,7 +411,8 @@ namespace diff{ * - the _matcher closure_ (CollectionBindingBuilder::matchElement) defines * how to determine, if an implementation data element "matches" a given diff spec * - the _constructor closure_ (CollectionBindingBuilder::constructFrom) defines how - * to build a new implementation data element from the spec of an `INS` diff verb + * to build a new implementation data element from the spec of an `INS` diff verb. + * Note: the result will be moved (move-constructed) into the target container. * - the optional _selector closure_ (CollectionBindingBuilder::isApplicableIf) * allows to limit applicability of this whole binding (layer) to only some * diff specs. E.g., we may set up a binding for elements with value semantics diff --git a/tests/gui/test/mock-elm.hpp b/tests/gui/test/mock-elm.hpp index 944354a09..19bbf2289 100644 --- a/tests/gui/test/mock-elm.hpp +++ b/tests/gui/test/mock-elm.hpp @@ -92,7 +92,7 @@ namespace test{ using std::string; class MockElm; - using PMockElm = std::shared_ptr; + using PMockElm = std::unique_ptr; /** @@ -252,7 +252,7 @@ namespace test{ }) .constructFrom ([&](GenNode const& spec) -> PMockElm { - return std::make_shared(spec.idi, this->uiBus_); // create a child element wired via this Element's BusTerm + return std::make_unique(spec.idi, this->uiBus_); // create a child element wired via this Element's BusTerm }) .buildChildMutator ([&](PMockElm& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool {