Added reset() to etl::optional

This commit is contained in:
John Wellbelove 2018-03-21 19:35:18 +00:00
parent 44068d1493
commit d28c88b1da
3 changed files with 26 additions and 0 deletions

View File

@ -313,6 +313,18 @@ namespace etl
other = temp;
}
//***************************************************************************
/// Reset back to invalid.
//***************************************************************************
void reset()
{
if (valid)
{
storage.template get_reference<T>().~T();
valid = false;
}
}
private:
typename etl::aligned_storage_as<sizeof(T), T>::type storage;

View File

@ -1,3 +1,7 @@
===============================================================================
11.00.1
Added reset() to etl::optional
===============================================================================
11.00.0
New directory structure.

View File

@ -396,5 +396,15 @@ namespace
CHECK_EQUAL(data1, original2);
CHECK_EQUAL(data2, original1);
}
//*************************************************************************
TEST(test_reset)
{
etl::optional<Data> data(Data("1"));
CHECK(bool(data));
data.reset();
CHECK(!bool(data));
}
};
}