Skip to content

Commit

Permalink
Fix #832: Only copy/move storage value when optional is valid (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiraffollo authored Jan 27, 2024
1 parent 0f1840a commit 8403165
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/etl/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,10 @@ namespace etl
{
if (this != &other)
{
storage.value = other.storage.value;
if (other.valid)
{
storage.value = other.storage.value;
}
valid = other.valid;
}

Expand All @@ -783,7 +786,10 @@ namespace etl
{
if (this != &other)
{
storage.value = etl::move(other.storage.value);
if (other.valid)
{
storage.value = etl::move(other.storage.value);
}
valid = other.valid;
}

Expand Down

0 comments on commit 8403165

Please sign in to comment.