fixed: deserialization for std::optional<T>

just writing the data does not update the has_value as expected
This commit is contained in:
Arne Morten Kvarving
2020-09-16 08:35:02 +02:00
parent 76c63c4405
commit 4160c6ce98

View File

@@ -617,9 +617,11 @@ void unpack(std::optional<T>&data, std::vector<char>& buffer, int& position,
{
bool has_value;
unpack(has_value, buffer, position, comm);
if (has_value)
unpack(*data, buffer, position, comm);
else
if (has_value) {
T val;
unpack(val, buffer, position, comm);
data = std::optional<T>(val);
} else
data.reset();
}