diff --git a/include/etl/memory.h b/include/etl/memory.h index 474cd449..2fc9341b 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -1260,6 +1260,24 @@ namespace etl } #endif + //********************************* + unique_ptr(pointer p_, typename etl::conditional::value, + TDeleter, + typename etl::add_lvalue_reference::type>::type deleter_) ETL_NOEXCEPT + : p(p_) + , deleter(deleter_) + { + } + +#if ETL_CPP11_SUPPORTED + //********************************* + unique_ptr(pointer pValue, typename etl::remove_reference::type&& deleter) ETL_NOEXCEPT + : p(p_) + , deleter(etl::move(deleter_)) + { + } +#endif + //********************************* ~unique_ptr() { diff --git a/include/etl/version.h b/include/etl/version.h index b65e206b..c62cb2ad 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 19 #define ETL_VERSION_MINOR 4 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 7a7b3caa..753f742f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "19.4.0", + "version": "19.4.1", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 3f950241..6d1dad9a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=19.4.0 +version=19.4.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 4e6b9b80..19546d57 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +19.4.1 +Added constructors with deleters for unique_ptr. + =============================================================================== 19.4.0 Added virtual function 'void on_task_added()' that is called when a task is added to a scheduler. diff --git a/test/test_memory.cpp b/test/test_memory.cpp index 73962a9e..95645c03 100644 --- a/test/test_memory.cpp +++ b/test/test_memory.cpp @@ -1041,6 +1041,46 @@ namespace CHECK_EQUAL(7, up1[3]); } + //************************************************************************* + TEST(test_unique_ptr_custom_deleter) + { + //******************************* + struct Object + { + Object() + : count(1) + { + } + + void Delete() + { + count = 0; + } + + int count; + }; + + //******************************* + struct Deleter + { + void operator()(Object* p) + { + p->Delete(); + } + }; + + Deleter deleter; + Object object; + + CHECK_EQUAL(1, object.count); + + { + etl::unique_ptr up(&object, deleter); + } + + CHECK_EQUAL(0, object.count); + } + //************************************************************************* TEST(test_uninitialized_buffer) {