util/cexec: Add convenience methods for taking strings
Change-Id: I2c62b16d827cd9cb45e32d4c7a497bd064fbbc16
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/stdplus/util/cexec.hpp b/src/stdplus/util/cexec.hpp
index 86dfe88..252d257 100644
--- a/src/stdplus/util/cexec.hpp
+++ b/src/stdplus/util/cexec.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <functional>
+#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
@@ -79,6 +80,12 @@
static_assert(std::is_same_v<Ret, int>, "Unimplemented check routine");
}
}
+template <auto (*makeError)(int, const char*) = makeSystemError,
+ typename... Args>
+inline auto callCheckErrno(const std::string& msg, Args&&... args)
+{
+ return callCheckErrno(msg.c_str(), std::forward(args)...);
+}
/** @brief Wraps common c style error handling for exception throwing
* This requires the callee to provide error information in -r.
@@ -108,6 +115,12 @@
static_assert(std::is_same_v<Ret, int>, "Unimplemented check routine");
}
}
+template <auto (*makeError)(int, const char*) = makeSystemError,
+ typename... Args>
+inline auto callCheckRet(const std::string& msg, Args&&... args)
+{
+ return callCheckRet(msg.c_str(), std::forward(args)...);
+}
} // namespace util
} // namespace stdplus