aboutsummaryrefslogtreecommitdiff
path: root/c/common.h
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-20 01:49:36 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-20 01:49:36 +0200
commit4da9280a307ced3fab399d655b9d11330fc33bc4 (patch)
treebd13c3543ce47c47ffb49b271c51e413b742ba24 /c/common.h
parentb102ae6d6ea778f28d4213b5b886dcb51a9b0fd9 (diff)
downloadEpisodeBrowser-4da9280a307ced3fab399d655b9d11330fc33bc4.tar.gz
Simplify templates.
Diffstat (limited to 'c/common.h')
-rw-r--r--c/common.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/c/common.h b/c/common.h
index 7d3f8bd..a4f73e5 100644
--- a/c/common.h
+++ b/c/common.h
@@ -34,7 +34,7 @@ private:
HMODULE m_hModule;
};
-template <class T>
+template <typename T>
T* Library::GetProcAddress(const char* const szProc)
{
return (T*)(void*)::GetProcAddress(m_hModule, szProc);
@@ -43,32 +43,32 @@ T* Library::GetProcAddress(const char* const szProc)
/* Create and return an object of type C. If construction fails,
* return nothing. The returned value must be checked before being
* used, as dereferencing is undefined if the value is empty. */
-template <class C, class... T>
-std::optional<C> maybe_make(T... args)
+template <typename T, typename... U>
+std::optional<T> maybe_make(U... xs)
{
try {
- return C(args...);
+ return T(xs...);
} catch (...) {
return {};
}
}
/* Call Windows API function, throwing error on NULL. */
-template <auto f, class... T>
-inline auto throw_nil(T... args)
+template <auto F, typename... T>
+inline auto throw_nil(T... xs)
{
- auto r = f(args...);
+ auto r = F(xs...);
if (!r) throw Win32Error(GetLastError());
return r;
}
/* Call Windows API function, showing a warning on NULL. */
-template <auto f, class... T>
-inline auto warn_nil(T... args)
+template <auto F, typename... T>
+inline auto warn_nil(T... xs)
{
- decltype(f(std::declval<T>()...)) r;
+ decltype(F(std::declval<T>()...)) r;
try {
- r = throw_nil<f>(args...);
+ r = throw_nil<F>(xs...);
} catch (Win32Error& e) {
EBMessageBox(e.twhat(), TEXT("System Error"), MB_ICONWARNING);
}