Skip to content

Commit

Permalink
Merge pull request #14938 from bangerth/cxx20-concepts-4
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Mar 22, 2023
2 parents bd588b2 + b5b8f6b commit d2dc6d1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions include/deal.II/base/thread_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#include <utility>
#include <vector>

#ifdef DEAL_II_HAVE_CXX20
# include <concepts>
#endif


#ifdef DEAL_II_WITH_TBB
# include <tbb/task_group.h>
#endif
Expand Down Expand Up @@ -787,8 +792,8 @@ namespace Threads
* @ingroup CPP11
*/
template <typename FunctionObjectType>
DEAL_II_DEPRECATED inline auto
new_thread(FunctionObjectType function_object)
DEAL_II_CXX20_REQUIRES((std::invocable<FunctionObjectType>))
DEAL_II_DEPRECATED inline auto new_thread(FunctionObjectType function_object)
-> Thread<decltype(function_object())>
{
// See the comment in the first new_thread() implementation
Expand Down Expand Up @@ -913,8 +918,10 @@ namespace Threads
* Set the value of a std::promise object by evaluating the action.
*/
template <typename RT, typename Function>
void
evaluate_and_set_promise(Function &function, std::promise<RT> &promise)
DEAL_II_CXX20_REQUIRES(
(std::invocable<Function> &&
std::convertible_to<std::invoke_result_t<Function>, RT>))
void evaluate_and_set_promise(Function &function, std::promise<RT> &promise)
{
promise.set_value(function());
}
Expand All @@ -928,8 +935,9 @@ namespace Threads
* call `std::promise::set_value()` without argument.
*/
template <typename Function>
void
evaluate_and_set_promise(Function &function, std::promise<void> &promise)
DEAL_II_CXX20_REQUIRES((std::invocable<Function>))
void evaluate_and_set_promise(Function & function,
std::promise<void> &promise)
{
function();
promise.set_value();
Expand Down Expand Up @@ -1560,8 +1568,8 @@ namespace Threads
* @ingroup CPP11
*/
template <typename FunctionObjectType>
inline auto
new_task(FunctionObjectType function_object)
DEAL_II_CXX20_REQUIRES((std::invocable<FunctionObjectType>))
inline auto new_task(FunctionObjectType function_object)
-> Task<decltype(function_object())>
{
using return_type = decltype(function_object());
Expand Down

0 comments on commit d2dc6d1

Please sign in to comment.