diff --git a/deps/ox/src/ox/std/optional.hpp b/deps/ox/src/ox/std/optional.hpp index 3110d5ab..fa8ed74b 100644 --- a/deps/ox/src/ox/std/optional.hpp +++ b/deps/ox/src/ox/std/optional.hpp @@ -32,16 +32,13 @@ class Optional { constexpr Optional(const Optional &other) { if (other.m_ptr) { - m_ptr = new(m_data.data()) T(*other.m_ptr); + m_ptr = std::construct_at(m_data.data(), *other.m_ptr); } } - constexpr Optional(const Optional &&other) noexcept { - if (m_ptr) { - m_ptr->~T(); - } + constexpr Optional(Optional &&other) noexcept { if (other.m_ptr) { - m_ptr = new(m_data.data()) T(std::move(*other.m_ptr)); + m_ptr = std::construct_at(m_data.data(), std::move(*other.m_ptr)); } } @@ -100,7 +97,7 @@ class Optional { emplace(); } *m_ptr = *other.m_ptr; - } else if (m_ptr) { + } else { reset(); } return *this; @@ -115,7 +112,7 @@ class Optional { emplace(); } *m_ptr = std::move(*other.m_ptr); - } else if (m_ptr) { + } else { reset(); } return *this; @@ -153,7 +150,7 @@ class Optional { return m_ptr; } - constexpr void reset() noexcept { + constexpr void reset() { if (std::is_constant_evaluated()) { ox::safeDelete(m_ptr); } else if (has_value()) {