diff --git a/score/mw/com/test/common_test_resources/proxy_container.h b/score/mw/com/test/common_test_resources/proxy_container.h index fa8039b4a..f121bd214 100644 --- a/score/mw/com/test/common_test_resources/proxy_container.h +++ b/score/mw/com/test/common_test_resources/proxy_container.h @@ -39,7 +39,11 @@ class ProxyContainer return *proxy_; } - Proxy&& Extract() + /// \brief Extracts the proxy, leaving the ProxyContainer in a valid but unspecified state. + /// + /// This function can only be called on an rvalue ProxyContainer, to make it clear that the ProxyContainer should + /// not be used after calling Extract() + Proxy&& Extract() && { SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE(proxy_ != nullptr, "Proxy was not successfully created! Cannot extract it!"); diff --git a/score/mw/com/test/move_semantics/proxy_method/consumer.cpp b/score/mw/com/test/move_semantics/proxy_method/consumer.cpp index 29c39e8bb..220571145 100644 --- a/score/mw/com/test/move_semantics/proxy_method/consumer.cpp +++ b/score/mw/com/test/move_semantics/proxy_method/consumer.cpp @@ -89,7 +89,7 @@ void RunConsumerMoveConstruct(const std::string& failure_message_prefix) std::cout << "\nConsumer: Step 1 - Find service and create proxy A" << std::endl; ProxyContainer proxy_a_container{}; proxy_a_container.CreateProxy(kInstanceSpecifierMovedTo, failure_message_prefix); - auto proxy_a = proxy_a_container.Extract(); + auto proxy_a = std::move(proxy_a_container).Extract(); // Step 2. Call method via proxy A (iteration 0: proxy works before the move) std::cout << "\nConsumer: Step 2 - Call method via proxy A" << std::endl; @@ -110,13 +110,13 @@ void RunConsumerMoveAssign(const std::string& failure_message_prefix) std::cout << "\nConsumer: Step 1 - Find service and create proxy A" << std::endl; ProxyContainer proxy_a_container{}; proxy_a_container.CreateProxy(kInstanceSpecifierMovedFrom, failure_message_prefix); - auto proxy_a = proxy_a_container.Extract(); + auto proxy_a = std::move(proxy_a_container).Extract(); // Step 2. Find service and create proxy B (connected to the moved-to instance, which answers with a - b) std::cout << "\nConsumer: Step 2 - Find service and create proxy B" << std::endl; ProxyContainer proxy_b_container{}; proxy_b_container.CreateProxy(kInstanceSpecifierMovedTo, failure_message_prefix); - auto proxy_b = proxy_b_container.Extract(); + auto proxy_b = std::move(proxy_b_container).Extract(); // Step 3. Call method via proxy A (iteration 0: proxy A works before the move, returns a + b) std::cout << "\nConsumer: Step 3 - Call method via proxy A" << std::endl;