diff --git a/libs/full/collectives/include/hpx/collectives/detail/communicator.hpp b/libs/full/collectives/include/hpx/collectives/detail/communicator.hpp index ec21d34f192f..bfc2d895ea40 100644 --- a/libs/full/collectives/include/hpx/collectives/detail/communicator.hpp +++ b/libs/full/collectives/include/hpx/collectives/detail/communicator.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -244,27 +245,6 @@ namespace hpx::collectives::detail { return fut; } - template - struct on_exit - { - explicit constexpr on_exit(F&& f_) noexcept - : f(HPX_MOVE(f_)) - { - } - - on_exit(on_exit const&) = delete; - on_exit(on_exit&&) = delete; - on_exit& operator=(on_exit const&) = delete; - on_exit& operator=(on_exit&&) = delete; - - ~on_exit() - { - f(); - } - - F f; - }; - // Step will be invoked under lock for each site that checks in (either // set or get). // @@ -320,7 +300,8 @@ namespace hpx::collectives::detail { // On exit, keep track of number of invocations of this // callback. - on_exit _([this] { ++on_ready_count_; }); + auto on_exit = hpx::experimental::scope_exit( + [this] { ++on_ready_count_; }); if constexpr (!std::is_same_v>)