Skip to content

Commit

Permalink
AsyncTask 関連のテンプレートパラメータ制約を修正 (#1213)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raclamusi authored Mar 16, 2024
1 parent cc791eb commit c1beee0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Siv3D/include/Siv3D/AsyncTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace s3d
/// @param ...args 非同期処理のタスクで実行する関数の引数
/// @remark 作成と同時にタスクが非同期で実行されます。
/// @remark 参照を渡す場合は `std::ref()` を使ってください。
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<Fty, Args...>>* = nullptr>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<std::decay_t<Fty>, std::decay_t<Args>...>>* = nullptr>
SIV3D_NODISCARD_CXX20
explicit AsyncTask(Fty&& f, Args&&... args);

Expand Down Expand Up @@ -97,7 +97,7 @@ namespace s3d
base_type m_data;
};

template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<Fty, Args...>>* = nullptr>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<std::decay_t<Fty>, std::decay_t<Args>...>>* = nullptr>
AsyncTask(Fty, Args...)->AsyncTask<std::invoke_result_t<std::decay_t<Fty>, std::decay_t<Args>...>>;

/// @brief 非同期処理のタスクを作成します。
Expand All @@ -108,7 +108,7 @@ namespace s3d
/// @remark 作成と同時にタスクが非同期で実行されます。
/// @remark 参照を渡す場合は `std::ref()` を使ってください。
/// @return 作成された非同期処理のタスク
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<Fty, Args...>>* = nullptr>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<std::decay_t<Fty>, std::decay_t<Args>...>>* = nullptr>
[[nodiscard]]
inline auto Async(Fty&& f, Args&&... args);
}
Expand Down
4 changes: 2 additions & 2 deletions Siv3D/include/Siv3D/detail/AsyncTask.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace s3d
: m_data{ std::move(other.m_data) } {}

template <class Type>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<Fty, Args...>>*>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<std::decay_t<Fty>, std::decay_t<Args>...>>*>
inline AsyncTask<Type>::AsyncTask(Fty&& f, Args&&... args)
# if !SIV3D_PLATFORM(WEB) || defined(__EMSCRIPTEN_PTHREADS__)
: m_data{ std::async(std::launch::async, std::forward<Fty>(f), std::forward<Args>(args)...) } {}
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace s3d
return m_data.share();
}

template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<Fty, Args...>>*>
template <class Fty, class... Args, std::enable_if_t<std::is_invocable_v<std::decay_t<Fty>, std::decay_t<Args>...>>*>
inline auto Async(Fty&& f, Args&&... args)
{
return AsyncTask<std::invoke_result_t<std::decay_t<Fty>, std::decay_t<Args>...>>{ std::forward<Fty>(f), std::forward<Args>(args)... };
Expand Down

0 comments on commit c1beee0

Please sign in to comment.