X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b0ffeb85dcd9b23d14bf0eaad4077daee4e50579..479eb3c5eb55f556b5b8c072f092685bc410ad90:/include/xbt/future.hpp?ds=sidebyside diff --git a/include/xbt/future.hpp b/include/xbt/future.hpp index 7211c4ec77..68040f532a 100644 --- a/include/xbt/future.hpp +++ b/include/xbt/future.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2016. The SimGrid Team. +/* Copyright (c) 2015-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -9,23 +9,21 @@ #include -#include #include +#include #include - #include - - +#include namespace simgrid { namespace xbt { /** A value or an exception (or nothing) * - * This is similar to optional> but it with a Future/Promise + * This is similar to `optional>`` but it with a Future/Promise * like API. * - * Also the name it not so great. + * Also the name is not so great. **/ template class Result { @@ -35,7 +33,7 @@ class Result { exception, }; public: - Result() {} + Result() { /* Nothing to do */} ~Result() { this->reset(); } // Copy (if T is copyable) and move: @@ -120,14 +118,11 @@ public: /** Extract the value from the future * - * After this the value is invalid. + * After this, the value is invalid. **/ T get() { switch (status_) { - case ResultStatus::invalid: - default: - throw std::logic_error("Invalid result"); case ResultStatus::value: { T value = std::move(value_); value_.~T(); @@ -141,6 +136,8 @@ public: std::rethrow_exception(std::move(exception)); break; } + default: + throw std::logic_error("Invalid result"); } } private: @@ -187,7 +184,7 @@ public: * promise.set_value(code()); * * - * but it takes care of exceptions and works with void. + * but it takes care of exceptions and works with `void`. * * We might need this when working with generic code because * the trivial implementation does not work with `void` (before C++1z). @@ -220,7 +217,7 @@ auto fulfillPromise(P& promise, F&& code) } } -/** Set a promise/result from a future/resul +/** Set a promise/result from a future/result * * Roughly this does: *