aboutsummaryrefslogtreecommitdiff
path: root/c/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.h')
-rw-r--r--c/common.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/c/common.h b/c/common.h
index a4f73e5..6b29ed5 100644
--- a/c/common.h
+++ b/c/common.h
@@ -55,7 +55,7 @@ std::optional<T> maybe_make(U... xs)
/* Call Windows API function, throwing error on NULL. */
template <auto F, typename... T>
-inline auto throw_nil(T... xs)
+inline auto require(T... xs)
{
auto r = F(xs...);
if (!r) throw Win32Error(GetLastError());
@@ -64,15 +64,14 @@ inline auto throw_nil(T... xs)
/* Call Windows API function, showing a warning on NULL. */
template <auto F, typename... T>
-inline auto warn_nil(T... xs)
+inline auto prefer(T... xs)
{
- decltype(F(std::declval<T>()...)) r;
try {
- r = throw_nil<F>(xs...);
+ return require<F>(xs...);
} catch (Win32Error& e) {
EBMessageBox(e.twhat(), TEXT("System Error"), MB_ICONWARNING);
+ return (decltype(F(std::declval<T>()...)))NULL;
}
- return r;
}
/* Return integer scaled for current DPI. */