Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics: fix "Malformed whitespace in C++" spotted by codefactor.io.
[simgrid.git] / include / xbt / future.hpp
index 95ab69d..ac75bf6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -12,6 +12,7 @@
 #include <boost/variant.hpp>
 #include <exception>
 #include <functional>
+#include <future> // std::future_error
 #include <stdexcept>
 #include <type_traits>
 #include <utility>
@@ -66,9 +67,10 @@ public:
         break;
       }
       default:
-        throw std::logic_error("Invalid result");
+        throw std::future_error(std::future_errc::no_state);
     }
   }
+
 private:
   boost::variant<boost::blank, T, std::exception_ptr> value_;
 };
@@ -126,7 +128,7 @@ template <class R, class F> auto fulfill_promise(R& promise, F&& code) -> declty
   }
 }
 
-template <class P, class F> auto fulfill_promise(P& promise, F&& code) -> decltype(promise.set_value())
+template <class R, class F> auto fulfill_promise(R& promise, F&& code) -> decltype(promise.set_value())
 {
   try {
     std::forward<F>(code)();