aboutsummaryrefslogtreecommitdiff
path: root/c/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.h')
-rw-r--r--c/common.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/c/common.h b/c/common.h
index 24c98c8..01083b8 100644
--- a/c/common.h
+++ b/c/common.h
@@ -55,24 +55,23 @@ std::optional<T> maybe_make(U... xs)
}
/* Call Windows API function, throwing error on NULL. */
-template <auto F, typename... T>
-inline auto require(T... xs)
+template <typename T>
+inline T require(T x)
{
- if (auto r = F(xs...)) return r;
- else throw Win32Error();
+ if (!x) throw Win32Error();
+ return x;
}
/* Call Windows API function, showing a warning on NULL. */
-template <auto F, typename... T>
-inline auto prefer(T... xs)
+template <typename T>
+inline T prefer(T x)
{
- if (auto r = F(xs...))
- return r;
- else {
+ if (!x) {
EBMessageBox(Win32Error().what<TCHAR>(),
- TEXT("System Error"), MB_ICONWARNING);
- return (decltype(F(std::declval<T>()...)))NULL;
+ TEXT("System Error"), MB_ICONWARNING);
+ return (T)NULL;
}
+ return x;
}
/* Return integer scaled for current DPI. */