diff --git a/core/Expected.h b/core/Expected.h index a5f054b..30ef615 100644 --- a/core/Expected.h +++ b/core/Expected.h @@ -63,32 +63,6 @@ public: } } -// void swap(Expected& rhs) -// { -// if (m_valid) { -// if (rhs.m_valid) { -// using std::swap; -// swap(m_value, rhs.m_value); -// } -// else { -// auto t = std::move(rhs.m_error); -// new(&rhs.m_value) T(std::move(m_value)); -// new(&m_error) std::exception_ptr(t); -// std::swap(m_valid, rhs.m_valid); -// } -// } -// else { -// if (rhs.m_valid) { -// rhs.swap(*this); -// } -// else { -// using std::swap; -// swap(m_error, rhs.m_error); -// std::swap(m_valid, rhs.m_valid); -// } -// } -// } - template static Expected fromException(const E& exception) { @@ -144,6 +118,7 @@ public: return true; } catch (...) { + // The stored exception is not of type E. It is still held in m_error. } return false; } @@ -168,7 +143,7 @@ class Expected { public: - Expected() + Expected() : m_valid(true) {} @@ -186,26 +161,6 @@ public: ~Expected() {} -// void swap(Expected& rhs) -// { -// if (m_valid) { -// if (!rhs.m_valid) { -// m_error = rhs.m_error; -// std::swap(m_valid, rhs.m_valid); -// } -// } -// else { -// if (rhs.m_valid) { -// rhs.swap(*this); -// } -// else { -// using std::swap; -// swap(m_error, rhs.m_error); -// std::swap(m_valid, rhs.m_valid); -// } -// } -// } - template static Expected fromException(const E& exception) { @@ -253,6 +208,7 @@ public: return true; } catch (...) { + // The stored exception is not of type E. It is still held in m_error. } return false; }