aboutsummaryrefslogtreecommitdiff
path: root/c/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/defs.h')
-rw-r--r--c/defs.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/c/defs.h b/c/defs.h
index ffebcb0..c8d76b3 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -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