aboutsummaryrefslogtreecommitdiff
path: root/c/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/defs.h')
-rw-r--r--c/defs.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/c/defs.h b/c/defs.h
index 766682e..ffebcb0 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -13,7 +13,6 @@ struct Library
Library(const TCHAR *);
~Library();
FARPROC GetProcAddress(const char *);
- static std::unique_ptr<Library> Load(const TCHAR *);
private:
HMODULE m_hModule;
};
@@ -144,4 +143,16 @@ inline int Dpi(int i)
return MulDiv(i, g_iDPI, 96);
}
+template <class T, typename ...A>
+std::unique_ptr<T> try_make_unique(A ...args)
+{
+ std::unique_ptr<T> up;
+ try {
+ up = std::make_unique<T>(args...);
+ } catch (...) {
+ up = nullptr;
+ }
+ return up;
+}
+
#endif