diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-15 03:04:22 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-15 03:04:22 +0200 |
commit | 7153a258427d3e401914de800bfdf1c7165cab71 (patch) | |
tree | 7aa97f2c9e4dd97b6c67bedb09ef03d7f2b3f19d /c/defs.h | |
parent | 0e56160e859d32adffb7c9df3cd78cde0bff8df8 (diff) | |
download | EpisodeBrowser-7153a258427d3e401914de800bfdf1c7165cab71.tar.gz |
Replace Library::Load with try_make_unique template.
Diffstat (limited to 'c/defs.h')
-rw-r--r-- | c/defs.h | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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 |