Added etl::is_forward_link, etl::is_bidirectional_link and etl::is_tree_link to intrusive links.

Added Constructors, access and status member functions to intrusive links.
This commit is contained in:
John Wellbelove 2023-06-15 09:25:28 +01:00
parent c3c12da861
commit ed589c91c6
7 changed files with 764 additions and 344 deletions

3
.gitignore vendored
View File

@ -377,3 +377,6 @@ test/syntax_check/c++11/bgcc
test/syntax_check/c++17/bgcc
test/syntax_check/c++20/bgcc
test/vs2022/Debug MSVC C++17
test/vs2022/Debug MSVC C++17 - No STL
test/vs2022/Release MSVC C++20 - No STL - Optimised -O2
test/vs2022/Release MSVC C++20 - Optimised O2

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,11 @@
===============================================================================
20.37.0
#708 Fix missing class key with friend.
#709 intrusive_list::iterator operator -> should not dereference pointer before return
#709 intrusive_list::iterator operator -> should not dereference pointer before return.
#710 Calling accept on etl::variant visits a copy instead of the original object.
#711 Added etl::is_forward_link, etl::is_bidirectional_link and etl::is_tree_link to intrusive links.
Added Constructors, access and status member functions to intrusive links.
#712 Unable to use etl::optional with non-default-constructible POD objects.
Modified etl::visitor to allow direct specification of the argument type.
Added etl::is_visitor trait.

View File

