From 95ae6a4812a2dfcdca63368d9939a28109e95ac4 Mon Sep 17 00:00:00 2001 From: sahithinukala Date: Mon, 7 Sep 2026 14:26:09 +0530 Subject: [PATCH 1/2] mw/com: Make ProxyContainer::Extract() rvalue-ref-qualified --- score/mw/com/test/common_test_resources/proxy_container.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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!"); From eee7effd5db383ede95f6fdebe323cb5e14fbbbd Mon Sep 17 00:00:00 2001 From: sahithinukala Date: Mon, 7 Sep 2026 14:26:09 +0530 Subject: [PATCH 2/2] mw/com: Fix proxy_method consumer to move ProxyContainer before Extract() --- score/mw/com/test/move_semantics/proxy_method/consumer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;