From 54981cfaa46e03389c36cb5ccefb5056a51956a4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 22 Mar 2018 06:11:35 +0000 Subject: [PATCH] Merge remote-tracking branch 'origin/development' # Conflicts: # support/Release notes.txt --- include/etl/optional.h | 12 ++++++++++++ support/Release notes.txt | 4 ++++ test/test_optional.cpp | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/etl/optional.h b/include/etl/optional.h index a1ec6a64..08cf7805 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -313,6 +313,18 @@ namespace etl other = temp; } + //*************************************************************************** + /// Reset back to invalid. + //*************************************************************************** + void reset() + { + if (valid) + { + storage.template get_reference().~T(); + valid = false; + } + } + private: typename etl::aligned_storage_as::type storage; diff --git a/support/Release notes.txt b/support/Release notes.txt index 1f55c588..58b72831 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.00.1 +Added reset() to etl::optional + =============================================================================== 11.00.0 New directory structure. diff --git a/test/test_optional.cpp b/test/test_optional.cpp index e0d081f4..a8b2d665 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -396,5 +396,15 @@ namespace CHECK_EQUAL(data1, original2); CHECK_EQUAL(data2, original1); } + + //************************************************************************* + TEST(test_reset) + { + etl::optional data(Data("1")); + CHECK(bool(data)); + + data.reset(); + CHECK(!bool(data)); + } }; }