From f603002c3396bfda1af6d991708dadaa5cf70a3e Mon Sep 17 00:00:00 2001
From: Li Feng
Date: Mon, 15 Jul 2024 13:16:58 +1000
Subject: [PATCH 1/2] Allow move-only types in Promise<>. (based on
contribution from jb-gcx)
---
support-lib/cpp/Future.hpp | 1 +
test-suite/handwritten-src/cpp/test_helpers.cpp | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/support-lib/cpp/Future.hpp b/support-lib/cpp/Future.hpp
index dede703d..59d5a0e0 100644
--- a/support-lib/cpp/Future.hpp
+++ b/support-lib/cpp/Future.hpp
@@ -57,6 +57,7 @@ struct ValueHolder {
using type = T;
std::optional value;
T getValueUnsafe() const {return *value;}
+ T getValueUnsafe() {return std::move(*value);}
};
template <>
struct ValueHolder {
diff --git a/test-suite/handwritten-src/cpp/test_helpers.cpp b/test-suite/handwritten-src/cpp/test_helpers.cpp
index 34920983..a6932efa 100644
--- a/test-suite/handwritten-src/cpp/test_helpers.cpp
+++ b/test-suite/handwritten-src/cpp/test_helpers.cpp
@@ -19,6 +19,11 @@
namespace testsuite {
+// verify we we can put move only types in futures
+std::unique_ptr testFutureMove() {
+ return djinni::Promise>::resolve(nullptr).get();
+}
+
SetRecord TestHelpers::get_set_record() {
return SetRecord { {
"StringA",
From 00878de8d537f8fba114198469897005c3f38de7 Mon Sep 17 00:00:00 2001
From: Li Feng
Date: Tue, 16 Jul 2024 10:15:21 +1000
Subject: [PATCH 2/2] delete unneeded overload
---
support-lib/cpp/Future.hpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/support-lib/cpp/Future.hpp b/support-lib/cpp/Future.hpp
index 59d5a0e0..aee1c23e 100644
--- a/support-lib/cpp/Future.hpp
+++ b/support-lib/cpp/Future.hpp
@@ -56,7 +56,6 @@ template
struct ValueHolder {
using type = T;
std::optional value;
- T getValueUnsafe() const {return *value;}
T getValueUnsafe() {return std::move(*value);}
};
template <>