diff options
Diffstat (limited to 'c/defs.h')
-rw-r--r-- | c/defs.h | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -2,6 +2,7 @@ #define DEFS_H #include <memory> +#include <optional> #include <windows.h> #include <commctrl.h> #include <SWI-Prolog.h> @@ -144,15 +145,13 @@ inline int Dpi(int i) } template <class T, typename ...A> -std::unique_ptr<T> try_make_unique(A ...args) +std::optional<T> try_make(A ...args) { - std::unique_ptr<T> up; try { - up = std::make_unique<T>(args...); + return T(args...); } catch (...) { - up = nullptr; + return {}; } - return up; } #endif |