Fix Expected, <void> not following c++20 standard, document empty catch(...)

This commit is contained in:
eelke 2026-10-19 16:56:44 +02:00
parent 550049ceff
commit 8f5de10f58

View file

@ -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 <class E>
static Expected<T> 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<void> {
public:
Expected<void>()
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 <class E>
static Expected<void> 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;
}