@@ -38,11 +38,6 @@ public:
{
}
- R returnValue()
- {
- return ret_;
- }
-
std::tuple<typename std::remove_reference_t<Args>...> args_;
R ret_;
};
@@ -56,10 +51,6 @@ public:
{
}
- void returnValue()
- {
- }
-
std::tuple<typename std::remove_reference_t<Args>...> args_;
};
@@ -140,8 +131,10 @@ public:
return func_(args...);
auto pack = std::make_shared<PackType>(args...);
- bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
- return sync ? pack->returnValue() : R();
+ [[maybe_unused]] bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
+
+ if constexpr (!std::is_void_v<R>)
+ return sync ? std::move(pack->ret_) : R();
}
R invoke(Args... args) override
@@ -175,8 +168,10 @@ public:
}
auto pack = std::make_shared<PackType>(args...);
- bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
- return sync ? pack->returnValue() : R();
+ [[maybe_unused]] bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
+
+ if constexpr (!std::is_void_v<R>)
+ return sync ? std::move(pack->ret_) : R();
}
R invoke(Args... args) override
@@ -58,6 +58,19 @@ public:
return 42;
}
+ struct MoveOnly {
+ MoveOnly() = default;
+ MoveOnly(const MoveOnly &) = delete;
+ MoveOnly &operator=(const MoveOnly &) = delete;
+ MoveOnly(MoveOnly &&) = default;
+ MoveOnly &operator=(MoveOnly &&) = default;
+ };
+
+ MoveOnly methodWithReturnMoveOnly()
+ {
+ return {};
+ }
+
private:
Status status_;
int value_;
@@ -186,6 +199,10 @@ protected:
return TestFail;
}
+ /* Test invoking a method that returns type with no copy ctor/assignment. */
+ object_.invokeMethod(&InvokedObject::methodWithReturnMoveOnly,
+ ConnectionTypeBlocking);
+
return TestPass;
}