[ox/std] Add error.hpp include to memory.hpp
All checks were successful
Build / build (push) Successful in 2m15s

This commit is contained in:
Gary Talent 2023-12-31 22:51:30 -06:00
parent 200e586768
commit de9f842640

View File

@ -39,6 +39,7 @@ constexpr T *construct_at(T *p, Args &&...args ) {
#endif #endif
#include "error.hpp"
#include "utility.hpp" #include "utility.hpp"
@ -290,4 +291,14 @@ constexpr auto make_unique(Args&&... args) {
return UniquePtr<U>(new T(ox::forward<Args>(args)...)); return UniquePtr<U>(new T(ox::forward<Args>(args)...));
} }
template<typename T, typename U = T, typename ...Args>
[[nodiscard]]
constexpr Result<UniquePtr<U>> make_unique_catch(Args&&... args) noexcept {
try {
return UniquePtr<U>(new T(ox::forward<Args>(args)...));
} catch (ox::Exception const&ex) {
return ex.toError();
}
}
} }