diff options
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 |