X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/55a08c7439db5b0335a5b26e40b3a46e1e03d3e8..139d102a3b2b25b6e9f93eb3047d290a3eac2794:/include/simgrid/kernel/future.hpp diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index 906d702937..897e4c231a 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2020. The SimGrid Team. +/* Copyright (c) 2016-2021. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -17,7 +17,7 @@ #include #include -#include +#include namespace simgrid { namespace kernel { @@ -279,7 +279,6 @@ class Future { public: Future() = default; explicit Future(std::shared_ptr> state) : state_(std::move(state)) {} - ~Future() = default; // Move type: Future(Future&) = delete; @@ -329,7 +328,7 @@ public: */ template auto then_no_unwrap(F continuation) -> Future { - typedef decltype(continuation(std::move(*this))) R; + using R = decltype(continuation(std::move(*this))); if (state_ == nullptr) throw std::future_error(std::future_errc::no_state); auto state = std::move(state_); @@ -358,19 +357,16 @@ public: * @exception std::future_error no state is associated with the future */ template - auto then(F continuation) -> typename std::enable_if::value, - Future>::type + auto then(F continuation) -> typename std::enable_if_t::value, + Future> { return this->then_no_unwrap(std::move(continuation)); } /** Attach a continuation to this future (future chaining) */ - template - auto then(F continuation) - -> typename std::enable_if< - is_future::value, - decltype(continuation(std::move(*this))) - >::type + template + auto then(F continuation) -> typename std::enable_if_t::value, + decltype(continuation(std::move(*this)))> { return unwrap_future(this->then_no_unwrap(std::move(continuation))); } @@ -485,7 +481,7 @@ public: } private: - std::shared_ptr> state_{new FutureState()}; + std::shared_ptr> state_ = std::make_shared>(); bool future_get_ = false; }; @@ -536,7 +532,7 @@ public: } private: - std::shared_ptr> state_{new FutureState()}; + std::shared_ptr> state_ = std::make_shared>(); bool future_get_ = false; };