aboutsummaryrefslogtreecommitdiff
path: root/c/defs.h
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-15 03:04:22 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-15 03:04:22 +0200
commit7153a258427d3e401914de800bfdf1c7165cab71 (patch)
tree7aa97f2c9e4dd97b6c67bedb09ef03d7f2b3f19d /c/defs.h
parent0e56160e859d32adffb7c9df3cd78cde0bff8df8 (diff)
downloadEpisodeBrowser-7153a258427d3e401914de800bfdf1c7165cab71.tar.gz
Replace Library::Load with try_make_unique template.
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