@ -157,6 +157,49 @@ namespace
CHECK_EQUAL(0, pdata->value);
}
//*************************************************************************
TEST(test_link_forward_link_get_set)
{
FData data0(0);
FData data1(1);
FData data2(2);
FData data3(3);
// Use reference interface
data0.FLink0::set_next(data1);
data1.FLink0::set_next(data2);
data2.FLink0::set_next(data3);
data3.FLink0::clear();
CHECK(data0.FLink0::get_next() == &data1);
CHECK(data1.FLink0::get_next() == &data2);
CHECK(data2.FLink0::get_next() == &data3);
CHECK(data3.FLink0::get_next() == nullptr);
// Use pointer interface
data3.FLink0::set_next(&data2);
data2.FLink0::set_next(&data1);
data1.FLink0::set_next(&data0);
data0.FLink0::set_next(nullptr);
CHECK(data3.FLink0::get_next() == &data2);
CHECK(data2.FLink0::get_next() == &data1);
CHECK(data1.FLink0::get_next() == &data0);
CHECK(data0.FLink0::get_next() == nullptr);
}
//*************************************************************************
TEST(test_link_forward_link_has_links)
{
FData data0(0);
FData data1(1);
CHECK_FALSE(data0.FLink0::has_next());
data0.FLink0::set_next(data1);
CHECK_TRUE(data0.FLink0::has_next());
}
//*************************************************************************
TEST(test_link_splice_forward_link)
{
@ -344,10 +387,13 @@ namespace
etl::link<FLink1>(data1, data0);
etl::link<FLink1>(data0, nullptr);
etl::unlink_after<FLink0>(data0, data2);
data1.FLink0::clear();
data2.FLink0::clear();
FLink0* start = etl::unlink_after<FLink0>(data0, data2);
CHECK(data0.FLink0::etl_next == &data3);
CHECK(data1.FLink0::etl_next == &data2);
CHECK(data2.FLink0::etl_next == &data3);
CHECK(data3.FLink0::etl_next == nullptr);
etl::link_clear_range(*start);
CHECK(data0.FLink0::etl_next == &data3);
CHECK(data1.FLink0::etl_next == nullptr);
CHECK(data2.FLink0::etl_next == nullptr);
@ -491,6 +537,77 @@ namespace
data2.BLink0::unlink();
}
//*************************************************************************
TEST(test_link_bidirectional_link_get_set)
{
BData data0(0);
BData data1(1);
BData data2(2);
BData data3(3);
// Use reference interface
data0.BLink0::set_next(data1);
data1.BLink0::set_next(data2);
data2.BLink0::set_next(data3);
data1.BLink0::set_previous(data0);
data2.BLink0::set_previous(data1);
data3.BLink0::set_previous(data2);
CHECK(data0.BLink0::get_next() == &data1);
CHECK(data1.BLink0::get_next() == &data2);
CHECK(data2.BLink0::get_next() == &data3);
CHECK(data3.BLink0::get_next() == nullptr);
CHECK(data3.BLink0::get_previous() == &data2);
CHECK(data2.BLink0::get_previous() == &data1);
CHECK(data1.BLink0::get_previous() == &data0);
CHECK(data0.BLink0::get_previous() == nullptr);
// Use pointer interface
data0.BLink0::clear();
data1.BLink0::clear();
data2.BLink0::clear();
data3.BLink0::clear();
data3.BLink0::set_next(&data2);
data2.BLink0::set_next(&data1);
data1.BLink0::set_next(&data0);
data0.BLink0::set_previous(&data1);
data1.BLink0::set_previous(&data2);
data2.BLink0::set_previous(&data3);
CHECK(data3.BLink0::get_next() == &data2);
CHECK(data2.BLink0::get_next() == &data1);
CHECK(data1.BLink0::get_next() == &data0);
CHECK(data0.BLink0::get_next() == nullptr);
CHECK(data0.BLink0::get_previous() == &data1);
CHECK(data1.BLink0::get_previous() == &data2);
CHECK(data2.BLink0::get_previous() == &data3);
CHECK(data3.BLink0::get_previous() == nullptr);
}
//*************************************************************************
TEST(test_link_bidirectional_link_has_links)
{
BData data0(0);
BData data1(1);
BData data2(2);
CHECK_FALSE(data1.BLink0::has_previous());
CHECK_FALSE(data1.BLink0::has_next());
data1.BLink0::set_previous(data0);
CHECK_TRUE(data1.BLink0::has_previous());
CHECK_FALSE(data1.BLink0::has_next());
data1.BLink0::set_next(data2);
CHECK_TRUE(data1.BLink0::has_previous());
CHECK_TRUE(data1.BLink0::has_next());
}
//*************************************************************************
TEST(test_link_splice_bidirectional_link)
{
@ -932,6 +1049,82 @@ namespace
CHECK(data3.TLink1::etl_right == nullptr);
}
//*************************************************************************
TEST(test_link_tree_link_get_set)
{
TData dataParent(0);
TData dataNode(1);
TData dataLeft(2);
TData dataRight(3);
// Use reference interface
dataNode.TLink0::set_parent(dataParent);
dataNode.TLink0::set_left(dataLeft);
dataNode.TLink0::set_right(dataRight);
CHECK(dataNode.TLink0::get_parent() == &dataParent);
CHECK(dataNode.TLink0::get_left() == &dataLeft);
CHECK(dataNode.TLink0::get_right() == &dataRight);
// Use pointer interface
dataNode.TLink0::clear();
dataNode.TLink0::set_parent(&dataParent);
dataNode.TLink0::set_left(&dataLeft);
dataNode.TLink0::set_right(&dataRight);
CHECK(dataNode.TLink0::get_parent() == &dataParent);
CHECK(dataNode.TLink0::get_left() == &dataLeft);
CHECK(dataNode.TLink0::get_right() == &dataRight);
}
//*************************************************************************
TEST(test_link_tree_link_has_links)
{
TData dataParent(0);
TData dataNode(1);
TData dataLeft(2);
TData dataRight(3);
CHECK_FALSE(dataNode.TLink0::has_parent());
CHECK_FALSE(dataNode.TLink0::has_left());
CHECK_FALSE(dataNode.TLink0::has_right());
dataNode.TLink0::set_parent(dataParent);
CHECK_TRUE(dataNode.TLink0::has_parent());
CHECK_FALSE(dataNode.TLink0::has_left());
CHECK_FALSE(dataNode.TLink0::has_right());
dataNode.TLink0::set_left(dataLeft);
CHECK_TRUE(dataNode.TLink0::has_parent());
CHECK_TRUE(dataNode.TLink0::has_left());
CHECK_FALSE(dataNode.TLink0::has_right());
dataNode.TLink0::set_right(dataRight);
CHECK_TRUE(dataNode.TLink0::has_parent());
CHECK_TRUE(dataNode.TLink0::has_left());
CHECK_TRUE(dataNode.TLink0::has_right());
}
//*************************************************************************
TEST(test_link_tree_link_mirror)
{
TData dataParent(0);
TData dataNode(1);
TData dataLeft(2);
TData dataRight(3);
dataNode.TLink0::set_parent(dataParent);
dataNode.TLink0::set_left(dataLeft);
dataNode.TLink0::set_right(dataRight);
dataNode.TLink0::mirror();
CHECK(dataNode.TLink0::get_parent() == &dataParent);
CHECK(dataNode.TLink0::get_left() == &dataRight);
CHECK(dataNode.TLink0::get_right() == &dataLeft);
}
//*************************************************************************
TEST(test_is_linked)
{
@ -1044,13 +1237,13 @@ namespace
CHECK(data3.FLink0::etl_next == nullptr);
CHECK(data3.BLink1::etl_previous == nullptr);
CHECK(data3.BLink1::etl_next == &data2);
CHECK(data3.BLink1::etl_next == &data2);
CHECK(data2.BLink1::etl_previous == &data3);
CHECK(data2.BLink1::etl_next == &data1);
CHECK(data2.BLink1::etl_next == &data1);
CHECK(data1.BLink1::etl_previous == &data2);
CHECK(data1.BLink1::etl_next == &data0);
CHECK(data1.BLink1::etl_next == &data0);
CHECK(data0.BLink1::etl_previous == &data1);
CHECK(data0.BLink1::etl_next == nullptr);
CHECK(data0.BLink1::etl_next == nullptr);
CHECK(data0.TLink2::etl_left == &data1);
CHECK(data0.TLink2::etl_right == &data2);

View File

@ -1122,6 +1122,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1242,6 +1243,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -12989,6 +12991,7 @@
<ClCompile Include="..\test_crc8_wcdma.cpp" />
<ClCompile Include="..\test_expected.cpp" />
<ClCompile Include="..\test_hfsm_recurse_to_inner_state_on_start.cpp" />
<ClCompile Include="..\test_intrusive_links.cpp" />
<ClCompile Include="..\test_message_broker.cpp" />
<ClCompile Include="..\test_poly_span_dynamic_extent.cpp" />
<ClCompile Include="..\test_poly_span_fixed_extent.cpp" />
@ -13295,80 +13298,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\test_intrusive_links.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - Optimised O2|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17 - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - No STL - Optimised -O2|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='LLVM New|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14 - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC - No STL -O2|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14 - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC - No STL -O2|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test1|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM C++20|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test2|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-LLVM-NoSTL-Builtins|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - Optimised O2|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++17 - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release MSVC C++20 - No STL - Optimised -O2|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='LLVM New|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14 - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC - No STL -O2|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++14 - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC - No STL -O2|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test1|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM C++20|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Test2|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-LLVM-NoSTL-Builtins|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\test_intrusive_list.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|Win32'">false</ExcludedFromBuild>

View File

@ -1979,9 +1979,6 @@
<ClCompile Include="..\test_user_type.cpp">
<Filter>Tests\Types</Filter>
</ClCompile>
<ClCompile Include="..\test_intrusive_links.cpp">
<Filter>Tests\Types</Filter>
</ClCompile>
<ClCompile Include="..\test_integral_limits.cpp">
<Filter>Tests\Types</Filter>
</ClCompile>
@ -3416,6 +3413,9 @@
<ClCompile Include="..\test_hfsm_recurse_to_inner_state_on_start.cpp">
<Filter>Tests\State Machines</Filter>
</ClCompile>
<ClCompile Include="..\test_intrusive_links.cpp">
<Filter>Tests\Containers</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">

View File

@ -1 +1 @@
20.36.1
20.37.0