[ox/std] Make most of Optional constexpr

This commit is contained in:
Gary Talent 2021-11-06 12:53:23 -05:00
parent 9a8bb557a6
commit 2bcea545f5

View File

@ -21,12 +21,12 @@ template<typename T, std::size_t buffSize = sizeof(T)>
class Optional {
private:
T *m_ptr = nullptr;
char m_data[buffSize];
char m_data[buffSize] = {};
public:
Optional() noexcept = default;
constexpr Optional() noexcept = default;
Optional(const Optional &other) {
constexpr Optional(const Optional &other) {
if (m_ptr) {
m_ptr->~T();
}
@ -37,7 +37,7 @@ class Optional {
}
}
Optional(const Optional &&other) noexcept {
constexpr Optional(const Optional &&other) noexcept {
if (m_ptr) {
m_ptr->~T();
}
@ -82,7 +82,7 @@ class Optional {
return m_ptr;
}
Optional &operator=(const Optional &other) {
constexpr Optional &operator=(const Optional &other) {
if (this == &other) {
return *this;
}
@ -97,7 +97,7 @@ class Optional {
return *this;
}
Optional &operator=(Optional &&other) noexcept {
constexpr Optional &operator=(Optional &&other) noexcept {
if (this == &other) {
return *this;
}