diff --git a/deps/ox/src/ox/std/memory.hpp b/deps/ox/src/ox/std/memory.hpp index a9374f9c..4e751f31 100644 --- a/deps/ox/src/ox/std/memory.hpp +++ b/deps/ox/src/ox/std/memory.hpp @@ -39,6 +39,7 @@ constexpr T *construct_at(T *p, Args &&...args ) { #endif +#include "error.hpp" #include "utility.hpp" @@ -290,4 +291,14 @@ constexpr auto make_unique(Args&&... args) { return UniquePtr(new T(ox::forward(args)...)); } +template +[[nodiscard]] +constexpr Result> make_unique_catch(Args&&... args) noexcept { + try { + return UniquePtr(new T(ox::forward(args)...)); + } catch (ox::Exception const&ex) { + return ex.toError(); + } +} + }