From: Wolfgang Bangerth Date: Tue, 21 Mar 2023 23:31:59 +0000 (-0600) Subject: Apply concepts to thread_management.h. X-Git-Tag: v9.5.0-rc1~438^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5b8f6b4ac83d4f5ada8f82ae9fe7568df31f244;p=dealii.git Apply concepts to thread_management.h. --- diff --git a/include/deal.II/base/thread_management.h b/include/deal.II/base/thread_management.h index 50f2d702b8..26b2b8b1a1 100644 --- a/include/deal.II/base/thread_management.h +++ b/include/deal.II/base/thread_management.h @@ -34,6 +34,11 @@ #include #include +#ifdef DEAL_II_HAVE_CXX20 +# include +#endif + + #ifdef DEAL_II_WITH_TBB # include #endif @@ -787,8 +792,8 @@ namespace Threads * @ingroup CPP11 */ template - DEAL_II_DEPRECATED inline auto - new_thread(FunctionObjectType function_object) + DEAL_II_CXX20_REQUIRES((std::invocable)) + DEAL_II_DEPRECATED inline auto new_thread(FunctionObjectType function_object) -> Thread { // See the comment in the first new_thread() implementation @@ -913,8 +918,10 @@ namespace Threads * Set the value of a std::promise object by evaluating the action. */ template - void - evaluate_and_set_promise(Function &function, std::promise &promise) + DEAL_II_CXX20_REQUIRES( + (std::invocable && + std::convertible_to, RT>)) + void evaluate_and_set_promise(Function &function, std::promise &promise) { promise.set_value(function()); } @@ -928,8 +935,9 @@ namespace Threads * call `std::promise::set_value()` without argument. */ template - void - evaluate_and_set_promise(Function &function, std::promise &promise) + DEAL_II_CXX20_REQUIRES((std::invocable)) + void evaluate_and_set_promise(Function & function, + std::promise &promise) { function(); promise.set_value(); @@ -1560,8 +1568,8 @@ namespace Threads * @ingroup CPP11 */ template - inline auto - new_task(FunctionObjectType function_object) + DEAL_II_CXX20_REQUIRES((std::invocable)) + inline auto new_task(FunctionObjectType function_object) -> Task { using return_type = decltype(function_object());