From b5b8f6b4ac83d4f5ada8f82ae9fe7568df31f244 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 Mar 2023 17:31:59 -0600 Subject: [PATCH] Apply concepts to thread_management.h. --- include/deal.II/base/thread_management.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) 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()); -- 2.39.5