Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncTask 関連のテンプレートパラメータ制約を修正 #1213

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading