Fix flat map const placement new issue

This commit is contained in:
John Wellbelove 2023-06-04 15:45:17 +01:00
parent d95c1cbc6d
commit 085d2c580a
10 changed files with 45 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.36.0",
"version": "20.36.1",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.36.0
version=20.36.1
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1056,7 +1056,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(etl::move(key));
::new ((void*)etl::addressof(pvalue->second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
return refmap_t::insert_at(i_element, *pvalue);
}
#endif

View File

@ -935,18 +935,13 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(map_full));
// Get next available free node
Data_Node& node = create_data_node();
::new ((void*)etl::addressof(node.value.first)) key_type(etl::move(key));
::new ((void*)etl::addressof(node.value.second)) mapped_type();
Data_Node& node = allocate_data_node_with_key(etl::move(key));
// Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate)
inserted_node = insert_node(root_node, node);
// Insert node into tree and return iterator to new node location in tree
i_element = iterator(*this, inserted_node);
ETL_INCREMENT_DEBUG_COUNT
}
return i_element->second;
@ -970,10 +965,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(map_full));
// Get next available free node
Data_Node& node = create_data_node();
::new (etl::addressof(node.value.first)) key_type(key);
::new (etl::addressof(node.value.second)) mapped_type();
Data_Node& node = allocate_data_node_with_key(key);
// Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate)
inserted_node = insert_node(root_node, node);
@ -1510,6 +1502,19 @@ namespace etl
return node;
}
//*************************************************************************
/// Allocate a Data_Node with the supplied key.
//*************************************************************************
Data_Node& allocate_data_node_with_key(const_key_reference key)
{
Data_Node& node = create_data_node();
::new ((void*)etl::addressof(node.value.first)) key_type(key);
::new ((void*)etl::addressof(node.value.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
return node;
}
#if ETL_USING_CPP11
//*************************************************************************
/// Allocate a Data_Node.
@ -1521,6 +1526,20 @@ namespace etl
ETL_INCREMENT_DEBUG_COUNT
return node;
}
//*************************************************************************
/// Allocate a Data_Node with the supplied key.
//*************************************************************************
Data_Node& allocate_data_node_with_key(rvalue_key_reference key)
{
Data_Node& node = create_data_node();
::new ((void*)etl::addressof(node.value.first)) key_type(etl::move(key));
::new ((void*)etl::addressof(node.value.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
return node;
}
#endif
//*************************************************************************

View File

@ -40,7 +40,7 @@ SOFTWARE.
#define ETL_VERSION_MAJOR 20
#define ETL_VERSION_MINOR 36
#define ETL_VERSION_PATCH 0
#define ETL_VERSION_PATCH 1
#define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "20.36.0",
"version": "20.36.1",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=20.36.0
version=20.36.1
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,8 @@
===============================================================================
20.36.1
#700 Compilation error for [] map operator. Fixed map const placement new issue.
Re-enabled memcast tests.
===============================================================================
20.36.0
#663 Make unit tests compile for C++20

View File

@ -93,14 +93,14 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - Optimised O2|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@ -114,14 +114,14 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17 - No STL|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>

View File

@ -1 +1 @@
20.36.0
20.36.1