From a88a48d7124391273ecdbe4134aff4d7f5db4431 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 20 Oct 2024 09:13:02 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7c9c02b..50c564c7 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ The library is intended for any compiler that supports C++98/03/11/14/17/20. - Checksums & hash functions - Variants (a type that can store many types in a type-safe interface) - Choice of asserts, exceptions, error handler or no checks on errors -- Unit tested (currently over 6480 tests), using VS2019, GCC 8.1.0, , GCC 9.3.0, Clang 9.0.0 & 10.0.0 +- Unit tested (currently over 9400 tests), using VS2022, GCC 12, Clang 14. - Many utilities for template support. - Easy to read and documented source. - Free support via email, GitHub and Slack From b58ba95e6062f39dc79c9f6829a1aeb19c67bb31 Mon Sep 17 00:00:00 2001 From: rolandreichweinbmw Date: Mon, 2 Dec 2024 13:10:26 +0100 Subject: [PATCH 2/2] Added return to etl::optional emplace, fixed typo (#982) --- include/etl/optional.h | 12 ++++++++---- test/test_optional.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/etl/optional.h b/include/etl/optional.h index 002d010a..f70b2689 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -484,14 +484,16 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR20_STL - void emplace(TArgs&& ... args) + T& emplace(TArgs&& ... args) { storage.construct(etl::forward(args)...); + + return storage.u.value; } #else //************************************************************************* /// Emplaces a value. - /// 1 parameter. + /// 0 parameters. //************************************************************************* T& emplace() { @@ -1048,14 +1050,16 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR14 - void emplace(TArgs&& ... args) + T& emplace(TArgs&& ... args) { storage.construct(etl::forward(args)...); + + return storage.value; } #else //************************************************************************* /// Emplaces a value. - /// 1 parameter. + /// 0 parameters. //************************************************************************* T& emplace() { diff --git a/test/test_optional.cpp b/test/test_optional.cpp index 61e68672..87ee24c7 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -157,6 +157,16 @@ namespace CHECK_EQUAL(0, int(result.value())); } + //************************************************************************* + TEST(test_emplace_return) + { + etl::optional data; + + DataM* datam = &data.emplace(1U); + CHECK_EQUAL(datam, &data.value()); + CHECK(datam != nullptr); + } + //************************************************************************* TEST(test_moveable) {