diff options
Diffstat (limited to 'c/common.h')
-rw-r--r-- | c/common.h | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -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); } |