Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Homogeneise throwned system_error
[simgrid.git] / include / xbt / system_error.hpp
diff --git a/include/xbt/system_error.hpp b/include/xbt/system_error.hpp
new file mode 100644 (file)
index 0000000..02f5089
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (c) 2016. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <cerrno>
+
+#include <system_error>
+
+namespace simgrid {
+namespace xbt {
+
+inline
+const std::error_category& errno_category() noexcept
+{
+  return std::generic_category();
+}
+
+inline
+std::system_error errno_error(int errnum) noexcept
+{
+  return std::system_error(errnum, errno_category());
+}
+
+inline
+std::system_error errno_error(int errno, const char* what)
+{
+  return std::system_error(errnum, errno_category(), what);
+}
+
+}
+}