Added tests for bug when swapping value/null-value and null-value value

This commit is contained in:
Glyn Matthews committed 2019-05-31 21:22:29 +02:00
1 parent 53697d4a36
commit 8fbb0262a1
3 files changed
+30 -2

No files matched your search

+2 -1
View File
@@ -1238,9 +1238,9 @@ public:
void
swap(optional &rhs) noexcept(std::is_nothrow_move_constructible<T>::value
&&detail::is_nothrow_swappable<T>::value) {
using std::swap;
if (has_value()) {
if (rhs.has_value()) {
using std::swap;
swap(**this, *rhs);
} else {
new (std::addressof(rhs.m_value)) T(std::move(this->m_value));
@@ -1250,6 +1250,7 @@ public:
new (std::addressof(this->m_value)) T(std::move(rhs.m_value));
rhs.m_value.T::~T();
}
swap(this->m_has_value, rhs.m_has_value);
}
/// Returns a pointer to the stored value