variant& operator= (variant&& v) {
// only if operator= may throw
// N - size of inner buffer
char buf[N];
// create "backup" for our value
memcpy(buf, m_buf, N);
on_scope_failure (return_value) {
swap_buffers(buf, m_buf);
};
// pseudocode, should be std::visit in real code
new (m_buf) T(std::move(v.current_value));
// success
return_value.no_longer_needed();
// swap for case when T was self reference, return it on its place for dctor
swap_buffers(buf, m_buf);
// should be std::visit in real code + set real index
destroy_at((T*)m_buf;
// place new value on its place
memcpy(m_buf, buf, N);
return *this;
}