Skip to content

Commit

Permalink
Merge pull request #180 from Snapchat/lf/move-only-promise
Browse files Browse the repository at this point in the history
Allow move-only types in Promise<>. (based on contribution from jb-gcx)
  • Loading branch information
li-feng-sc authored Jul 16, 2024
2 parents 4b57d4a + 00878de commit 5466945
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion support-lib/cpp/Future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ template <typename T>
struct ValueHolder {
using type = T;
std::optional<T> value;
T getValueUnsafe() const {return *value;}
T getValueUnsafe() {return std::move(*value);}
};
template <>
struct ValueHolder<void> {
Expand Down
5 changes: 5 additions & 0 deletions test-suite/handwritten-src/cpp/test_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

namespace testsuite {

// verify we we can put move only types in futures
std::unique_ptr<int> testFutureMove() {
return djinni::Promise<std::unique_ptr<int>>::resolve(nullptr).get();
}

SetRecord TestHelpers::get_set_record() {
return SetRecord { {
"StringA",
Expand Down

0 comments on commit 5466945

Please sign in to comment.