win32: add except::try_func
This commit is contained in:
parent
2e3aaa4c17
commit
d8f916a25b
@ -11,6 +11,8 @@
|
||||
#define CRUFT_UTIL_WIN32_EXCEPT_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <functional>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace cruft::win32 {
|
||||
@ -22,6 +24,18 @@ namespace cruft::win32 {
|
||||
DWORD code (void) const;
|
||||
static DWORD last_code (void);
|
||||
|
||||
template <typename FunctionT, typename ...ArgsT>
|
||||
static decltype(auto)
|
||||
try_call (FunctionT &&func, ArgsT &&...args)
|
||||
{
|
||||
return try_value (
|
||||
std::invoke (
|
||||
std::forward<FunctionT> (func),
|
||||
std::forward<ArgsT> (args)...
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static HANDLE try_value (HANDLE);
|
||||
|
||||
static void try_code (void);
|
||||
|
Loading…
Reference in New Issue
Block a user