mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Added constructors with deleters for unique_ptr.
This commit is contained in:
parent
0412615952
commit
503b990514
@ -1260,6 +1260,24 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
unique_ptr(pointer p_, typename etl::conditional<etl::is_reference<TDeleter>::value,
|
||||
TDeleter,
|
||||
typename etl::add_lvalue_reference<const TDeleter>::type>::type deleter_) ETL_NOEXCEPT
|
||||
: p(p_)
|
||||
, deleter(deleter_)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
//*********************************
|
||||
unique_ptr(pointer pValue, typename etl::remove_reference<TDeleter>::type&& deleter) ETL_NOEXCEPT
|
||||
: p(p_)
|
||||
, deleter(etl::move(deleter_))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
~unique_ptr()
|
||||
{
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library ETL
|
||||
version=19.4.0
|
||||
version=19.4.1
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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<Object, Deleter> up(&object, deleter);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(0, object.count);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_uninitialized_buffer)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user