From 29e7eda887243cf0df0fdc07a8c7c9730a2149ab Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 24 Feb 2021 13:45:10 +0300 Subject: [PATCH] named_thread: rewrite result_storage Use SFINAE as permitted by std::invoke_result_t<> --- Utilities/Thread.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 6d59291eb3..1b67009ca4 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -42,10 +42,20 @@ class need_wakeup {}; template class named_thread; -template +template struct result_storage { - static_assert(std::is_default_constructible_v && noexcept(T())); + static constexpr bool empty = true; + + using type = void; +}; + +template +struct result_storage>>, Args...> +{ + using T = std::invoke_result_t; + + static_assert(std::is_default_constructible_v); alignas(T) std::byte data[sizeof(T)]; @@ -69,17 +79,6 @@ struct result_storage } }; -template <> -struct result_storage -{ - static constexpr bool empty = true; - - using type = void; -}; - -template -using result_storage_t = result_storage>; - template struct thread_thread_name : std::bool_constant {}; @@ -306,9 +305,9 @@ private: // Derived from the callable object Context, possibly a lambda template -class named_thread final : public Context, result_storage_t, thread_base +class named_thread final : public Context, result_storage, thread_base { - using result = result_storage_t; + using result = result_storage; using thread = thread_base; static u64 entry_point(thread_base* _base)