X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/76ddf2528f029c970be3fd1d08659452b1842ae8..4bd2cbe6c40e96efdbf49550cc66bb9e35df8b94:/include/xbt/system_error.hpp?ds=sidebyside diff --git a/include/xbt/system_error.hpp b/include/xbt/system_error.hpp index 4a2ae7ae44..4b0bbf21fd 100644 --- a/include/xbt/system_error.hpp +++ b/include/xbt/system_error.hpp @@ -43,6 +43,15 @@ std::error_code errno_code(int errnum) return std::error_code(errnum, errno_category()); } +/** Create an `error_code` from `errno` (and clear it) */ +inline +std::error_code errno_code() +{ + int errnum = errno; + errno = 0; + return errno_code(errnum); +} + /** Create a `system_error` from an `errno` value * * This is expected to to whatever is right to create a @@ -60,6 +69,19 @@ std::system_error errno_error(int errnum, const char* what) return std::system_error(errno_code(errnum), what); } +/** Create a `system_code` from `errno` (and clear it) */ +inline +std::system_error errno_error() +{ + return std::system_error(errno_code()); +} + +inline +std::system_error errno_error(const char* what) +{ + return std::system_error(errno_code(), what); +} + } }