File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,19 @@ namespace tremotesf {
4747 if (mSharedData ->unhandledException ) {
4848 std::rethrow_exception (mSharedData ->unhandledException );
4949 }
50- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
51- return std::move (mSharedData ->result ).value ();
50+ if constexpr (!std::is_void_v<T>) {
51+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
52+ return std::move (mSharedData ->result ).value ();
53+ }
5254 }
5355
5456 private:
57+ struct Empty {};
58+ using ResultValue = std::conditional_t <std::is_void_v<T>, Empty, T>;
5559 struct SharedData {
5660 QObject receiver{};
5761 std::atomic_bool cancelled{};
58- std::optional<T > result{};
62+ std::optional<ResultValue > result{};
5963 std::exception_ptr unhandledException{};
6064 std::coroutine_handle<> coroutineHandle{};
6165 };
@@ -75,7 +79,11 @@ namespace tremotesf {
7579 windowsSetUpFatalErrorHandlersInThread ();
7680#endif
7781 try {
78- mSharedData ->result = mFunction ();
82+ if constexpr (std::is_void_v<T>) {
83+ mFunction ();
84+ } else {
85+ mSharedData ->result = mFunction ();
86+ }
7987 } catch (...) {
8088 mSharedData ->unhandledException = std::current_exception ();
8189 }
You can’t perform that action at this time.
0 commit comments