From 6024cf290c4b18afe26d5d42de8ebcbf38914539 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 30 Jan 2025 20:56:46 +0100 Subject: [PATCH 01/28] Default delegate executable (void) --- include/etl/private/delegate_cpp11.h | 25 ++++++++++++++++++++++--- test/test_delegate.cpp | 23 ----------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/etl/private/delegate_cpp11.h b/include/etl/private/delegate_cpp11.h index 0bb8025e1..5b1a3955f 100644 --- a/include/etl/private/delegate_cpp11.h +++ b/include/etl/private/delegate_cpp11.h @@ -368,11 +368,30 @@ namespace etl //************************************************************************* /// Execute the delegate. //************************************************************************* - TReturn operator()(TParams... args) const + template + ETL_CONSTEXPR14 + typename etl::enable_if_t::value> + operator()(TParams... args) const { - ETL_ASSERT(is_valid(), ETL_ERROR(delegate_uninitialised)); + if (is_valid()) + { + (*invocation.stub)(invocation.object, etl::forward(args)...); + } + } - return (*invocation.stub)(invocation.object, etl::forward(args)...); + template + ETL_CONSTEXPR14 + typename etl::enable_if_t::value, TReturn> + operator()(TParams... args) const + { + if (is_valid()) + { + return (*invocation.stub)(invocation.object, etl::forward(args)...); + } + else + { + return {}; + } } //************************************************************************* diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index 302787b52..b66887b2c 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -287,29 +287,6 @@ namespace SUITE(test_delegate) { - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_is_valid_false) - { - etl::delegate d; - - CHECK(!d.is_valid()); - CHECK(!d); - - CHECK_THROW(d(), etl::delegate_uninitialised); - } - - //************************************************************************* -#if ETL_USING_CPP14 - TEST_FIXTURE(SetupFixture, test_constexpr_is_valid_false) - { - constexpr etl::delegate d; - - CHECK(!d.is_valid()); - CHECK(!d); - - CHECK_THROW(d(), etl::delegate_uninitialised); - } -#endif //************************************************************************* TEST_FIXTURE(SetupFixture, test_is_valid_true) From e99433b2d65fed37e8a7d76fa933a66ce4ebd867 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Dec 2024 21:54:25 +0100 Subject: [PATCH 02/28] Add contains() and contains_node() to etl::intrusive_forward_list and etl::intrusive_list --- include/etl/intrusive_forward_list.h | 42 ++++++++++++++++ include/etl/intrusive_list.h | 64 +++++++++++++++++-------- test/test_intrusive_forward_list.cpp | 72 ++++++++++++++++++++++++++++ test/test_intrusive_list.cpp | 72 ++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+), 21 deletions(-) diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 84d0aa94e..11abc6b34 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -253,6 +253,27 @@ namespace etl return current_size; } + //************************************************************************* + /// Detects existence of specified node in list. + ///\param search_link The node to find in list + //************************************************************************* + bool contains_node(const link_type& search_link) const + { + const link_type* p_link = start.etl_next; + + while (p_link != ETL_NULLPTR) + { + if (&search_link == p_link) + { + return true; + } + + p_link = p_link->link_type::etl_next; + } + + return false; + } + protected: link_type start; ///< The link pointer that acts as the intrusive_forward_list start. @@ -1167,6 +1188,27 @@ namespace etl } } + //************************************************************************* + /// Detects existence of specified value in list. + ///\param value The value to find in list + //************************************************************************* + bool contains(const_reference value) const + { + const_iterator i_item = begin(); + + while (i_item != end()) + { + if (*i_item == value) + { + return true; + } + + ++i_item; + } + + return false; + } + private: //************************************************************************* diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 6bbd906f5..1fde59461 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -255,6 +255,27 @@ namespace etl return current_size; } + //************************************************************************* + /// Detects existence of specified node in list. + ///\param search_link The node to find in list + //************************************************************************* + bool contains_node(link_type& search_link) const + { + link_type* p_link = terminal_link.link_type::etl_next; + + while (p_link != &terminal_link) + { + if (&search_link == p_link) + { + return true; + } + + p_link = p_link->link_type::etl_next; + } + + return false; + } + protected: /// The link that acts as the intrusive_list start & end. @@ -376,26 +397,6 @@ namespace etl current_size = 0; } - //************************************************************************* - /// Tests if the link is in this list. - //************************************************************************* - bool is_link_in_list(link_type& search_link) const - { - link_type* p_link = terminal_link.link_type::etl_next; - - while (p_link != &terminal_link) - { - if (&search_link == p_link) - { - return true; - } - - p_link = p_link->link_type::etl_next; - } - - return false; - } - //************************************************************************* /// Remove the specified node from the list. /// Returns ETL_NULLPTR if the link was not in this list or was the last in the list. @@ -404,7 +405,7 @@ namespace etl { link_type* result = ETL_NULLPTR; - if (is_link_in_list(link)) + if (contains_node(link)) { link_type* p_next = link.etl_next; @@ -1192,6 +1193,27 @@ namespace etl } } + //************************************************************************* + /// Detects existence of specified value in list. + ///\param value The value to find in list + //************************************************************************* + bool contains(const_reference value) const + { + const_iterator i_item = begin(); + + while (i_item != end()) + { + if (*i_item == value) + { + return true; + } + + ++i_item; + } + + return false; + } + private: // Disabled. diff --git a/test/test_intrusive_forward_list.cpp b/test/test_intrusive_forward_list.cpp index 20c8d830c..03198fd24 100644 --- a/test/test_intrusive_forward_list.cpp +++ b/test/test_intrusive_forward_list.cpp @@ -1166,5 +1166,77 @@ namespace CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size()); CHECK_EQUAL(size_t(std::distance(compare1.begin(), compare1.end())), data1.size()); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_node) + { + static ItemNDCNode node0("0"); + static ItemNDCNode node1("1"); + static ItemNDCNode node2("2"); + static ItemNDCNode node3("3"); + static ItemNDCNode node4("4"); + static ItemNDCNode node5("5"); + static ItemNDCNode node6("6"); + static ItemNDCNode node7("7"); + static ItemNDCNode node8("8"); + static ItemNDCNode node9("9"); + + DataNDC0 data0; + + data0.push_front(node0); + data0.push_front(node1); + data0.push_front(node2); + data0.push_front(node3); + data0.push_front(node4); + data0.push_front(node5); + + CHECK_TRUE(data0.contains_node(node0)); + CHECK_TRUE(data0.contains_node(node1)); + CHECK_TRUE(data0.contains_node(node2)); + CHECK_TRUE(data0.contains_node(node3)); + CHECK_TRUE(data0.contains_node(node4)); + CHECK_TRUE(data0.contains_node(node5)); + + CHECK_FALSE(data0.contains_node(node6)); + CHECK_FALSE(data0.contains_node(node7)); + CHECK_FALSE(data0.contains_node(node8)); + CHECK_FALSE(data0.contains_node(node9)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains) + { + static ItemNDCNode node0("0"); + static ItemNDCNode node1("1"); + static ItemNDCNode node2("2"); + static ItemNDCNode node3("3"); + static ItemNDCNode node4("4"); + static ItemNDCNode node5("5"); + static ItemNDCNode node6("6"); + static ItemNDCNode node7("7"); + static ItemNDCNode node8("8"); + static ItemNDCNode node9("9"); + + DataNDC0 data0; + + data0.push_front(node0); + data0.push_front(node1); + data0.push_front(node2); + data0.push_front(node3); + data0.push_front(node4); + data0.push_front(node5); + + CHECK_TRUE(data0.contains(ItemNDCNode("0"))); + + ItemNDCNode compare_node1("1"); + + CHECK_TRUE(data0.contains(compare_node1)); + + CHECK_FALSE(data0.contains(ItemNDCNode("6"))); + + ItemNDCNode compare_node2("7"); + + CHECK_FALSE(data0.contains(compare_node2)); + } }; } diff --git a/test/test_intrusive_list.cpp b/test/test_intrusive_list.cpp index 33aa44679..21bd985dc 100644 --- a/test/test_intrusive_list.cpp +++ b/test/test_intrusive_list.cpp @@ -1412,5 +1412,77 @@ namespace CHECK_EQUAL(data0.size(), compare0.size()); CHECK_EQUAL(data1.size(), compare1.size()); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_node) + { + static ItemNDCNode node0("0"); + static ItemNDCNode node1("1"); + static ItemNDCNode node2("2"); + static ItemNDCNode node3("3"); + static ItemNDCNode node4("4"); + static ItemNDCNode node5("5"); + static ItemNDCNode node6("6"); + static ItemNDCNode node7("7"); + static ItemNDCNode node8("8"); + static ItemNDCNode node9("9"); + + DataNDC0 data0; + + data0.push_front(node0); + data0.push_front(node1); + data0.push_front(node2); + data0.push_front(node3); + data0.push_front(node4); + data0.push_front(node5); + + CHECK_TRUE(data0.contains_node(node0)); + CHECK_TRUE(data0.contains_node(node1)); + CHECK_TRUE(data0.contains_node(node2)); + CHECK_TRUE(data0.contains_node(node3)); + CHECK_TRUE(data0.contains_node(node4)); + CHECK_TRUE(data0.contains_node(node5)); + + CHECK_FALSE(data0.contains_node(node6)); + CHECK_FALSE(data0.contains_node(node7)); + CHECK_FALSE(data0.contains_node(node8)); + CHECK_FALSE(data0.contains_node(node9)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains) + { + static ItemNDCNode node0("0"); + static ItemNDCNode node1("1"); + static ItemNDCNode node2("2"); + static ItemNDCNode node3("3"); + static ItemNDCNode node4("4"); + static ItemNDCNode node5("5"); + static ItemNDCNode node6("6"); + static ItemNDCNode node7("7"); + static ItemNDCNode node8("8"); + static ItemNDCNode node9("9"); + + DataNDC0 data0; + + data0.push_front(node0); + data0.push_front(node1); + data0.push_front(node2); + data0.push_front(node3); + data0.push_front(node4); + data0.push_front(node5); + + CHECK_TRUE(data0.contains(ItemNDCNode("0"))); + + ItemNDCNode compare_node1("1"); + + CHECK_TRUE(data0.contains(compare_node1)); + + CHECK_FALSE(data0.contains(ItemNDCNode("6"))); + + ItemNDCNode compare_node2("7"); + + CHECK_FALSE(data0.contains(compare_node2)); + } }; } From 6aaa946b95d383c9e2568e25f8caf7d6c7a146d3 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 6 Feb 2025 11:52:34 +0100 Subject: [PATCH 03/28] Cleanup --- include/etl/bit_stream.h | 6 +++--- include/etl/intrusive_forward_list.h | 6 +----- include/etl/private/delegate_cpp03.h | 10 +++++----- include/etl/vector.h | 1 - 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/etl/bit_stream.h b/include/etl/bit_stream.h index 7c5b557ef..b58c58820 100644 --- a/include/etl/bit_stream.h +++ b/include/etl/bit_stream.h @@ -236,8 +236,8 @@ namespace etl while (nbits != 0) { unsigned char mask_width = static_cast(etl::min(nbits, bits_available_in_char)); - - typedef typename etl::make_unsigned::type chunk_t; + + typedef typename etl::make_unsigned::type chunk_t; chunk_t chunk = get_chunk(mask_width); nbits -= mask_width; @@ -529,7 +529,7 @@ namespace etl typedef char value_type; typedef value_type* iterator; - typedef const value_type* const_iterator; + typedef const value_type* const_iterator; typedef etl::span callback_parameter_type; typedef etl::delegate callback_type; diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 84d0aa94e..00485a124 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -351,11 +351,7 @@ namespace etl } p_previous = p_link; - - if (p_link != ETL_NULLPTR) - { - p_link = p_link->link_type::etl_next; - } + p_link = p_link->link_type::etl_next; } return ETL_NULLPTR; diff --git a/include/etl/private/delegate_cpp03.h b/include/etl/private/delegate_cpp03.h index 250fff6f6..382e6504f 100644 --- a/include/etl/private/delegate_cpp03.h +++ b/include/etl/private/delegate_cpp03.h @@ -66,11 +66,11 @@ namespace etl //*********************************** template struct call_if_impl - { + { etl::optional call_if(TParam param) { - TDelegate& d = static_cast(*this); - + TDelegate& d = static_cast(*this); + etl::optional result; if (d.is_valid()) @@ -88,8 +88,8 @@ namespace etl { bool call_if() { - TDelegate& d = static_cast(*this); - + TDelegate& d = static_cast(*this); + if (d.is_valid()) { d(); diff --git a/include/etl/vector.h b/include/etl/vector.h index 80994bd58..f2c1b6461 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -47,7 +47,6 @@ SOFTWARE. #include "functional.h" #include "static_assert.h" #include "placement_new.h" -#include "algorithm.h" #include "initializer_list.h" #include From bbb58b9d1c94c0c43127d0f6485122d9bdde6af5 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 31 Dec 2024 00:07:04 +0100 Subject: [PATCH 04/28] etl::span: Add advance(), copy(), reinterpret_as() --- include/etl/file_error_numbers.h | 2 + include/etl/span.h | 93 +++++++++++++++++++++++++++ test/test_span_dynamic_extent.cpp | 103 ++++++++++++++++++++++++++++++ test/test_span_fixed_extent.cpp | 70 ++++++++++++++++++++ 4 files changed, 268 insertions(+) diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index 64d94d573..2369f68cf 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -105,4 +105,6 @@ SOFTWARE. #define ETL_BASE64_FILE_ID "72" #define ETL_SINGLETON_BASE_FILE_ID "73" #define ETL_UNALIGNED_TYPE_FILE_ID "74" +#define ETL_SPAN_FILE_ID "75" + #endif diff --git a/include/etl/span.h b/include/etl/span.h index 8d03e5fba..7e4ad35ad 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -32,6 +32,10 @@ SOFTWARE. #define ETL_SPAN_INCLUDED #include "platform.h" + +#include "error_handler.h" +#include "exception.h" +#include "alignment.h" #include "iterator.h" #include "algorithm.h" #include "circular_iterator.h" @@ -55,6 +59,34 @@ SOFTWARE. namespace etl { + //*************************************************************************** + ///\ingroup span + /// Exception base for span + //*************************************************************************** + class span_exception : public exception + { + public: + + span_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + ///\ingroup span + /// Bad alignment exception. + //*************************************************************************** + class span_alignment_exception : public span_exception + { + public: + + span_alignment_exception(string_type file_name_, numeric_type line_number_) + : span_exception(ETL_ERROR_TEXT("span:alignment", ETL_SPAN_FILE_ID"A"), file_name_, line_number_) + { + } + }; + //*************************************************************************** /// Span - Fixed Extent //*************************************************************************** @@ -426,6 +458,18 @@ namespace etl : etl::span(pbegin + offset, pbegin + offset + count); } + //************************************************************************* + /// Reinterpret the span as a span with different element type. + //************************************************************************* + template + ETL_NODISCARD ETL_CONSTEXPR14 etl::span reinterpret_as() const + { + ETL_ASSERT(etl::is_aligned::value>(pbegin), ETL_ERROR(span_alignment_exception)); + + return etl::span(reinterpret_cast(pbegin), + Extent * sizeof(element_type) / sizeof(TNew)); + } + private: pointer pbegin; @@ -812,6 +856,28 @@ namespace etl : etl::span(pbegin + offset, pbegin + offset + count); } + //************************************************************************* + /// Moves the pointer to the first element of the span further by a specified number of elements. + ///\tparam elements Number of elements to move forward + //************************************************************************* + void advance(size_t elements) ETL_NOEXCEPT + { + elements = etl::min(elements, size()); + pbegin += elements; + } + + //************************************************************************* + /// Reinterpret the span as a span with different element type. + //************************************************************************* + template + ETL_NODISCARD ETL_CONSTEXPR14 etl::span reinterpret_as() const + { + ETL_ASSERT(etl::is_aligned::value>(pbegin), ETL_ERROR(span_alignment_exception)); + + return etl::span(reinterpret_cast(pbegin), + (pend - pbegin) * sizeof(element_type) / sizeof(TNew)); + } + private: pointer pbegin; @@ -884,6 +950,33 @@ namespace etl etl::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } + //************************************************************************* + /// Copy complete element data from one span to another. If the destination + /// span is bigger than the source span, only the initial part of + /// destination span is overwritten. + ///\param src Source + ///\param dst Destination + ///\return true, if copy was successful (including empty source span, or + /// spans pointing to the same address) + ///\return false, if the destination span is shorter than the source span. + //************************************************************************* + template + typename etl::enable_if::type, typename etl::remove_cv::type>::value && + !etl::is_const::value, bool>::type + copy(const etl::span& src, const etl::span& dst) + { + if (src.empty() || (src.begin() == dst.begin())) + { + return true; + } + if (src.size() > dst.size()) + { + return false; + } + (void) etl::copy(src.begin(), src.end(), dst.begin()); + return true; + } + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index dd71bae22..14d2c9559 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -30,6 +30,7 @@ SOFTWARE. #include "etl/span.h" #include "etl/array.h" +#include "etl/unaligned_type.h" #include #include @@ -1244,6 +1245,108 @@ namespace } } + //************************************************************************* + TEST(test_advance) + { + { + uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = data; + + CHECK_EQUAL(data0.size(), 5); + data0.advance(1); + CHECK_EQUAL(data0.size(), 4); + CHECK_EQUAL(data0[0], 0x02); + data0.advance(2); + CHECK_EQUAL(data0.size(), 2); + CHECK_EQUAL(data0[0], 0x04); + data0.advance(1); + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data0[0], 0x05); + data0.advance(1); + CHECK_EQUAL(data0.size(), 0); + } + { + const uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = data; + + CHECK_EQUAL(data0.size(), 5); + data0.advance(1); + CHECK_EQUAL(data0.size(), 4); + CHECK_EQUAL(data0[0], 0x02); + data0.advance(2); + CHECK_EQUAL(data0.size(), 2); + CHECK_EQUAL(data0[0], 0x04); + data0.advance(1); + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data0[0], 0x05); + data0.advance(1); + CHECK_EQUAL(data0.size(), 0); + data0.advance(1); + CHECK_EQUAL(data0.size(), 0); + data0.advance(100); + CHECK_EQUAL(data0.size(), 0); + } + } + + //************************************************************************* + TEST(test_reinterpret_as) + { + uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = data; + + etl::span data1 = data0.reinterpret_as(); + + CHECK_EQUAL(data1.size(), 2); + CHECK(data1[0] == 0x102); + CHECK(data1[1] == 0x304); + } + + //************************************************************************* + TEST(test_reinterpret_as_aligned) + { + uint32_t data[] = { 0x01020304, 0x020406080, 0x03400560}; + etl::span data0 = data; + CHECK_EQUAL(data0.size(), 3); + + etl::span data1 = data0.reinterpret_as(); + CHECK_EQUAL(data1.size(), 12); + + etl::span data2 = data1.subspan(2).reinterpret_as(); + CHECK_EQUAL(data2.size(), 5); + + CHECK_THROW(data2 = data1.subspan(1).reinterpret_as(), etl::span_alignment_exception); + } + + //************************************************************************* + TEST(test_copy) + { + uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + uint8_t dst[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + etl::span data0 = src; + etl::span data1 = dst; + + CHECK_EQUAL(etl::copy(data0, data1), true); + CHECK(std::equal(data0.begin(), data0.end(), data1.begin())); + + data1 = data1.subspan(1); + + CHECK_EQUAL(etl::copy(data0, data1), true); + CHECK(std::equal(data0.begin(), data0.end(), data1.begin())); + + data1 = data1.subspan(1); + + CHECK_EQUAL(etl::copy(data0, data1), false); + + data0 = data0.subspan(0, 0); + + CHECK_EQUAL(etl::copy(data0, data1), true); + + data0 = src; + data1 = src; + + CHECK_EQUAL(etl::copy(data0, data1), true); + } + #include "etl/private/diagnostic_pop.h" }; } diff --git a/test/test_span_fixed_extent.cpp b/test/test_span_fixed_extent.cpp index 640126eea..1440fde70 100644 --- a/test/test_span_fixed_extent.cpp +++ b/test/test_span_fixed_extent.cpp @@ -30,6 +30,7 @@ SOFTWARE. #include "etl/span.h" #include "etl/array.h" +#include "etl/unaligned_type.h" #include #include @@ -1166,6 +1167,75 @@ namespace } } + //************************************************************************* + TEST(test_reinterpret_as) + { + uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = data; + + etl::span data1 = data0.reinterpret_as(); + + CHECK_EQUAL(data1.size(), 2); + CHECK(data1[0] == 0x102); + CHECK(data1[1] == 0x304); + } + + //************************************************************************* + TEST(test_reinterpret_as_aligned) + { + uint32_t data[] = { 0x01020304, 0x020406080, 0x03400560}; + etl::span data0 = data; + CHECK_EQUAL(data0.size(), 3); + + etl::span data1 = data0.reinterpret_as(); + CHECK_EQUAL(data1.size(), 12); + + etl::span data2 = data1.subspan(2).reinterpret_as(); + CHECK_EQUAL(data2.size(), 5); + + CHECK_THROW(data2 = data1.subspan(1).reinterpret_as(), etl::span_alignment_exception); + } + + //************************************************************************* + TEST(test_copy) + { + uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + uint8_t dst[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + { + etl::span data0 = src; + etl::span data1 = dst; + + CHECK_EQUAL(etl::copy(data0, data1), true); + CHECK(std::equal(data0.begin(), data0.end(), data1.begin())); + } + { + etl::span data0 = src; + etl::span data1(&dst[1], 5); + + CHECK_EQUAL(etl::copy(data0, data1), true); + CHECK(std::equal(data0.begin(), data0.end(), data1.begin())); + } + + { + etl::span data0 = src; + etl::span data1(&dst[2], 4); + + CHECK_EQUAL(etl::copy(data0, data1), false); + } + { + etl::span data0(&src[0], 0); + etl::span data1 = dst; + + CHECK_EQUAL(etl::copy(data0, data1), true); + } + { + etl::span data0 = src; + etl::span data1 = src; + + CHECK_EQUAL(etl::copy(data0, data1), true); + } + } + #include "etl/private/diagnostic_pop.h" }; } From 9bf2733161a651de698f5ae27659e0542acf8246 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 2 Mar 2025 22:00:26 +0100 Subject: [PATCH 05/28] Added further tests for span::reinterpret_as --- test/test_span_dynamic_extent.cpp | 35 +++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index 14d2c9559..ee85f843b 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -1291,14 +1291,37 @@ namespace //************************************************************************* TEST(test_reinterpret_as) { - uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; - etl::span data0 = data; + { + uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = data; - etl::span data1 = data0.reinterpret_as(); + etl::span data1 = data0.reinterpret_as(); - CHECK_EQUAL(data1.size(), 2); - CHECK(data1[0] == 0x102); - CHECK(data1[1] == 0x304); + CHECK_EQUAL(data1.size(), 2); + CHECK(data1[0] == 0x102); + CHECK(data1[1] == 0x304); + } + { + uint32_t data[] = { 0x01020304 }; + etl::span data0 = data; + etl::span data1 = data0.reinterpret_as(); + data1 = data1.first(3); + etl::span data2 = data1.reinterpret_as(); + CHECK_EQUAL(data2.size(), 0); + } + { + uint32_t data[] = { 0x01020304, 0x06070809 }; + etl::span data0 = data; + etl::span data1 = data0.reinterpret_as(); + data1 = data1.first(6); + etl::span data2 = data1.reinterpret_as(); + CHECK_EQUAL(data2.size(), 1); + + auto it = data2.begin(); + CHECK_NOT_EQUAL(it, data2.end()); + ++it; + CHECK_EQUAL(it, data2.end()); + } } //************************************************************************* From f8a70ed49a8114682d77f0680e5e60ac04567018 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 2 Mar 2025 22:34:37 +0100 Subject: [PATCH 06/28] Fix size of unaligned_type on Windows Multiple inheritance leads to additional 1 byte for the second base class. Fixing it by not inheriting but aggregating via typedef. --- include/etl/unaligned_type.h | 36 +++++++++++++++++++----------------- test/test_unaligned_type.cpp | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/include/etl/unaligned_type.h b/include/etl/unaligned_type.h index 8910f864d..87519dbff 100644 --- a/include/etl/unaligned_type.h +++ b/include/etl/unaligned_type.h @@ -449,7 +449,6 @@ namespace etl //************************************************************************* template ETL_PACKED_CLASS(unaligned_type) : public private_unaligned_type::unaligned_type_storage - , public private_unaligned_type::unaligned_copy::value ? false : true> { public: @@ -457,6 +456,8 @@ namespace etl typedef T value_type; + typedef private_unaligned_type::unaligned_copy::value ? false : true> unaligned_copy; + typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; @@ -480,7 +481,7 @@ namespace etl //************************************************************************* unaligned_type(T value) { - this->copy_value_to_store(value, this->storage); + unaligned_copy::copy_value_to_store(value, this->storage); } //************************************************************************* @@ -506,7 +507,7 @@ namespace etl //************************************************************************* unaligned_type(const unaligned_type& other) { - this->copy_store_to_store(other.data(), Endian, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian, this->storage); } //************************************************************************* @@ -515,7 +516,7 @@ namespace etl template unaligned_type(const unaligned_type& other) { - this->copy_store_to_store(other.data(), Endian_Other, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian_Other, this->storage); } //************************************************************************* @@ -523,7 +524,7 @@ namespace etl //************************************************************************* unaligned_type& operator =(T value) { - this->copy_value_to_store(value, this->storage); + unaligned_copy::copy_value_to_store(value, this->storage); return *this; } @@ -533,7 +534,7 @@ namespace etl //************************************************************************* unaligned_type& operator =(const unaligned_type& other) { - this->copy_store_to_store(other.data(), Endian_, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian_, this->storage); return *this; } @@ -544,7 +545,7 @@ namespace etl template unaligned_type& operator =(const unaligned_type& other) { - this->copy_store_to_store(other.data(), Endian_Other, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian_Other, this->storage); return *this; } @@ -556,7 +557,7 @@ namespace etl { T value = T(); - this->copy_store_to_value(this->storage, value); + unaligned_copy::copy_store_to_value(this->storage, value); return value; } @@ -568,7 +569,7 @@ namespace etl { T value = T(); - this->copy_store_to_value(this->storage, value); + unaligned_copy::copy_store_to_value(this->storage, value); return value; } @@ -589,7 +590,6 @@ namespace etl //************************************************************************* template ETL_PACKED_CLASS(unaligned_type_ext) : public private_unaligned_type::unaligned_type_storage_ext - , public private_unaligned_type::unaligned_copy::value ? false : true> { public: @@ -600,6 +600,8 @@ namespace etl typedef T value_type; + typedef private_unaligned_type::unaligned_copy::value ? false : true> unaligned_copy; + typedef typename private_unaligned_type::unaligned_type_storage_ext::storage_type storage_type; typedef typename private_unaligned_type::unaligned_type_storage_ext::pointer pointer; typedef typename private_unaligned_type::unaligned_type_storage_ext::const_pointer const_pointer; @@ -625,7 +627,7 @@ namespace etl unaligned_type_ext(T value, pointer storage_) : private_unaligned_type::unaligned_type_storage_ext(storage_) { - this->copy_value_to_store(value, this->storage); + unaligned_copy::copy_value_to_store(value, this->storage); } //************************************************************************* @@ -635,7 +637,7 @@ namespace etl unaligned_type_ext(const unaligned_type_ext& other, pointer storage_) : private_unaligned_type::unaligned_type_storage_ext(storage_) { - this->copy_store_to_store(other.data(), Endian_Other, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian_Other, this->storage); } #if ETL_USING_CPP11 @@ -670,7 +672,7 @@ namespace etl //************************************************************************* unaligned_type_ext& operator =(T value) { - this->copy_value_to_store(value, this->storage); + unaligned_copy::copy_value_to_store(value, this->storage); return *this; } @@ -680,7 +682,7 @@ namespace etl //************************************************************************* unaligned_type_ext& operator =(const unaligned_type_ext& other) { - this->copy_store_to_store(other.data(), Endian, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian, this->storage); return *this; } @@ -691,7 +693,7 @@ namespace etl template unaligned_type_ext& operator =(const unaligned_type_ext& other) { - this->copy_store_to_store(other.data(), Endian_Other, this->storage); + unaligned_copy::copy_store_to_store(other.data(), Endian_Other, this->storage); return *this; } @@ -735,7 +737,7 @@ namespace etl { T value = T(); - this->copy_store_to_value(this->storage, value); + unaligned_copy::copy_store_to_value(this->storage, value); return value; } @@ -747,7 +749,7 @@ namespace etl { T value = T(); - this->copy_store_to_value(this->storage, value); + unaligned_copy::copy_store_to_value(this->storage, value); return value; } diff --git a/test/test_unaligned_type.cpp b/test/test_unaligned_type.cpp index be9ea1ec8..e80eeaebe 100644 --- a/test/test_unaligned_type.cpp +++ b/test/test_unaligned_type.cpp @@ -208,6 +208,16 @@ namespace CHECK_EQUAL(sizeof(uint32_t), etl::le_uint32_t::Size); CHECK_EQUAL(sizeof(int64_t), etl::le_int64_t::Size); CHECK_EQUAL(sizeof(uint64_t), etl::le_uint64_t::Size); + + // check if net size equals gross size on platform + CHECK_EQUAL(sizeof(int8_t), sizeof(etl::le_int8_t)); + CHECK_EQUAL(sizeof(uint8_t), sizeof(etl::le_uint8_t)); + CHECK_EQUAL(sizeof(int16_t), sizeof(etl::le_int16_t)); + CHECK_EQUAL(sizeof(uint16_t), sizeof(etl::le_uint16_t)); + CHECK_EQUAL(sizeof(int32_t), sizeof(etl::le_int32_t)); + CHECK_EQUAL(sizeof(uint32_t), sizeof(etl::le_uint32_t)); + CHECK_EQUAL(sizeof(int64_t), sizeof(etl::le_int64_t)); + CHECK_EQUAL(sizeof(uint64_t), sizeof(etl::le_uint64_t)); } //************************************************************************* @@ -236,6 +246,16 @@ namespace CHECK_EQUAL(sizeof(uint32_t), etl::be_uint32_t::Size); CHECK_EQUAL(sizeof(int64_t), etl::be_int64_t::Size); CHECK_EQUAL(sizeof(uint64_t), etl::be_uint64_t::Size); + + // check if net size equals gross size on platform + CHECK_EQUAL(sizeof(int8_t), sizeof(etl::be_int8_t)); + CHECK_EQUAL(sizeof(uint8_t), sizeof(etl::be_uint8_t)); + CHECK_EQUAL(sizeof(int16_t), sizeof(etl::be_int16_t)); + CHECK_EQUAL(sizeof(uint16_t), sizeof(etl::be_uint16_t)); + CHECK_EQUAL(sizeof(int32_t), sizeof(etl::be_int32_t)); + CHECK_EQUAL(sizeof(uint32_t), sizeof(etl::be_uint32_t)); + CHECK_EQUAL(sizeof(int64_t), sizeof(etl::be_int64_t)); + CHECK_EQUAL(sizeof(uint64_t), sizeof(etl::be_uint64_t)); } //************************************************************************* From c66fe321045f0d81c292780d429f5710034eece0 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 2 Jan 2025 23:20:23 +0100 Subject: [PATCH 07/28] Added iterator and const_iterator to etl::ipool --- include/etl/ipool.h | 190 +++++++++++++++++++++++++++++++++ test/test_pool.cpp | 251 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 441 insertions(+) diff --git a/include/etl/ipool.h b/include/etl/ipool.h index 942927748..fb7982bd4 100644 --- a/include/etl/ipool.h +++ b/include/etl/ipool.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "error_handler.h" #include "exception.h" +#include "iterator.h" #include "static_assert.h" #include "utility.h" #include "memory.h" @@ -104,6 +105,189 @@ namespace etl typedef size_t size_type; + private: + + //*************************************************************************** + /// Iterator helper functions + //*************************************************************************** + + const char* buffer_end() const + { + return p_buffer + Item_Size * items_initialised; + } + + //*************************************************************************** + /// Optimization: a candidate for being in free list, but no guarantee + /// if false, cannot be part of free list, and therefore is allocated + /// if true, possibly in free list, but still needs to be checked via free list + //*************************************************************************** + bool is_pointing_into_pool_or_end_or_nullptr(const char *address) const + { + return address == ETL_NULLPTR || (p_buffer <= address && address <= buffer_end()); + } + + //*************************************************************************** + /// Iterate free list to confirm specified address is included or not + //*************************************************************************** + bool is_in_free_list(const char* address) const + { + const char* i = p_next; + while (i != ETL_NULLPTR) + { + if (address == i) + { + return true; + } + i = *reinterpret_cast(i); + } + return false; + } + + public: + + template + class ipool_iterator + { + public: + + friend class ipool; + + typedef typename etl::conditional::type value_type; + typedef typename etl::conditional::type reference; + typedef typename etl::conditional::type pointer; + typedef ptrdiff_t difference_type; + typedef ETL_OR_STD::forward_iterator_tag iterator_category; + typedef typename etl::conditional::type void_type; + typedef typename etl::conditional::type pool_type; + typedef typename etl::conditional::type pointer_type; + + ipool_iterator(const ipool_iterator& other): + p_current(other.p_current), + p_pool(other.p_pool) + { + find_allocated(); + } + + ipool_iterator& operator ++() + { + p_current = p_current + p_pool->Item_Size; + find_allocated(); + return *this; + } + + ipool_iterator operator ++(int) + { + ipool_iterator temp(*this); + p_current = p_current + p_pool->Item_Size; + find_allocated(); + return temp; + } + + ipool_iterator& operator =(const ipool_iterator& other) + { + p_current = other.p_current; + p_pool = other.p_pool; + return *this; + } + + void_type operator *() const + { + return p_current; + } + + template + T& get() const + { + return *reinterpret_cast(p_current); + } + + friend bool operator == (const ipool_iterator& lhs, const ipool_iterator& rhs) + { + return lhs.p_current == rhs.p_current; + } + + friend bool operator != (const ipool_iterator& lhs, const ipool_iterator& rhs) + { + return !(lhs == rhs); + } + + private: + + //*************************************************************************** + /// find allocated item by increasing p_current, starting at p_current + /// leave p_current at buffer_end() if no further allocated item found + //*************************************************************************** + void find_allocated() + { + while (p_current < p_pool->buffer_end()) + { + value_type value = *reinterpret_cast(p_current); + if (!p_pool->is_pointing_into_pool_or_end_or_nullptr(value)) + { + return; + } + if (!p_pool->is_in_free_list(p_current)) + { + return; + } + p_current += p_pool->Item_Size; + } + } + + ipool_iterator(value_type p, pool_type* pool_): + p_current(p), + p_pool(pool_) + { + find_allocated(); + } + + value_type p_current; + pool_type* p_pool; + }; + + template + friend class ipool_iterator; + + typedef ipool_iterator iterator; + + class const_iterator : public ipool_iterator + { + public: + const_iterator(const ipool_iterator& other) : ipool_iterator(other) {} + const_iterator(const ipool_iterator& other) : ipool_iterator(other.p_current, other.p_pool) {} + const_iterator(value_type p, pool_type* pool_) : ipool_iterator(p, pool_) {} + }; + + iterator begin() + { + return iterator(p_buffer, this); + } + + iterator end() + { + return iterator(p_buffer + Item_Size * items_initialised, this); + } + + const_iterator begin() const + { + return const_iterator(p_buffer, this); + } + + const_iterator end() const + { + return const_iterator(p_buffer + Item_Size * items_initialised, this); + } + + const_iterator cbegin() const + { + return const_iterator(p_buffer, this); + } + + const_iterator cend() const + { + return const_iterator(p_buffer + Item_Size * items_initialised, this); + } + //************************************************************************* /// Allocate storage for an object from the pool. /// If asserts or exceptions are enabled and there are no more free items an @@ -337,6 +521,7 @@ namespace etl } private: + static ETL_CONSTEXPR uintptr_t invalid_item_ptr = 1; //************************************************************************* /// Allocate an item from the pool. @@ -371,6 +556,11 @@ namespace etl // No more left! p_next = ETL_NULLPTR; } + + // invalid pointer, outside pool + // needs to be different from ETL_NULLPTR since ETL_NULLPTR is used + // as list endmarker + *reinterpret_cast(p_value) = invalid_item_ptr; } else { diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 2866ab1d0..c74425aa1 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -34,6 +34,7 @@ SOFTWARE. #include #include +#include "etl/unaligned_type.h" #include "etl/pool.h" #include "etl/largest.h" @@ -484,4 +485,254 @@ namespace CHECK_EQUAL(3, memPool.available()); CHECK_EQUAL(0, memPool.size()); } + + //************************************************************************* + TEST(test_iterators) + { + etl::pool pool0; + + etl::ipool::iterator begin = pool0.begin(); + etl::ipool::iterator end = pool0.end(); + + CHECK(begin == end); + CHECK(!(begin != end)); + CHECK_EQUAL(etl::distance(begin, end), 0); + + int* a = pool0.allocate(); + *a = 1; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 1); + + int* b = pool0.allocate(); + *b = 2; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + // post increment + for (auto i = pool0.begin(); i != pool0.end(); i++) + { + CHECK(*reinterpret_cast(*i) == 1 || *reinterpret_cast(*i) == 2); + } + + // pre increment + for (auto i = pool0.begin(); i != pool0.end(); ++i) + { + CHECK(*reinterpret_cast(*i) == 1 || *reinterpret_cast(*i) == 2); + } + + int* c = pool0.allocate(); + *c = 3; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + pool0.release(b); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + int* d = pool0.allocate(); + *d = 4; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + b = pool0.allocate(); + *b = 2; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 4); + + // post increment + for (auto i = pool0.begin(); i != pool0.end(); i++) + { + CHECK(*reinterpret_cast(*i) >= 1 && *reinterpret_cast(*i) <= 4); + } + + // pre increment + for (auto i = pool0.begin(); i != pool0.end(); ++i) + { + CHECK(*reinterpret_cast(*i) >= 1 && *reinterpret_cast(*i) <= 4); + } + + pool0.release(b); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + pool0.release(a); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + pool0.release(d); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 1); + + auto& v = begin.get(); + v = 1; + + pool0.release(c); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin == end); + CHECK(!(begin != end)); + CHECK_EQUAL(etl::distance(begin, end), 0); + } + + //************************************************************************* + TEST(test_const_iterators) + { + etl::pool pool0; + + etl::ipool::const_iterator begin = pool0.begin(); + etl::ipool::const_iterator end = pool0.end(); + + CHECK(begin == end); + CHECK(!(begin != end)); + CHECK_EQUAL(etl::distance(begin, end), 0); + + int* a = pool0.allocate(); + *a = 1; + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 1); + + int* b = pool0.allocate(); + *b = 2; + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + // post increment + for (auto i = pool0.begin(); i != pool0.end(); i++) + { + CHECK(*reinterpret_cast(*i) == 1 || *reinterpret_cast(*i) == 2); + } + + // pre increment + for (auto i = pool0.begin(); i != pool0.end(); ++i) + { + CHECK(*reinterpret_cast(*i) == 1 || *reinterpret_cast(*i) == 2); + } + + int* c = pool0.allocate(); + *c = 3; + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + pool0.release(b); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + int* d = pool0.allocate(); + *d = 4; + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + b = pool0.allocate(); + *b = 2; + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 4); + + // post increment + for (auto i = pool0.begin(); i != pool0.end(); i++) + { + CHECK(*reinterpret_cast(*i) >= 1 && *reinterpret_cast(*i) <= 4); + } + + // pre increment + for (auto i = pool0.cbegin(); i != pool0.cend(); ++i) + { + CHECK(*reinterpret_cast(*i) >= 1 && *reinterpret_cast(*i) <= 4); + } + + pool0.release(b); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 3); + + pool0.release(a); + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 2); + + pool0.release(d); + + begin = pool0.begin(); + end = pool0.end(); + CHECK(begin != end); + CHECK(!(begin == end)); + CHECK_EQUAL(etl::distance(begin, end), 1); + + const auto& v = begin.get(); + CHECK(v != 0); + + pool0.release(c); + + begin = pool0.cbegin(); + end = pool0.cend(); + CHECK(begin == end); + CHECK(!(begin != end)); + CHECK_EQUAL(etl::distance(begin, end), 0); + } } From c60e30417fbe8dd260e721545a180637419e539c Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 5 Mar 2025 10:52:29 +0100 Subject: [PATCH 08/28] Adjusted source code format --- include/etl/ipool.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/etl/ipool.h b/include/etl/ipool.h index fb7982bd4..141cdc7e0 100644 --- a/include/etl/ipool.h +++ b/include/etl/ipool.h @@ -161,9 +161,9 @@ namespace etl typedef typename etl::conditional::type pool_type; typedef typename etl::conditional::type pointer_type; - ipool_iterator(const ipool_iterator& other): - p_current(other.p_current), - p_pool(other.p_pool) + ipool_iterator(const ipool_iterator& other) + : p_current(other.p_current) + , p_pool(other.p_pool) { find_allocated(); } @@ -234,9 +234,9 @@ namespace etl } } - ipool_iterator(value_type p, pool_type* pool_): - p_current(p), - p_pool(pool_) + ipool_iterator(value_type p, pool_type* pool_) + : p_current(p) + , p_pool(pool_) { find_allocated(); } From 54874afb0f20c1cfd24c015855c9d57274598daf Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 5 Mar 2025 15:59:40 +0100 Subject: [PATCH 09/28] Simplify default return --- include/etl/private/delegate_cpp11.h | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/include/etl/private/delegate_cpp11.h b/include/etl/private/delegate_cpp11.h index 5b1a3955f..8c79e7c3e 100644 --- a/include/etl/private/delegate_cpp11.h +++ b/include/etl/private/delegate_cpp11.h @@ -368,30 +368,15 @@ namespace etl //************************************************************************* /// Execute the delegate. //************************************************************************* - template - ETL_CONSTEXPR14 - typename etl::enable_if_t::value> - operator()(TParams... args) const - { - if (is_valid()) - { - (*invocation.stub)(invocation.object, etl::forward(args)...); - } - } - - template ETL_CONSTEXPR14 - typename etl::enable_if_t::value, TReturn> - operator()(TParams... args) const + TReturn operator()(TParams... args) const { if (is_valid()) { return (*invocation.stub)(invocation.object, etl::forward(args)...); } - else - { - return {}; - } + + return TReturn{}; } //************************************************************************* From 2e16e5b3f5a5eed1e5d86a5b63149477d7f5007a Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 5 Mar 2025 17:57:49 +0100 Subject: [PATCH 10/28] Fix return value --- include/etl/private/delegate_cpp11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/private/delegate_cpp11.h b/include/etl/private/delegate_cpp11.h index 8c79e7c3e..967cb42a2 100644 --- a/include/etl/private/delegate_cpp11.h +++ b/include/etl/private/delegate_cpp11.h @@ -376,7 +376,7 @@ namespace etl return (*invocation.stub)(invocation.object, etl::forward(args)...); } - return TReturn{}; + return TReturn(); } //************************************************************************* From faa7f4c5702f3ed1f89e88f15cf664bf857b7435 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 5 Mar 2025 18:06:02 +0100 Subject: [PATCH 11/28] Re-add tests --- test/test_delegate.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index b66887b2c..0ce8b5792 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -287,6 +287,29 @@ namespace SUITE(test_delegate) { + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_is_valid_false) + { + etl::delegate d; + + CHECK(!d.is_valid()); + CHECK(!d); + + d(); + } + + //************************************************************************* +#if ETL_USING_CPP14 + TEST_FIXTURE(SetupFixture, test_constexpr_is_valid_false) + { + constexpr etl::delegate d; + + CHECK(!d.is_valid()); + CHECK(!d); + + d(); + } +#endif //************************************************************************* TEST_FIXTURE(SetupFixture, test_is_valid_true) From 1cdf747f77720286ffad7b2d505d24273e91c0e5 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 4 Mar 2025 20:44:54 +0100 Subject: [PATCH 12/28] Add traits to type_list --- include/etl/type_list.h | 91 +++++++++++++++++++++ test/CMakeLists.txt | 1 + test/test_type_list.cpp | 172 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 test/test_type_list.cpp diff --git a/include/etl/type_list.h b/include/etl/type_list.h index 533ae7618..556787abe 100644 --- a/include/etl/type_list.h +++ b/include/etl/type_list.h @@ -30,7 +30,10 @@ SOFTWARE. #define ETL_TYPE_LIST_INCLUDED #include "platform.h" + +#include "algorithm.h" #include "nth_type.h" +#include "integral_limits.h" #include "static_assert.h" #include "type_traits.h" #include "utility.h" @@ -38,6 +41,9 @@ SOFTWARE. #if ETL_USING_CPP11 namespace etl { + + static ETL_CONSTEXPR size_t type_list_npos = etl::integral_limits::max; + //*************************************************************************** /// Type list forward declaration. //*************************************************************************** @@ -61,6 +67,18 @@ namespace etl type_list& operator =(const type_list&) ETL_DELETE; }; + namespace private_type_list + { + + // helper to solve the issue that recursed-rest can't be put directly in type_list::tail definition + template + struct recursion_helper + { + using type = type_list; + }; + + } + //*************************************************************************** /// Recursive type list implementation for multiple types. //*************************************************************************** @@ -68,6 +86,7 @@ namespace etl struct type_list : type_list { using type = THead; + using tail = typename private_type_list::recursion_helper::type; static constexpr size_t size = sizeof...(TTail) + 1U; @@ -87,6 +106,7 @@ namespace etl struct type_list : type_list<> { using type = THead; + using tail = typename private_type_list::recursion_helper<>::type; static constexpr size_t size = 1U; @@ -180,6 +200,77 @@ namespace etl { using type = typename type_list_cat, TTail...>::type; }; + + template + struct type_list_contains + : public etl::integral_constant::value ? true : type_list_contains::value> + { + }; + + template + struct type_list_contains, T> + : public etl::integral_constant + { + }; + +#if ETL_USING_CPP17 + template + inline constexpr bool type_list_contains_v = etl::type_list_contains::value; +#endif + + template + struct type_list_index_of + : public etl::integral_constant::value ? 0 : + (type_list_index_of::value == type_list_npos ? + type_list_npos : type_list_index_of::value + 1)> + { + }; + + template + struct type_list_index_of, T> + : public etl::integral_constant + { + }; + +#if ETL_USING_CPP17 + template + inline constexpr size_t type_list_index_of_v = etl::type_list_index_of::value; +#endif + + template + struct type_list_max_sizeof_type + : public etl::integral_constant::value)> + { + }; + + template<> + struct type_list_max_sizeof_type> + : public etl::integral_constant + { + }; + +#if ETL_USING_CPP17 + template + inline constexpr size_t type_list_max_sizeof_type_v = etl::type_list_max_sizeof_type::value; +#endif + + template + struct type_list_max_alignment + : public etl::integral_constant::value, + type_list_max_alignment::value)> + { + }; + + template<> + struct type_list_max_alignment> + : public etl::integral_constant + { + }; + +#if ETL_USING_CPP17 + template + inline constexpr size_t type_list_max_alignment_v = etl::type_list_max_alignment::value; +#endif } #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bcc8a0da7..d2641ab5f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -286,6 +286,7 @@ add_executable(etl_tests test_to_u8string.cpp test_to_wstring.cpp test_type_def.cpp + test_type_list.cpp test_type_lookup.cpp test_type_select.cpp test_type_traits.cpp diff --git a/test/test_type_list.cpp b/test/test_type_list.cpp new file mode 100644 index 000000000..44f197f8f --- /dev/null +++ b/test/test_type_list.cpp @@ -0,0 +1,172 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/type_list.h" + +#include + +namespace +{ +#if ETL_USING_CPP11 + SUITE(test_type_list) + { + //************************************************************************* + TEST(test_nth_type) + { + typedef etl::type_list t1; + + CHECK_TRUE((std::is_same::type, char>::value)); + CHECK_TRUE((std::is_same::type, int>::value)); + CHECK_TRUE((std::is_same::type, uint32_t>::value)); + } + + //************************************************************************* + TEST(test_type_list_select) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + + CHECK_TRUE((std::is_same::type, t2>::value)); + } + + //************************************************************************* + TEST(test_type_list_size) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + + CHECK_EQUAL(etl::type_list_size::value, 3); + CHECK_EQUAL(etl::type_list_size::value, 2); + } + + //************************************************************************* + TEST(test_type_list_cat) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + + typedef etl::type_list t_cat1; + typedef etl::type_list t_cat2; + + CHECK_TRUE((std::is_same::type, t_cat1>::value)); + CHECK_FALSE((std::is_same::type, t_cat2>::value)); + } + + //************************************************************************* + TEST(test_type_list_contains) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + typedef etl::type_list t3; + typedef etl::type_list<> t4; + + CHECK_TRUE((etl::type_list_contains::value)); + CHECK_FALSE((etl::type_list_contains::value)); + CHECK_FALSE((etl::type_list_contains::value)); + CHECK_TRUE((etl::type_list_contains::value)); + CHECK_TRUE((etl::type_list_contains::value)); + CHECK_FALSE((etl::type_list_contains::value)); + CHECK_FALSE((etl::type_list_contains::value)); + +#if ETL_USING_CPP17 + CHECK_TRUE((etl::type_list_contains_v)); + CHECK_FALSE((etl::type_list_contains_v)); + CHECK_FALSE((etl::type_list_contains_v)); + CHECK_TRUE((etl::type_list_contains_v)); + CHECK_TRUE((etl::type_list_contains_v)); + CHECK_FALSE((etl::type_list_contains_v)); + CHECK_FALSE((etl::type_list_contains_v)); +#endif + } + + //************************************************************************* + TEST(test_type_list_index_of) + { + typedef etl::type_list t1; + typedef etl::type_list<> t2; + + CHECK_EQUAL((etl::type_list_index_of::value), 0); + CHECK_EQUAL((etl::type_list_index_of::value), 1); + CHECK_EQUAL((etl::type_list_index_of::value), 2); + CHECK_EQUAL((etl::type_list_index_of::value), etl::type_list_npos); + +#if ETL_USING_CPP17 + CHECK_EQUAL((etl::type_list_index_of_v), 0); + CHECK_EQUAL((etl::type_list_index_of_v), 1); + CHECK_EQUAL((etl::type_list_index_of_v), 2); + CHECK_EQUAL((etl::type_list_index_of_v), etl::type_list_npos); +#endif + } + + //************************************************************************* + TEST(test_type_list_max_sizeof_type) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + typedef etl::type_list t3; + typedef etl::type_list<> t4; + + CHECK_EQUAL(etl::type_list_max_sizeof_type::value, 4); + CHECK_EQUAL(etl::type_list_max_sizeof_type::value, 2); + CHECK_EQUAL(etl::type_list_max_sizeof_type::value, 4); + CHECK_EQUAL(etl::type_list_max_sizeof_type::value, 0); + +#if ETL_USING_CPP17 + CHECK_EQUAL((etl::type_list_max_sizeof_type_v), 4); + CHECK_EQUAL((etl::type_list_max_sizeof_type_v), 2); + CHECK_EQUAL((etl::type_list_max_sizeof_type_v), 4); + CHECK_EQUAL((etl::type_list_max_sizeof_type_v), 0); +#endif + } + + //************************************************************************* + TEST(test_type_list_max_alignment) + { + typedef etl::type_list t1; + typedef etl::type_list t2; + typedef etl::type_list t3; + typedef etl::type_list<> t4; + + CHECK_EQUAL(etl::type_list_max_alignment::value, std::alignment_of::value); + CHECK_EQUAL(etl::type_list_max_alignment::value, std::alignment_of::value); + CHECK_EQUAL(etl::type_list_max_alignment::value, std::alignment_of::value); + CHECK_EQUAL(etl::type_list_max_alignment::value, 1); + +#if ETL_USING_CPP17 + CHECK_EQUAL((etl::type_list_max_alignment_v), std::alignment_of::value); + CHECK_EQUAL((etl::type_list_max_alignment_v), std::alignment_of::value); + CHECK_EQUAL((etl::type_list_max_alignment_v), std::alignment_of::value); + CHECK_EQUAL((etl::type_list_max_alignment_v), 1); +#endif + } + + }; +#endif +} From d9f3d09e5cf91c73a73ee6b15f63869c08575e24 Mon Sep 17 00:00:00 2001 From: "Chiang, Yi" Date: Tue, 4 Mar 2025 18:10:56 +0100 Subject: [PATCH 13/28] Support c++17 is_invocable_r --- include/etl/type_traits.h | 51 +++++++++++++++++++++++++++++++++++++++ test/test_type_traits.cpp | 23 ++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 327f164be..260cdf990 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -2349,6 +2349,57 @@ typedef integral_constant true_type; template inline constexpr bool has_duplicates_of_v = etl::has_duplicates_of::value; #endif + +#if ETL_USING_STL && ETL_USING_CPP17 + template + using is_invocable_r = std::is_invocable_r; + template + inline constexpr bool is_invocable_r_v = std::is_invocable_r_v; +#elif ETL_USING_CPP11 + namespace private_type_traits + { + template + void accept(R); + + template + struct is_invocable_r_impl : etl::false_type + { + }; + + template + struct is_invocable_r_impl< + decltype(etl::declval()(etl::declval()...), void()), + void, + F, + Args...> : etl::true_type + { + }; + + template + struct is_invocable_r_impl< + decltype(etl::declval()(etl::declval()...), void()), + const void, + F, + Args...> : etl::true_type + { + }; + + template + struct is_invocable_r_impl< + decltype(accept(etl::declval()(etl::declval()...))), + R, + F, + Args...> : etl::true_type + { + }; + } // namespace private_type_traits + template + using is_invocable_r = private_type_traits::is_invocable_r_impl; +#if ETL_USING_CPP17 + template + inline constexpr bool is_invocable_r_v = is_invocable_r::value; +#endif +#endif } // Helper macros diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 4316a697f..ca413e023 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -1379,4 +1379,27 @@ namespace CHECK_EQUAL(2, (etl::count_of::value)); #endif } +#if ETL_USING_CPP11 + TEST(test_is_invocable_r) + { + auto func2 = [](char) -> int (*)() + { + return nullptr; + }; +#if ETL_USING_CPP17 + CHECK_TRUE((etl::is_invocable_r_v)); + CHECK_TRUE((etl::is_invocable_r_v)); + CHECK_TRUE((etl::is_invocable_r_v)); + CHECK_FALSE((etl::is_invocable_r_v)); + CHECK_FALSE((etl::is_invocable_r_v)); + CHECK_FALSE((etl::is_invocable_r_v)); +#endif + CHECK_TRUE((etl::is_invocable_r::value)); + CHECK_TRUE((etl::is_invocable_r::value)); + CHECK_TRUE((etl::is_invocable_r::value)); + CHECK_FALSE((etl::is_invocable_r::value)); + CHECK_FALSE((etl::is_invocable_r::value)); + CHECK_FALSE((etl::is_invocable_r::value)); + } +#endif } From af095d7e1a08a6ef20e4187ee328d48150d19bbf Mon Sep 17 00:00:00 2001 From: "Chiang, Yi" Date: Tue, 4 Mar 2025 18:11:43 +0100 Subject: [PATCH 14/28] Support etl::inplace_function Provide similar api to std::function. Store a callable inside the inplace_function object's member field in a type-erasure way. The member field, i.e. storage or buffer, has a compile-time fixed size. The size is specify either by the macro ETL_INPLACE_FUNCTION_DEFAULT_CAPACITY or a non-type template parameter. The implementation is inspired by: 1. SG14 inplace_function 2. folly::Function 3. function2 --- include/etl/file_error_numbers.h | 1 + include/etl/inplace_function.h | 40 ++ include/etl/private/inplace_function_cpp11.h | 246 +++++++ test/CMakeLists.txt | 1 + test/test_inplace_function.cpp | 652 +++++++++++++++++++ 5 files changed, 940 insertions(+) create mode 100644 include/etl/inplace_function.h create mode 100644 include/etl/private/inplace_function_cpp11.h create mode 100644 test/test_inplace_function.cpp diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index 64d94d573..554d7b143 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -105,4 +105,5 @@ SOFTWARE. #define ETL_BASE64_FILE_ID "72" #define ETL_SINGLETON_BASE_FILE_ID "73" #define ETL_UNALIGNED_TYPE_FILE_ID "74" +#define ETL_INPLACE_FUNCTION_FILE_ID "75" #endif diff --git a/include/etl/inplace_function.h b/include/etl/inplace_function.h new file mode 100644 index 000000000..803e2e6ed --- /dev/null +++ b/include/etl/inplace_function.h @@ -0,0 +1,40 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_INPLACE_FUNCTION_INCLUDED +#define ETL_INPLACE_FUNCTION_INCLUDED + +#include "platform.h" + +#if ETL_USING_CPP11 + #include "private/inplace_function_cpp11.h" +#endif + +#endif diff --git a/include/etl/private/inplace_function_cpp11.h b/include/etl/private/inplace_function_cpp11.h new file mode 100644 index 000000000..a9f9f295c --- /dev/null +++ b/include/etl/private/inplace_function_cpp11.h @@ -0,0 +1,246 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR rhs +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR rhsWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR rhs DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_INPLACE_FUNCTION_CPP11_INCLUDED +#define ETL_INPLACE_FUNCTION_CPP11_INCLUDED + +#include "../platform.h" +#include "../error_handler.h" +#include "../exception.h" +#include "../type_traits.h" +#include "../utility.h" + +#ifndef ETL_INPLACE_FUNCTION_DEFAULT_CAPACITY + #define ETL_INPLACE_FUNCTION_DEFAULT_CAPACITY 32 +#endif +namespace etl +{ + template < + typename Signature, + size_t Capacity = ETL_INPLACE_FUNCTION_DEFAULT_CAPACITY> + class inplace_function; + + namespace private_inplace_function + { + template + struct is_inplace_function : etl::false_type + { + }; + template + struct is_inplace_function> : etl::true_type + { + }; + } // namespace private_inplace_function + + class inplace_function_exception : public etl::exception + { + public: + inplace_function_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + class bad_inplace_function_call : public inplace_function_exception + { + public: + bad_inplace_function_call(string_type file_name_, numeric_type line_number_) + : inplace_function_exception(ETL_ERROR_TEXT("inplace_function:call", ETL_INPLACE_FUNCTION_FILE_ID "A"), file_name_, line_number_) + { + } + }; + + template < + typename R, + typename... Args, + size_t Capacity> + class inplace_function ETL_FINAL + { + public: + using capacity = etl::integral_constant; + + inplace_function() ETL_NOEXCEPT = default; + + template < + typename T, + typename C = etl::decay_t, + typename = etl::enable_if_t< + !private_inplace_function::is_inplace_function::value && etl::is_invocable_r::value>> + inplace_function(T&& closure) + { + ETL_STATIC_ASSERT(etl::is_copy_constructible::value, + "cannot be constructed from non-copyable types"); + ETL_STATIC_ASSERT(sizeof(C) <= Capacity, + "internal storage too small"); + + static const vtable_t vt{etl::type_identity{}}; + + vtable_ptr = &vt; + ::new (obj) C{etl::forward(closure)}; + } + + template + inplace_function(const inplace_function& rhs) + : inplace_function(rhs.vtable_ptr, rhs.vtable_ptr->copy_func, rhs.obj) + { + ETL_STATIC_ASSERT(Cap <= Capacity, + "internal storage too small"); + } + + template + inplace_function(inplace_function&& rhs) ETL_NOEXCEPT + : inplace_function(rhs.vtable_ptr, rhs.vtable_ptr->move_func, rhs.obj) + { + ETL_STATIC_ASSERT(Cap <= Capacity, + "internal storage too small"); + rhs.vtable_ptr = &default_vtable; + } + + inplace_function(const inplace_function& rhs) + : vtable_ptr{rhs.vtable_ptr} + { + vtable_ptr->copy_func( + obj, + rhs.obj); + } + + inplace_function(inplace_function&& rhs) ETL_NOEXCEPT + : vtable_ptr{rhs.vtable_ptr} + { + rhs.vtable_ptr = &default_vtable; + vtable_ptr->move_func( + obj, + rhs.obj); + } + + inplace_function& operator=(etl::nullptr_t) ETL_NOEXCEPT + { + vtable_ptr->dtor_func(&obj); + vtable_ptr = ETL_NULLPTR; + return *this; + } + + inplace_function& operator=(inplace_function rhs) ETL_NOEXCEPT + { + vtable_ptr->dtor_func(obj); + vtable_ptr = rhs.vtable_ptr; + rhs.vtable_ptr = &default_vtable; + vtable_ptr->move_func( + obj, + rhs.obj); + return *this; + } + + ~inplace_function() + { + vtable_ptr->dtor_func(obj); + } + + R operator()(Args... args) const + { + ETL_ASSERT(vtable_ptr->invoke_func, ETL_ERROR(bad_inplace_function_call)); + return vtable_ptr->invoke_func( + obj, + etl::forward(args)...); + } + + explicit ETL_CONSTEXPR operator bool() const ETL_NOEXCEPT + { + return vtable_ptr != &default_vtable; + } + + private: + template + friend class inplace_function; + + struct vtable_t ETL_FINAL + { + using invoke_func_t = R (*)(char*, Args&&...); + using copy_or_move_func_t = void (*)(char*, char*); + using dtor_func_t = void (*)(char*); + + const invoke_func_t invoke_func{ETL_NULLPTR}; + const copy_or_move_func_t copy_func{[](char*, char*) -> void {}}; + const copy_or_move_func_t move_func{[](char*, char*) -> void {}}; + const dtor_func_t dtor_func{[](char*) -> void {}}; + + ~vtable_t() = default; + + ETL_CONSTEXPR vtable_t() ETL_NOEXCEPT = default; + + template + explicit ETL_CONSTEXPR vtable_t(etl::type_identity) ETL_NOEXCEPT + : invoke_func{[](char* obj, Args&&... args) -> R + { return (*reinterpret_cast(obj))( + etl::forward(args)...); }}, + copy_func{[](char* dst_obj, char* src_obj) -> void + { ::new (dst_obj) T{*reinterpret_cast(src_obj)}; }}, + move_func{[](char* dst_obj, char* src_obj) -> void + { + ::new (dst_obj) T{etl::move(*reinterpret_cast(src_obj))}; + reinterpret_cast(src_obj)->~T(); + }}, + dtor_func{[](char* obj) -> void + { reinterpret_cast(obj)->~T(); }} + { + } + + private: + vtable_t(const vtable_t&) ETL_DELETE; + vtable_t(vtable_t&&) ETL_NOEXCEPT ETL_DELETE; + + vtable_t& operator=(const vtable_t&) ETL_DELETE; + vtable_t& operator=(vtable_t&&) ETL_DELETE; + }; + + static const vtable_t default_vtable; + + const vtable_t* vtable_ptr{&default_vtable}; + mutable char obj[Capacity]; + + explicit inplace_function( + const vtable_t* vtable, + typename vtable_t::copy_or_move_func_t copy_or_move_func, + char* obj_ptr) + : vtable_ptr{vtable} + { + copy_or_move_func(obj, obj_ptr); + } + }; + + template < + typename R, + typename... Args, + size_t Capacity> + const typename inplace_function::vtable_t + inplace_function::default_vtable{}; +} // namespace etl + +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bcc8a0da7..fc1b7fbf1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -151,6 +151,7 @@ add_executable(etl_tests test_histogram.cpp test_indirect_vector.cpp test_indirect_vector_external_buffer.cpp + test_inplace_function.cpp test_instance_count.cpp test_integral_limits.cpp test_intrusive_forward_list.cpp diff --git a/test/test_inplace_function.cpp b/test/test_inplace_function.cpp new file mode 100644 index 000000000..d5dbb2cac --- /dev/null +++ b/test/test_inplace_function.cpp @@ -0,0 +1,652 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/inplace_function.h" + +#include + +#if ETL_USING_CPP11 +namespace +{ + void fooRef(int32_t& result) + { + result = 2; + } + + int32_t foo0() + { + return 2; + } + + int32_t foo1(float f) + { + return f; + } + + int32_t foo2(float, int32_t g) + { + return g; + } + + int32_t foo3(float, int32_t, int32_t h) + { + return h; + } + + int32_t foo4(float, int32_t, int32_t, int32_t i) + { + return i; + } + + int32_t foo5(float, int32_t, int32_t, int32_t, int32_t j) + { + return j; + } + + struct Foo + { + int32_t foo0() + { + return 3; + } + + int32_t foo1(float f) + { + return f; + } + + int32_t foo2(float, int32_t g) + { + return g; + } + + int32_t foo3(float, int32_t, int32_t h) + { + return h; + } + + int32_t foo4(float, int32_t, int32_t, int32_t i) + { + return i; + } + + int32_t foo5(float, int32_t, int32_t, int32_t, int32_t j) + { + return j; + } + + static int32_t bar0() + { + return 5; + } + + static int32_t bar1(float f) + { + return f; + } + + static int32_t bar2(float, int32_t g) + { + return g; + } + + static int32_t bar3(float, int32_t, int32_t h) + { + return h; + } + + static int32_t bar4(float, int32_t, int32_t, int32_t i) + { + return i; + } + + static int32_t bar5(float, int32_t, int32_t, int32_t, int32_t j) + { + return j; + } + }; + + struct Bar0 + { + int32_t operator()() const + { + return 7; + } + }; + + struct Bar1 + { + int32_t operator()(float f) const + { + return f; + } + }; + + struct Bar2 + { + int32_t operator()(float, int32_t g) const + { + return g; + } + }; + + struct Bar3 + { + int32_t operator()(float, int32_t, int32_t h) const + { + return h; + } + }; + + struct Bar4 + { + int32_t operator()(float, int32_t, int32_t, int32_t i) const + { + return i; + } + }; + + struct Bar5 + { + int32_t operator()(float, int32_t, int32_t, int32_t, int32_t j) const + { + return j; + } + }; + + struct BarV + { + int32_t _m; + + int32_t operator()() + { + _m++; + return _m + 7; + } + + int32_t operator()(int32_t f) const + { + return _m + f; + } + + int32_t operator()(int32_t, int32_t g) const + { + return _m + g; + } + + int32_t operator()(int32_t, int32_t, int32_t h) const + { + return _m + h; + } + + int32_t operator()(int32_t, int32_t, int32_t, int32_t i) const + { + return _m + i; + } + + int32_t operator()(int32_t, int32_t, int32_t, int32_t, int32_t j) const + { + return _m + j; + } + }; + + struct IntClass + { + IntClass() + : i(10) + { + } + + int32_t i; + }; +} // namespace + +namespace +{ + SUITE(test_inplace_function) + { + TEST(DefaultConstructed) + { + etl::inplace_function f; + CHECK_THROW((f()), etl::bad_inplace_function_call); + + etl::inplace_function f1; + IntClass a1; + CHECK_THROW((f1(a1)), etl::bad_inplace_function_call); + + etl::inplace_function f2; + IntClass a2; + CHECK_THROW((f2(a1, a2)), etl::bad_inplace_function_call); + + etl::inplace_function f2_copy; + + f2_copy = f2; + CHECK_THROW((f2_copy(a1, a2)), etl::bad_inplace_function_call); + + etl::inplace_function f3; + IntClass a3; + CHECK_THROW((f3(a1, a2, a3)), etl::bad_inplace_function_call); + + etl::inplace_function f4; + IntClass a4; + CHECK_THROW((f4(a1, a2, a3, a4)), etl::bad_inplace_function_call); + + etl::inplace_function f5; + IntClass a5; + CHECK_THROW((f5(a1, a2, a3, a4, a5)), etl::bad_inplace_function_call); + } + + TEST(OperatorBool) + { + etl::inplace_function f0; + etl::inplace_function f1; + etl::inplace_function f2; + etl::inplace_function f3; + etl::inplace_function f4; + etl::inplace_function f5; + + CHECK_FALSE(f0); + CHECK_FALSE(f1); + CHECK_FALSE(f2); + CHECK_FALSE(f3); + CHECK_FALSE(f4); + CHECK_FALSE(f5); + + f0 = etl::inplace_function(&Foo::bar0); + f1 = etl::inplace_function(&Foo::bar1); + f2 = etl::inplace_function(&Foo::bar2); + f3 = etl::inplace_function(&Foo::bar3); + f4 = etl::inplace_function(&Foo::bar4); + f5 = etl::inplace_function(&Foo::bar5); + + CHECK(f0); + CHECK(f1); + CHECK(f2); + CHECK(f3); + CHECK(f4); + CHECK(f5); + } + + TEST(HasValue) + { + etl::inplace_function f0; + etl::inplace_function f1; + etl::inplace_function f2; + etl::inplace_function f3; + etl::inplace_function f4; + etl::inplace_function f5; + + CHECK_FALSE(f0); + CHECK_FALSE(f1); + CHECK_FALSE(f2); + CHECK_FALSE(f3); + CHECK_FALSE(f4); + CHECK_FALSE(f5); + + f0 = etl::inplace_function(&Foo::bar0); + f1 = etl::inplace_function(&Foo::bar1); + f2 = etl::inplace_function(&Foo::bar2); + f3 = etl::inplace_function(&Foo::bar3); + f4 = etl::inplace_function(&Foo::bar4); + f5 = etl::inplace_function(&Foo::bar5); + + CHECK(f0); + CHECK(f1); + CHECK(f2); + CHECK(f3); + CHECK(f4); + CHECK(f5); + } + + TEST(TestFreeFunctionZeroParams) + { + etl::inplace_function f = etl::inplace_function(&foo0); + CHECK_EQUAL(2, f()); + } + + TEST(TestMemberFunctionZeroParams) + { + Foo foo; + etl::inplace_function f = std::bind(&Foo::foo0, &foo); + CHECK_EQUAL(3, f()); + } + + TEST(TestStaticMemberFunctionZeroParams) + { + etl::inplace_function f = etl::inplace_function(&Foo::bar0); + CHECK_EQUAL(5, f()); + } + + TEST(TestFunctorZeroParams) + { + Bar0 bar; + etl::inplace_function f(bar); + CHECK_EQUAL(7, f()); + } + + TEST(TestLambdaParameter) + { + auto callme = [](etl::inplace_function f) + { return f(); }; + auto f = []() + { return 112358; }; + CHECK_EQUAL(112358, callme(f)); + } + + TEST(TestFreeFunctionOneParam) + { + etl::inplace_function f = &foo1; + CHECK_EQUAL(2, f(2.14)); + } + + TEST(TestFreeFunctionOneParamVoid) + { + etl::inplace_function f = &fooRef; + int32_t result = 0; + f(result); + CHECK_EQUAL(2, result); + } + + TEST(TestMemberFunctionOneParam) + { + Foo foo; + etl::inplace_function f = + std::bind(&Foo::foo1, &foo, std::placeholders::_1); + CHECK_EQUAL(3, f(3.14)); + } + + TEST(TestStaticMemberFunctionOneParam) + { + etl::inplace_function f = &Foo::bar1; + CHECK_EQUAL(5, f(5.75)); + } + + TEST(TestFunctorOneParam) + { + Bar1 bar; + etl::inplace_function f = bar; + CHECK_EQUAL(7, f(7.65)); + } + + TEST(TestFreeFunctionTwoParams) + { + etl::inplace_function f = &foo2; + CHECK_EQUAL(2, f(2.14, 2)); + } + + TEST(TestMemberFunctionTwoParams) + { + Foo foo; + etl::inplace_function f = + std::bind(&Foo::foo2, &foo, std::placeholders::_1, std::placeholders::_2); + CHECK_EQUAL(3, f(3.14, 3)); + } + + TEST(TestStaticMemberFunctionTwoParams) + { + etl::inplace_function f = &Foo::bar2; + CHECK_EQUAL(5, f(5.75, 5)); + } + + TEST(TestFunctorTwoParams) + { + Bar2 bar; + etl::inplace_function f = bar; + CHECK_EQUAL(7, f(7.65, 7)); + } + + TEST(TestFreeFunctionThreeParams) + { + etl::inplace_function f = &foo3; + CHECK_EQUAL(4, f(2.14, 2, 4)); + } + + TEST(TestMemberFunctionThreeParams) + { + Foo foo, *pfoo{&foo}; + etl::inplace_function f = + [pfoo](float p0, int32_t p1, int32_t p2) + { return pfoo->foo3(p0, p1, p2); }; + CHECK_EQUAL(120, f(3.14, 3, 120)); + } + + TEST(TestStaticMemberFunctionThreeParams) + { + etl::inplace_function f = &Foo::bar3; + CHECK_EQUAL(4, f(5.75, 5, 4)); + } + + TEST(TestFunctorThreeParams) + { + Bar3 bar; + etl::inplace_function f = bar; + CHECK_EQUAL(4, f(7.65, 7, 4)); + } + + TEST(TestFreeFunctionFourParams) + { + etl::inplace_function f = &foo4; + CHECK_EQUAL(5, f(2.14, 2, 4, 5)); + } + + TEST(TestStaticMemberFunctionFourParams) + { + etl::inplace_function f = &Foo::bar4; + CHECK_EQUAL(5, f(5.75, 5, 4, 5)); + } + + TEST(TestFunctorFourParams) + { + Bar4 bar; + etl::inplace_function f = bar; + CHECK_EQUAL(5, f(7.65, 7, 4, 5)); + } + + TEST(TestFreeFunctionFiveParams) + { + etl::inplace_function f = &foo5; + CHECK_EQUAL(7, f(2.14, 2, 4, 5, 7)); + } + + TEST(TestStaticMemberFunctionFiveParams) + { + etl::inplace_function f = &Foo::bar5; + CHECK_EQUAL(8, f(5.75, 5, 4, 5, 8)); + } + + TEST(TestFunctorFiveParams) + { + Bar5 bar; + etl::inplace_function f = + bar; + CHECK_EQUAL(8, f(7.65, 7, 4, 5, 8)); + } + + TEST(CopyConstructorZeroParams) + { + { + etl::inplace_function f = &foo0; + etl::inplace_function g(f); + CHECK_EQUAL(2, f()); + CHECK_EQUAL(2, g()); + } + { + Foo foo, *pfoo{&foo}; + etl::inplace_function f = [pfoo] + { return pfoo->foo0(); }; + etl::inplace_function g(f); + CHECK_EQUAL(3, f()); + CHECK_EQUAL(3, g()); + } + { + etl::inplace_function f = &Foo::bar0; + etl::inplace_function g = f; + CHECK_EQUAL(5, f()); + CHECK_EQUAL(5, g()); + } + { + Bar0 bar; + etl::inplace_function f = bar; + etl::inplace_function g = f; + CHECK_EQUAL(7, f()); + CHECK_EQUAL(7, g()); + } + } + + TEST(AssignmentOperatorZeroParams) + { + { + etl::inplace_function f = &foo0, g; + g = f; + CHECK_EQUAL(2, f()); + CHECK_EQUAL(2, g()); + } + { + Foo foo, *pfoo{&foo}; + etl::inplace_function f = [pfoo] + { return pfoo->foo0(); }, + g; + g = f; + CHECK_EQUAL(3, f()); + CHECK_EQUAL(3, g()); + } + { + etl::inplace_function f = &Foo::bar0, g; + g = f; + CHECK_EQUAL(5, f()); + CHECK_EQUAL(5, g()); + } + { + Bar0 bar; + etl::inplace_function f = bar, g; + g = f; + CHECK_EQUAL(7, f()); + CHECK_EQUAL(7, g()); + } + } + + class Const + { + int32_t _i; + + public: + Const(int32_t i) + : _i(i) + { + } + + int32_t get0() const + { + return _i; + } + + int32_t get0_b() const + { + return _i * 2; + } + + int32_t get1(Const&) const + { + return _i; + } + + int32_t get1NotConst(Const const&) const + { + return _i; + } + + int32_t get2(Const const&, Const const&) const + { + return _i; + } + + int32_t get3(Const const&, Const const&, Const const&) const + { + return _i; + } + + int32_t get4(Const const&, Const const&, Const const&, Const const&) const + { + return _i; + } + + int32_t get5(Const const&, Const const&, Const const&, Const const&, Const const&) const + { + return _i; + } + }; + TEST(ConstMemberFunction) + { + Const ncon(17), *pncon{&ncon}; + etl::inplace_function f = [pncon] + { return pncon->get0(); }; + CHECK_EQUAL(17, f()); + + Const const & con = ncon, *pcon{&con}; + etl::inplace_function f2 = [pcon] + { return pcon->get0(); }; + CHECK_EQUAL(17, f2()); + + etl::inplace_function f3 = [pcon](Const& p0) + { return pcon->get1(p0); }; + CHECK_EQUAL(17, f3(ncon)); + + etl::inplace_function f3NotConst = + [pncon](Const const& p0) + { return pncon->get1NotConst(p0); }; + CHECK_EQUAL(17, f3NotConst(ncon)); + + etl::inplace_function f4 = + [pcon](Const const& p0, Const const& p1) + { return pcon->get2(p0, p1); }; + CHECK_EQUAL(17, f4(ncon, ncon)); + CHECK_EQUAL(17, f4(con, con)); + + etl::inplace_function f5 = + [pcon](Const const& p0, Const const& p1, Const const& p2) + { return pcon->get3(p0, p1, p2); }; + CHECK_EQUAL(17, f5(ncon, ncon, ncon)); + CHECK_EQUAL(17, f5(con, con, con)); + + etl::inplace_function f6 = etl::inplace_function([pcon](Const const& p0, Const const& p1, Const const& p2, Const const& p3) + { return pcon->get4(p0, p1, p2, p3); }); + CHECK_EQUAL(17, f6(ncon, ncon, ncon, ncon)); + CHECK_EQUAL(17, f6(con, con, con, con)); + + etl::inplace_function + f7 = [pcon](Const const& p0, Const const& p1, Const const& p2, Const const& p3, Const const& p4) + { return pcon->get5(p0, p1, p2, p3, p4); }; + CHECK_EQUAL(17, f7(ncon, ncon, ncon, ncon, ncon)); + CHECK_EQUAL(17, f7(con, con, con, con, con)); + } + } +} // namespace + +#endif From d22ca6c72ae036cd7c917aac267080d0127cd19b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 31 Jan 2025 22:02:01 +0100 Subject: [PATCH 15/28] Add etl::typed_storage based on etl::aligned_storage_as --- include/etl/alignment.h | 117 ++++++++++++++++++++++++++++++++++++++++ test/test_alignment.cpp | 43 +++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/include/etl/alignment.h b/include/etl/alignment.h index c6a4de066..0f50e4697 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -36,6 +36,7 @@ SOFTWARE. #include "static_assert.h" #include "error_handler.h" #include "exception.h" +#include "utility.h" #include @@ -71,6 +72,19 @@ namespace etl } }; + //*************************************************************************** + /// Typed storage exception. + //*************************************************************************** + class typed_storage_error : public alignment_exception + { + public: + + typed_storage_error(string_type file_name_, numeric_type line_number_) + : alignment_exception(ETL_ERROR_TEXT("typed_storage:error", ETL_ALIGNMENT_FILE_ID"B"), file_name_, line_number_) + { + } + }; + //***************************************************************************** /// Check that 'p' has 'required_alignment'. //***************************************************************************** @@ -333,6 +347,109 @@ namespace etl #if ETL_USING_CPP11 template using aligned_storage_as_t = typename aligned_storage_as::type; + + //*************************************************************************** + /// Wrapper class that provides a memory area and lets the user emplace and + /// instance of T in this memory at runtime. This class also erases the + /// destructor call of T, i.e. if typed_storage goes out of scope, the + /// destructor if the wrapped type will not be called. This can be done + /// explicitly by calling destroy(). + /// \tparam T Type of element stored in this instance of typed_storage. + //*************************************************************************** + template + class typed_storage + { + public: + + using value_type = T; + using reference = T&; + using const_reference = T const&; + using pointer = T*; + using const_pointer = T const*; + + // Constructor + typed_storage() + : valid(false) + { + } + + //*************************************************************************** + /// Default destructor which will NOT call the destructor of the object which + /// was created by calling emplace(). + //*************************************************************************** + ~typed_storage() = default; + + //*************************************************************************** + /// Calls the destructor of the wrapped object and asserts if has_value() is false. + //*************************************************************************** + void destroy() + { + ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error)); + data.template get_reference().~T(); + valid = false; + } + + //*************************************************************************** + /// \returns true if object has been constructed using emplace(). + /// \returns false otherwise. + //*************************************************************************** + bool has_value() const + { + return valid; + } + + //*************************************************************************** + /// Constructs the instance of T forwarding the given \p args to its constructor and + /// asserts if has_value() is true before calling emplace(). + /// + /// \returns the instance of T which has been constructed in the internal byte array. + //*************************************************************************** + template + reference emplace(Args&&... args) + { + ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error)); + valid = true; + return *::new (data.template get_address()) value_type(etl::forward(args)...); + } + + //*************************************************************************** + /// \returns a pointer of type T and asserts if has_value() is false. + //*************************************************************************** + pointer operator->() + { + ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error)); + return data.template get_address(); + } + + //*************************************************************************** + /// \returns a const pointer of type T and asserts if has_value() is false. + //*************************************************************************** + const_pointer operator->() const + { + return operator->(); + } + + //*************************************************************************** + /// \returns reference of type T and asserts if has_value() is false. + //*************************************************************************** + reference operator*() + { + return *operator->(); + } + + //*************************************************************************** + /// \returns const reference of type T and asserts if has_value() is false. + //*************************************************************************** + const_reference operator*() const + { + return *operator->(); + } + + private: + + typename aligned_storage_as::type data; + bool valid; + }; #endif } diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 29de827a1..52773baa1 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -48,6 +48,23 @@ void f(int) { } +struct A_t +{ + A_t(uint32_t v_x, uint8_t v_y) + : x(v_x) + , y(v_y) + { + } + + bool operator==(A_t& other) + { + return other.x == x && other.y == y; + } + + uint32_t x; + uint8_t y; +}; + namespace { SUITE(test_alignment) @@ -155,5 +172,31 @@ namespace CHECK_EQUAL(32, alignof(etl::type_with_alignment_t<32>)); CHECK_EQUAL(64, alignof(etl::type_with_alignment_t<64>)); } + + //************************************************************************* +#if ETL_USING_CPP11 + TEST(test_typed_storage) + { + etl::typed_storage a; + + CHECK_EQUAL(false, a.has_value()); + + auto& b = a.emplace(123, 4); + + CHECK_EQUAL(true, a.has_value()); + + CHECK_EQUAL(a->x, 123); + CHECK_EQUAL(a->y, 4); + + CHECK_EQUAL(b.x, 123); + CHECK_EQUAL(b.y, 4); + + CHECK_TRUE(*a == b); + + CHECK_EQUAL(true, a.has_value()); + a.destroy(); + CHECK_EQUAL(false, a.has_value()); + } +#endif }; } From 9d72300652e4276bb8d14a9c6ad0f61ee215e282 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 10 Mar 2025 14:42:37 +0100 Subject: [PATCH 16/28] Have create() instead of emplace() --- include/etl/alignment.h | 2 +- test/test_alignment.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/alignment.h b/include/etl/alignment.h index 0f50e4697..47ae77447 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -405,7 +405,7 @@ namespace etl /// \returns the instance of T which has been constructed in the internal byte array. //*************************************************************************** template - reference emplace(Args&&... args) + reference create(Args&&... args) { ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error)); valid = true; diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 52773baa1..7563bbbcc 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -181,7 +181,7 @@ namespace CHECK_EQUAL(false, a.has_value()); - auto& b = a.emplace(123, 4); + auto& b = a.create(123, 4); CHECK_EQUAL(true, a.has_value()); From 160cd800d74519416f432f34b3324bb389d04f22 Mon Sep 17 00:00:00 2001 From: "Chiang, Yi" Date: Wed, 5 Mar 2025 11:03:53 +0100 Subject: [PATCH 17/28] Support etl::underlying_type with compiler builtin msvc is unsupported currently --- .../etl/generators/type_traits_generator.h | 29 +++++++++++++ .../etl/profiles/determine_builtin_support.h | 12 ++++++ include/etl/type_traits.h | 29 +++++++++++++ include/etl/utility.h | 8 ++++ test/test_type_traits.cpp | 42 +++++++++++++++++- test/test_utility.cpp | 43 +++++++++++++++++++ 6 files changed, 162 insertions(+), 1 deletion(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index e55d12217..9302e06aa 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -2302,6 +2302,35 @@ typedef integral_constant true_type; using type_identity_t = typename type_identity::type; #endif +#if ETL_USING_BUILTIN_UNDERLYING_TYPE +namespace private_type_traits +{ + template ::value> + struct __underlying_type_impl; + + template + struct __underlying_type_impl + { + }; + + template + struct __underlying_type_impl + { + using type = __underlying_type(T); + }; +} + +template +struct underlying_type : private_type_traits::__underlying_type_impl::value> +{ +}; + +#if ETL_USING_CPP11 +template +using underlying_type_t = typename underlying_type::type; +#endif +#endif + #if ETL_USING_CPP11 //********************************************* // has_duplicates diff --git a/include/etl/profiles/determine_builtin_support.h b/include/etl/profiles/determine_builtin_support.h index 725927f32..313a18a20 100644 --- a/include/etl/profiles/determine_builtin_support.h +++ b/include/etl/profiles/determine_builtin_support.h @@ -51,6 +51,10 @@ SOFTWARE. #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE) #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1 #endif + + #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE) + #define ETL_USING_BUILTIN_UNDERLYING_TYPE 1 + #endif #endif #if defined(__has_builtin) // Use __has_builtin to check for existence of builtin functions? @@ -73,6 +77,10 @@ SOFTWARE. #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE) #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable)) #endif + + #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE) + #define ETL_USING_BUILTIN_UNDERLYING_TYPE __has_builtin(__underlying_type) + #endif #endif // The default. Set to 0, if not already set. @@ -96,6 +104,10 @@ SOFTWARE. #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0 #endif +#if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE) + #define ETL_USING_BUILTIN_UNDERLYING_TYPE 0 +#endif + namespace etl { namespace traits diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 327f164be..7949a62ad 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -2295,6 +2295,35 @@ typedef integral_constant true_type; using type_identity_t = typename type_identity::type; #endif +#if ETL_USING_BUILTIN_UNDERLYING_TYPE +namespace private_type_traits +{ + template ::value> + struct __underlying_type_impl; + + template + struct __underlying_type_impl + { + }; + + template + struct __underlying_type_impl + { + using type = __underlying_type(T); + }; +} + +template +struct underlying_type : private_type_traits::__underlying_type_impl::value> +{ +}; + +#if ETL_USING_CPP11 +template +using underlying_type_t = typename underlying_type::type; +#endif +#endif + #if ETL_USING_CPP11 //********************************************* // has_duplicates diff --git a/include/etl/utility.h b/include/etl/utility.h index 8ea7a4751..7ba93e3da 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -131,6 +131,14 @@ namespace etl using forward_like_t = decltype(etl::forward_like(etl::declval())); #endif +#if ETL_USING_BUILTIN_UNDERLYING_TYPE && ETL_USING_CPP11 +template +ETL_CONSTEXPR underlying_type_t to_underlying(T val) ETL_NOEXCEPT +{ + return static_cast>(val); +} +#endif + // We can't have std::swap and etl::swap templates coexisting in the unit tests // as the compiler will be unable to decide which one to use, due to ADL. #if ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST) diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 4316a697f..b6466aa53 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -1329,11 +1329,51 @@ namespace } //************************************************************************* - TEST(test_type_identity) + TEST(test_type_identity) { CHECK_CLOSE(type_identity_test_add(1.5f, 2), 3.5f, 0.01f); } + //************************************************************************* +#if ETL_USING_BUILTIN_UNDERLYING_TYPE + TEST(test_underlying_type) + { + enum enum0_t : char + { + }; + + enum enum1_t : uint32_t + { + }; + + enum class enum2_t : short + { + }; + + enum class enum3_t : size_t + { + }; + + using enum4_t = enum1_t; + using enum5_t = std::add_const::type; + + CHECK_TRUE((std::is_same::type, char>::value)); + CHECK_TRUE((std::is_same::type, uint32_t>::value)); + CHECK_TRUE((std::is_same::type, short>::value)); + CHECK_TRUE((std::is_same::type, size_t>::value)); + CHECK_TRUE((std::is_same::type, uint32_t>::value)); + CHECK_TRUE((std::is_same::type, short>::value)); +#if ETL_USING_CPP11 + CHECK_TRUE((std::is_same, char>::value)); + CHECK_TRUE((std::is_same, uint32_t>::value)); + CHECK_TRUE((std::is_same, short>::value)); + CHECK_TRUE((std::is_same, size_t>::value)); + CHECK_TRUE((std::is_same, uint32_t>::value)); + CHECK_TRUE((std::is_same, short>::value)); +#endif + } +#endif + //************************************************************************* TEST(test_has_duplicates) { diff --git a/test/test_utility.cpp b/test/test_utility.cpp index e049198da..70b525ec9 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -719,6 +719,49 @@ namespace CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl(etl::move(u4))); } +#if ETL_USING_BUILTIN_UNDERLYING_TYPE && ETL_USING_CPP11 + TEST(test_to_underlying) + { + enum enum0_t : char + { + a0 = 'e', + a1 = 't', + a2 = 'l', + a3 = '3' + }; + + enum enum1_t : uint32_t + { + b0 = 2, + b1 = 3, + b2 = 5, + }; + + enum enum2_t : signed + { + c0 = -2, + c1 = 100, + }; + + using enum3_t = enum1_t; + + enum0_t e0 = enum0_t::a1; + enum1_t e1 = enum1_t::b2; + enum2_t e2 = enum2_t::c0; + enum3_t e3 = enum3_t::b0; + + CHECK_EQUAL(etl::to_underlying(e0), 't'); + CHECK_EQUAL(etl::to_underlying(e1), 5); + CHECK_EQUAL(etl::to_underlying(e2), -2); + CHECK_EQUAL(etl::to_underlying(e3), 2); + CHECK_EQUAL(etl::to_underlying(enum0_t::a0), 'e'); + CHECK_EQUAL(etl::to_underlying(enum0_t::a2), 'l'); + CHECK_EQUAL(etl::to_underlying(enum0_t::a3), '3'); + CHECK_EQUAL(etl::to_underlying(enum3_t::b1), 3); + CHECK_EQUAL(etl::to_underlying(enum2_t::c1), 100); + } +#endif + #if ETL_HAS_PACKED //********************************* TEST(test_packed) From 5978b31b66a5d7cfb164de10992b2e15415dd549 Mon Sep 17 00:00:00 2001 From: "Chiang, Yi" Date: Sun, 9 Mar 2025 23:01:41 +0100 Subject: [PATCH 18/28] Add chrono.h --- include/etl/chrono.h | 577 +++++++++++++++++++++++++++++++++++++++++++ test/CMakeLists.txt | 1 + test/test_chrono.cpp | 555 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1133 insertions(+) create mode 100644 include/etl/chrono.h create mode 100644 test/test_chrono.cpp diff --git a/include/etl/chrono.h b/include/etl/chrono.h new file mode 100644 index 000000000..03f4802db --- /dev/null +++ b/include/etl/chrono.h @@ -0,0 +1,577 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CHRONO_INCLUDED +#define ETL_CHRONO_INCLUDED + +#include "platform.h" +#include "limits.h" +#include "ratio.h" +#include "stdint.h" +#include "type_traits.h" + +//***************************************************************************** +///\defgroup chrono chrono +/// Provides functionalities of std::chrono +///\ingroup utilities +//***************************************************************************** +namespace etl +{ + namespace chrono + { + template > + struct duration; + + template + struct time_point; + + namespace private_chrono + { + template + struct is_duration_impl : false_type + { + }; + + template + struct is_duration_impl> : true_type + { + }; + + template + struct is_duration : is_duration_impl::type> + { + }; + + template , + bool = (Period::num == 1), + bool = (Period::den == 1)> + struct duration_cast_impl; + + template + struct duration_cast_impl + { + static ETL_CONSTEXPR ToDuration cast(const FromDuration& dur) + { + return ToDuration(static_cast(dur.count())); + } + }; + + template + struct duration_cast_impl + { + static ETL_CONSTEXPR ToDuration cast(const FromDuration& dur) + { + using Ct = typename common_type::type; + return ToDuration( + static_cast(static_cast(dur.count()) / static_cast(Period::den))); + } + }; + + template + struct duration_cast_impl + { + static ETL_CONSTEXPR ToDuration cast(const FromDuration& dur) + { + using Ct = typename common_type::type; + return ToDuration( + static_cast(static_cast(dur.count()) * static_cast(Period::num))); + } + }; + + template + struct duration_cast_impl + { + static ETL_CONSTEXPR ToDuration cast(const FromDuration& dur) + { + using Ct = typename common_type::type; + return ToDuration(static_cast( + static_cast(dur.count()) * static_cast(Period::num) / static_cast(Period::den))); + } + }; + } // namespace private_chrono + + template ::value, int>::type = 0> + ETL_CONSTEXPR ToDuration duration_cast(const duration& dur) + { + return private_chrono::duration_cast_impl, ToDuration>::cast(dur); + } + } // namespace chrono + + template + struct common_type, chrono::duration> + { + using type = chrono::duration::type, + ratio< + private_ratio::ratio_gcd::value, + private_ratio::ratio_lcm::value>>; + }; + + template + struct common_type, chrono::time_point> + { + using type = chrono::time_point::type>; + }; + + namespace chrono + { + template + struct duration_values + { + static Rep ETL_CONSTEXPR zero() ETL_NOEXCEPT + { + return Rep(0); + }; + + static Rep ETL_CONSTEXPR min() ETL_NOEXCEPT + { + return numeric_limits::lowest(); + } + + static Rep ETL_CONSTEXPR max() ETL_NOEXCEPT + { + return numeric_limits::max(); + } + }; + + template + struct duration + { + using rep = Rep; + using period = Period; + + ETL_CONSTEXPR duration() + : val(0) + { + } + + duration(duration const& rhs) + : val(rhs.val) + { + } + + template ::value && (is_floating_point::value || !is_floating_point::value), int>::type = 0> + ETL_CONSTEXPR explicit duration(Rep2 const& rhs) + : val(rhs) + { + } + + template + ETL_CONSTEXPR duration(duration const& dur) + : val( + duration_cast< + typename enable_if<(ratio_divide::den == 1), duration>::type>( + dur) + .count()) + { + } + + duration& operator=(duration const& rhs) + { + val = rhs.val; + return *this; + } + + ETL_CONSTEXPR rep count() const + { + return val; + } + + ETL_CONSTEXPR duration operator+() const + { + return *this; + } + + ETL_CONSTEXPR duration operator-() const + { + return duration(-val); + } + + duration& operator++() + { + ++val; + return *this; + } + + duration operator++(int) + { + duration ret = *this; + ++val; + return ret; + } + + duration& operator--() + { + --val; + return *this; + } + + duration operator--(int) + { + duration ret = *this; + --val; + return ret; + } + + duration& operator+=(duration const& rhs) + { + val += rhs.count(); + return *this; + } + + duration& operator-=(duration const& rhs) + { + val -= rhs.count(); + return *this; + } + + duration& operator*=(rep const& r) + { + val *= r; + return *this; + } + + duration& operator/=(rep const& rhs) + { + val /= rhs; + return *this; + } + + duration& operator%=(rep const& rhs) + { + val %= rhs; + return *this; + } + + duration& operator%=(duration const& rhs) + { + val %= rhs.count(); + return *this; + } + + static ETL_CONSTEXPR duration zero() ETL_NOEXCEPT + { + return duration(duration_values::zero()); + } + + static ETL_CONSTEXPR duration min() ETL_NOEXCEPT + { + return duration(duration_values::min()); + } + + static ETL_CONSTEXPR duration max() ETL_NOEXCEPT + { + return duration(duration_values::max()); + } + + private: + Rep val; + }; + + template + typename common_type, duration>::type + operator+(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(cd_t(lhs).count() + cd_t(rhs).count()); + } + + template + typename common_type, duration>::type + operator-(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(cd_t(lhs).count() - cd_t(rhs).count()); + } + + template + duration::type, Period> + operator*(duration const& d, Rep2 const& r) + { + using cd_t = duration::type, Period>; + return cd_t(cd_t(d).count() * r); + } + + template + duration::type, Period> + operator*(Rep1 const& r, duration const& d) + { + return d * r; + } + + template + duration::type, Period> + operator/(duration const& d, Rep2 const& r) + { + using cd_t = duration::type, Period>; + return cd_t(cd_t(d).count() / r); + } + + template + typename common_type::type + operator/(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(lhs).count() / cd_t(rhs).count(); + } + + template + duration::type, Period> + operator%(duration const& d, Rep2 const& r) + { + using cd_t = duration::type, Period>; + return cd_t(cd_t(d).count() % r); + } + + template + typename common_type, duration>::type + operator%(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(cd_t(lhs).count() % cd_t(rhs).count()); + } + + template + bool operator==(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(lhs).count() == cd_t(rhs).count(); + } + + template + bool operator!=(duration const& lhs, duration const& rhs) + { + return !(lhs == rhs); + } + + template + bool operator<(duration const& lhs, duration const& rhs) + { + using cd_t = typename common_type, duration>::type; + return cd_t(lhs).count() < cd_t(rhs).count(); + } + + template + bool operator<=(duration const& lhs, duration const& rhs) + { + return !(rhs < lhs); + } + + template + bool operator>(duration const& lhs, duration const& rhs) + { + return rhs < lhs; + } + + template + bool operator>=(duration const& lhs, duration const& rhs) + { + return !(lhs < rhs); + } + + using nanoseconds = duration; + using microseconds = duration; + using milliseconds = duration; + using seconds = duration; + using minutes = duration>; + using hours = duration>; + template + struct time_point + { + using clock = Clock; + using duration = Dur; + using rep = typename duration::rep; + using period = typename duration::period; + + ETL_CONSTEXPR time_point() + : dur(duration::zero()) + { + } + + ETL_CONSTEXPR explicit time_point(duration const& d) + : dur(d) + { + } + + ETL_CONSTEXPR time_point(time_point const& rhs) + : dur(rhs.dur) + { + } + + template + explicit time_point(time_point const& rhs) + : dur(rhs.time_since_epoch()) + { + } + + time_point& operator=(time_point const& rhs) + { + dur = rhs.dur; + return *this; + } + + ETL_CONSTEXPR duration time_since_epoch() const + { + return dur; + } + + time_point& operator+=(duration const& rhs) + { + dur += rhs; + return *this; + } + + time_point& operator-=(duration const& rhs) + { + dur -= rhs; + return *this; + } + + static ETL_CONSTEXPR time_point min() ETL_NOEXCEPT + { + return time_point(duration::min()); + } + + static ETL_CONSTEXPR time_point max() ETL_NOEXCEPT + { + return time_point(duration::max()); + } + + private: + duration dur; + }; + + template + time_point time_point_cast(time_point const& tp) + { + using time_point_t = + typename enable_if::value, time_point>::type; + return time_point_t(duration_cast(tp.time_since_epoch())); + } + + template + time_point>::type> + operator+(time_point const& lhs, duration const& rhs) + { + using ct_t = typename common_type>::type; + using time_point_t = time_point; + return time_point_t(lhs.time_since_epoch() + rhs); + } + + template + time_point, Dur2>::type> + operator+(duration const& lhs, time_point const& rhs) + { + return rhs + lhs; + } + + template + time_point>::type> + operator-(time_point const& lhs, duration const& rhs) + { + using ct_t = typename common_type>::type; + using time_point_t = time_point; + return time_point_t(lhs.time_since_epoch() - rhs); + } + + template + typename common_type::type + operator-(time_point const& lhs, time_point const& rhs) + { + return lhs.time_since_epoch() - rhs.time_since_epoch(); + } + + //*************************************************************************** + ///\brief C function supporting etl::chrono::high_resolution_clock + /// + /// Users of etl::chrono::high_resolution_clock should provide the definition + /// of this function. + /// etl::chrono::high_resolution_clock depends on it to get time points. + /// It should model a std::chrono::steady_clock . + /// + ///\return current time in nanosecond + //*************************************************************************** + extern "C" uint64_t etl_get_system_time_nanosec(); + + class high_resolution_clock + { + public: + using duration = nanoseconds; + using rep = duration::rep; + using period = duration::period; + using time_point = chrono::time_point; + + static bool ETL_CONSTANT is_steady = true; + + static time_point now() ETL_NOEXCEPT + { + return time_point(duration(static_cast(etl_get_system_time_nanosec()))); + } + }; + + template + bool operator==(time_point const& lhs, time_point const& rhs) + { + return lhs.time_since_epoch() == rhs.time_since_epoch(); + } + + template + bool operator!=(time_point const& lhs, time_point const& rhs) + { + return !(lhs == rhs); + } + + template + bool operator<(time_point const& lhs, time_point const& rhs) + { + return lhs.time_since_epoch() < rhs.time_since_epoch(); + } + + template + bool operator<=(time_point const& lhs, time_point const& rhs) + { + return !(rhs < lhs); + } + + template + bool operator>(time_point const& lhs, time_point const& rhs) + { + return rhs < lhs; + } + + template + bool operator>=(time_point const& lhs, time_point const& rhs) + { + return !(lhs < rhs); + } + } // namespace chrono +} // namespace etl + +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bcc8a0da7..ac81e44fe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -58,6 +58,7 @@ add_executable(etl_tests test_callback_timer_locked.cpp test_char_traits.cpp test_checksum.cpp + test_chrono.cpp test_circular_buffer.cpp test_circular_buffer_external_buffer.cpp test_circular_iterator.cpp diff --git a/test/test_chrono.cpp b/test/test_chrono.cpp new file mode 100644 index 000000000..0ff13057a --- /dev/null +++ b/test/test_chrono.cpp @@ -0,0 +1,555 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 BMW AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/chrono.h" + +#include +#include + +namespace chrono = etl::chrono; + +static uint64_t currentTimeNs = 0; + +extern "C" uint64_t etl_get_system_time_nanosec() +{ + return currentTimeNs; +} + +namespace chrono_test +{ + struct Clock + { + using duration = chrono::minutes; + }; + +} // namespace chrono_test + +namespace etl +{ + namespace chrono + { + template struct duration_values; + template struct duration; + template struct time_point>; + + } // namespace chrono +} // namespace etl + +static_assert( + std::is_same::duration>:: + value, + ""); +static_assert( + std::is_same::value, ""); +static_assert( + std::is_same::value, ""); +static_assert( + std::is_same::value, ""); + +namespace +{ + SUITE(test_chrono) + { + TEST(TetlurationCast) + { + chrono::duration src(1001); + { + chrono::duration cut = chrono::duration_cast>(src); + CHECK_EQUAL(1001000, cut.count()); + } + { + chrono::duration cut = chrono::duration_cast>(src); + CHECK_EQUAL(100, cut.count()); + } + { + chrono::duration cut = chrono::duration_cast>(src); + CHECK_EQUAL(100, cut.count()); + } + { + chrono::duration cut = chrono::duration_cast>(src); + CHECK_EQUAL(1001, cut.count()); + } + { + chrono::duration> cut = chrono::duration_cast>>( + chrono::duration>(4)); + CHECK_EQUAL(9, cut.count()); + } + } + + TEST(TetlurationConstructors) + { + { + chrono::duration cut; + CHECK_EQUAL(0, cut.count()); + } + { + chrono::duration cut(1000); + CHECK_EQUAL(1000, cut.count()); + } + { + chrono::duration src(1000); + chrono::duration cut(src); + CHECK_EQUAL(1000, cut.count()); + } + { + chrono::duration src(1000); + chrono::duration cut(src); + CHECK_EQUAL(1000000, cut.count()); + } + } + + TEST(TetlurationAssignment) + { + chrono::duration src(1000); + chrono::duration cut; + cut = src; + CHECK_EQUAL(1000, cut.count()); + } + + TEST(TetlurationUnaryPlusMinusOperators) + { + chrono::duration cut(1000); + CHECK_EQUAL(1000, (+cut).count()); + CHECK_EQUAL(-1000, (-cut).count()); + } + + TEST(TetlurationIncrementDecrementOperators) + { + chrono::duration cut(1000); + CHECK_EQUAL(1001, (++cut).count()); + CHECK_EQUAL(1001, cut.count()); + CHECK_EQUAL(1000, (--cut).count()); + CHECK_EQUAL(1000, cut.count()); + + CHECK_EQUAL(1000, (cut++).count()); + CHECK_EQUAL(1001, cut.count()); + CHECK_EQUAL(1001, (cut--).count()); + CHECK_EQUAL(1000, cut.count()); + } + + TEST(TetlurationCompoundAssignmentOperators) + { + chrono::duration cut(1000); + chrono::duration other(500); + chrono::duration prime(737); + + CHECK_EQUAL(1500, (cut += other).count()); + CHECK_EQUAL(1500, cut.count()); + CHECK_EQUAL(1000, (cut -= other).count()); + CHECK_EQUAL(1000, cut.count()); + CHECK_EQUAL(3000, (cut *= 3).count()); + CHECK_EQUAL(3000, cut.count()); + CHECK_EQUAL(1000, (cut /= 3).count()); + CHECK_EQUAL(1000, cut.count()); + CHECK_EQUAL(263, (cut %= 737).count()); + CHECK_EQUAL(263, cut.count()); + CHECK_EQUAL(263, (cut %= prime).count()); + CHECK_EQUAL(263, cut.count()); + } + + TEST(TetlurationArithmeticOperators) + { + chrono::duration d1(500); + chrono::duration d2(1000); + chrono::duration d3(int16_t(250)); + chrono::duration prime(737); + + { + chrono::duration cut = d1 + d2; + CHECK_EQUAL(501000, cut.count()); + } + { + chrono::duration cut = d1 - d2; + CHECK_EQUAL(499000, cut.count()); + } + { + chrono::duration cut = d1 * 100; + CHECK_EQUAL(50000, cut.count()); + } + { + chrono::duration cut = 100 * d1; + CHECK_EQUAL(50000, cut.count()); + } + { + CHECK_EQUAL(2000, d1 / d3); + } + { + chrono::duration cut = d1 / 250; + CHECK_EQUAL(2, cut.count()); + } + { + chrono::duration cut = d1 % prime; + CHECK_EQUAL(int64_t(500000 % 737), cut.count()); + } + { + chrono::duration cut = d1 % 73; + CHECK_EQUAL((500 % 73), cut.count()); + } + } + + TEST(TetlurationComparisonOperators) + { + chrono::duration l1(999); + chrono::duration g1(1000); + chrono::duration g2(1000); + + CHECK_FALSE(l1 == g1); + CHECK_FALSE(g1 == l1); + CHECK_TRUE(g1 == g2); + CHECK_TRUE(g2 == g1); + + CHECK_TRUE(l1 != g1); + CHECK_TRUE(g1 != l1); + CHECK_FALSE(g1 != g2); + CHECK_FALSE(g2 != g1); + + CHECK_TRUE(l1 < g1); + CHECK_FALSE(g1 < l1); + CHECK_FALSE(g1 < g2); + CHECK_FALSE(g2 < g1); + + CHECK_TRUE(l1 <= g1); + CHECK_FALSE(g1 <= l1); + CHECK_TRUE(g1 <= g2); + CHECK_TRUE(g2 <= g1); + + CHECK_FALSE(l1 > g1); + CHECK_TRUE(g1 > l1); + CHECK_FALSE(g1 > g2); + CHECK_FALSE(g2 > g1); + + CHECK_FALSE(l1 >= g1); + CHECK_TRUE(g1 >= l1); + CHECK_TRUE(g1 >= g2); + CHECK_TRUE(g2 >= g1); + } + + TEST(TetlurationConstants) + { + CHECK_EQUAL(0, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0U, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0U, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0U, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + + CHECK_EQUAL(0U, (chrono::duration::zero().count())); + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::duration::min().count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::duration::max().count())); + } + + TEST(TestPredefinedTypes) + { + { + chrono::milliseconds cut = chrono::hours(3) + chrono::minutes(16) + chrono::seconds(35) + chrono::milliseconds(26); + CHECK_EQUAL((((((3 * 60) + 16) * 60) + 35) * 1000 + 26), cut.count()); + } + { + chrono::nanoseconds cut = chrono::milliseconds(251) + chrono::microseconds(365) + chrono::nanoseconds(857); + CHECK_EQUAL((((251 * 1000 + 365) * 1000) + 857), cut.count()); + } + } + + TEST(TestTimePointCast) + { + { + chrono::time_point> src( + chrono::duration(1001)); + { + chrono::time_point> cut = chrono::time_point_cast>(src); + CHECK_EQUAL(1001000, cut.time_since_epoch().count()); + } + } + } + + TEST(TestTimePointConstructors) + { + { + chrono::time_point cut; + CHECK_EQUAL(0, cut.time_since_epoch().count()); + } + { + chrono::time_point cut(chrono::microseconds(715)); + CHECK_EQUAL(715, cut.time_since_epoch().count()); + } + { + chrono::time_point cut( + chrono::time_point>( + chrono::duration(int16_t(715)))); + CHECK_EQUAL(715000, cut.time_since_epoch().count()); + } + { + chrono::time_point cut; + CHECK_EQUAL(0, cut.time_since_epoch().count()); + } + { + // copy constructor + chrono::time_point cut(chrono::microseconds(715)); + chrono::time_point other(cut); + CHECK_EQUAL(715, other.time_since_epoch().count()); + } + { + // assignment operator + chrono::time_point cut(chrono::microseconds(715)); + chrono::time_point other( + chrono::microseconds(716)); + + other = cut; + CHECK_EQUAL(715, other.time_since_epoch().count()); + } + } + + TEST(TestTimePointCompoundAssignmentOperators) + { + chrono::time_point cut(chrono::milliseconds(1000)); + chrono::milliseconds duration = chrono::milliseconds(500); + + CHECK_EQUAL(1500, (cut += duration).time_since_epoch().count()); + CHECK_EQUAL(1500, cut.time_since_epoch().count()); + CHECK_EQUAL(1000, (cut -= duration).time_since_epoch().count()); + CHECK_EQUAL(1000, cut.time_since_epoch().count()); + } + + TEST(TestTimePointArithmeticOperators) + { + chrono::time_point tp1(chrono::milliseconds(500)); + chrono::time_point tp2(chrono::microseconds(1000)); + chrono::microseconds d(1000); + + { + chrono::time_point cut = tp1 + d; + CHECK_EQUAL(501000, cut.time_since_epoch().count()); + } + { + chrono::time_point cut = d + tp1; + CHECK_EQUAL(501000, cut.time_since_epoch().count()); + } + { + chrono::time_point cut = tp1 - d; + CHECK_EQUAL(499000, cut.time_since_epoch().count()); + } + { + chrono::microseconds cut = tp1 - tp2; + CHECK_EQUAL(499000, cut.count()); + } + } + + TEST(TestTimePointComparisonOperators) + { + chrono::time_point l1(chrono::milliseconds(999)); + chrono::time_point g1(chrono::milliseconds(1000)); + chrono::time_point g2(chrono::milliseconds(1000)); + + CHECK_FALSE(l1 == g1); + CHECK_FALSE(g1 == l1); + CHECK_TRUE(g1 == g2); + CHECK_TRUE(g2 == g1); + + CHECK_TRUE(l1 != g1); + CHECK_TRUE(g1 != l1); + CHECK_FALSE(g1 != g2); + CHECK_FALSE(g2 != g1); + + CHECK_TRUE(l1 < g1); + CHECK_FALSE(g1 < l1); + CHECK_FALSE(g1 < g2); + CHECK_FALSE(g2 < g1); + + CHECK_TRUE(l1 <= g1); + CHECK_FALSE(g1 <= l1); + CHECK_TRUE(g1 <= g2); + CHECK_TRUE(g2 <= g1); + + CHECK_FALSE(l1 > g1); + CHECK_TRUE(g1 > l1); + CHECK_FALSE(g1 > g2); + CHECK_FALSE(g2 > g1); + + CHECK_FALSE(l1 >= g1); + CHECK_TRUE(g1 >= l1); + CHECK_TRUE(g1 >= g2); + CHECK_TRUE(g2 >= g1); + } + + TEST(TestTimePointConstants) + { + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + + CHECK_EQUAL( + std::numeric_limits::min(), + (chrono::time_point>::min() + .time_since_epoch() + .count())); + CHECK_EQUAL( + std::numeric_limits::max(), + (chrono::time_point>::max() + .time_since_epoch() + .count())); + } + + TEST(TestHighResolutionClock) + { + currentTimeNs = 15; + CHECK_EQUAL( + static_cast(currentTimeNs), chrono::high_resolution_clock::now().time_since_epoch().count()); + currentTimeNs = 0x7fffffffffffffff; + CHECK_EQUAL( + static_cast(currentTimeNs), chrono::high_resolution_clock::now().time_since_epoch().count()); + } + } +} // namespace From 9e25d547ecd07410bf079aa75f67c328611da4c5 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 3 Mar 2025 12:29:41 +0100 Subject: [PATCH 19/28] Various Cleanup Remove remove() by pointer because erase() can be used for that Fix signed distance handling, with added check for order Add missing file ID Fix File IDs Added test for algorithm.h --- include/etl/algorithm.h | 41 ++++++++++++++++++++++----- include/etl/file_error_numbers.h | 1 + include/etl/intrusive_forward_list.h | 23 --------------- include/etl/intrusive_list.h | 2 +- include/etl/private/bitset_new.h | 4 +-- include/etl/queue.h | 2 -- include/etl/reference_flat_multiset.h | 2 +- include/etl/reference_flat_set.h | 2 +- include/etl/singleton_base.h | 2 +- test/test_algorithm.cpp | 11 +++++++ test/test_intrusive_forward_list.cpp | 29 ------------------- 11 files changed, 52 insertions(+), 67 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 5dc231bb3..6907b7f33 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -44,6 +44,8 @@ SOFTWARE. #include "functional.h" #include "utility.h" #include "gcd.h" +#include "error_handler.h" +#include "exception.h" #include #include @@ -82,6 +84,27 @@ namespace etl template ETL_CONSTEXPR14 void insertion_sort(TIterator first, TIterator last, TCompare compare); + + class algorithm_exception : public etl::exception + { + public: + + algorithm_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + class algorithm_error : public algorithm_exception + { + public: + + algorithm_error(string_type file_name_, numeric_type line_number_) + : algorithm_exception(ETL_ERROR_TEXT("algorithm:error", ETL_ALGORITHM_FILE_ID"A"), file_name_, line_number_) + { + } + }; + } //***************************************************************************** @@ -2262,11 +2285,13 @@ namespace etl TOutputIterator o_begin, TOutputIterator o_end) { - size_t s_size = etl::distance(i_begin, i_end); - size_t d_size = etl::distance(o_begin, o_end); - size_t size = (s_size < d_size) ? s_size : d_size; + ptrdiff_t s_size = etl::distance(i_begin, i_end); + ETL_ASSERT(s_size >= 0, ETL_ERROR(algorithm_error)); + ptrdiff_t d_size = etl::distance(o_begin, o_end); + ETL_ASSERT(d_size >= 0, ETL_ERROR(algorithm_error)); + ptrdiff_t size = etl::min(s_size, d_size); - return etl::copy(i_begin, i_begin + size, o_begin); + return etl::copy(i_begin, i_begin + size, o_begin); } //*************************************************************************** @@ -2429,9 +2454,11 @@ namespace etl TOutputIterator o_begin, TOutputIterator o_end) { - size_t s_size = etl::distance(i_begin, i_end); - size_t d_size = etl::distance(o_begin, o_end); - size_t size = (s_size < d_size) ? s_size : d_size; + ptrdiff_t s_size = etl::distance(i_begin, i_end); + ETL_ASSERT(s_size >= 0, ETL_ERROR(algorithm_error)); + ptrdiff_t d_size = etl::distance(o_begin, o_end); + ETL_ASSERT(d_size >= 0, ETL_ERROR(algorithm_error)); + ptrdiff_t size = etl::min(s_size, d_size); return etl::move(i_begin, i_begin + size, o_begin); } diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index 64d94d573..3de007228 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -105,4 +105,5 @@ SOFTWARE. #define ETL_BASE64_FILE_ID "72" #define ETL_SINGLETON_BASE_FILE_ID "73" #define ETL_UNALIGNED_TYPE_FILE_ID "74" +#define ETL_ALGORITHM_FILE_ID "75" #endif diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index d1a024fcf..84d0aa94e 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -991,29 +991,6 @@ namespace etl } } - //************************************************************************* - // Removes the element specified by pointer. - //************************************************************************* - void remove(const_pointer element) - { - iterator i_item = begin(); - iterator i_last_item = before_begin(); - - while (i_item != end()) - { - if (&i_item == element) - { - i_item = erase_after(i_last_item); - return; - } - else - { - ++i_item; - ++i_last_item; - } - } - } - //************************************************************************* /// Removes according to a predicate. //************************************************************************* diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 6bbd906f5..5d3aec2c9 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -113,7 +113,7 @@ namespace etl public: intrusive_list_value_is_already_linked(string_type file_name_, numeric_type line_number_) - : intrusive_list_exception(ETL_ERROR_TEXT("intrusive_list:value is already linked", ETL_INTRUSIVE_LIST_FILE_ID"E"), file_name_, line_number_) + : intrusive_list_exception(ETL_ERROR_TEXT("intrusive_list:value is already linked", ETL_INTRUSIVE_LIST_FILE_ID"D"), file_name_, line_number_) { } }; diff --git a/include/etl/private/bitset_new.h b/include/etl/private/bitset_new.h index 2fcbc990e..e7673f4bb 100644 --- a/include/etl/private/bitset_new.h +++ b/include/etl/private/bitset_new.h @@ -141,7 +141,7 @@ namespace etl public: bitset_overflow(string_type file_name_, numeric_type line_number_) - : bitset_exception(ETL_ERROR_TEXT("bitset:overflow", ETL_BITSET_FILE_ID"C"), file_name_, line_number_) + : bitset_exception(ETL_ERROR_TEXT("bitset:overflow", ETL_BITSET_FILE_ID"B"), file_name_, line_number_) { } }; @@ -155,7 +155,7 @@ namespace etl public: bitset_invalid_buffer(string_type file_name_, numeric_type line_number_) - : bitset_exception(ETL_ERROR_TEXT("bitset:invalid buffer", ETL_BITSET_FILE_ID"D"), file_name_, line_number_) + : bitset_exception(ETL_ERROR_TEXT("bitset:invalid buffer", ETL_BITSET_FILE_ID"C"), file_name_, line_number_) { } }; diff --git a/include/etl/queue.h b/include/etl/queue.h index 99e4d50eb..47e9d4703 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -32,9 +32,7 @@ SOFTWARE. #define ETL_QUEUE_INCLUDED #include "platform.h" -#include "iterator.h" #include "alignment.h" -#include "array.h" #include "exception.h" #include "error_handler.h" #include "debug_count.h" diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index 9d43848df..78abcce94 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -86,7 +86,7 @@ namespace etl public: flat_multiset_iterator(string_type file_name_, numeric_type line_number_) - : flat_multiset_exception(ETL_ERROR_TEXT("flat_multiset:iterator", ETL_REFERENCE_FLAT_MULTISET_FILE_ID"C"), file_name_, line_number_) + : flat_multiset_exception(ETL_ERROR_TEXT("flat_multiset:iterator", ETL_REFERENCE_FLAT_MULTISET_FILE_ID"B"), file_name_, line_number_) { } }; diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index dfb654247..44bbea965 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -87,7 +87,7 @@ namespace etl public: flat_set_iterator(string_type file_name_, numeric_type line_number_) - : flat_set_exception(ETL_ERROR_TEXT("flat_set:iterator", ETL_REFERENCE_FLAT_SET_FILE_ID"C"), file_name_, line_number_) + : flat_set_exception(ETL_ERROR_TEXT("flat_set:iterator", ETL_REFERENCE_FLAT_SET_FILE_ID"B"), file_name_, line_number_) { } }; diff --git a/include/etl/singleton_base.h b/include/etl/singleton_base.h index eb9653b4b..72f0744aa 100644 --- a/include/etl/singleton_base.h +++ b/include/etl/singleton_base.h @@ -78,7 +78,7 @@ namespace etl public: singleton_base_already_created(string_type file_name_, numeric_type line_number_) - : singleton_base_exception(ETL_ERROR_TEXT("singleton_base:already created", ETL_SINGLETON_BASE_FILE_ID"A"), file_name_, line_number_) + : singleton_base_exception(ETL_ERROR_TEXT("singleton_base:already created", ETL_SINGLETON_BASE_FILE_ID"B"), file_name_, line_number_) { } }; diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index f12427189..2d362dd94 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -1364,6 +1364,17 @@ namespace CHECK(is_same); } + //************************************************************************* + TEST(copy_s_random_iterator) + { + int data1[] = { 1, 2, 3, 4, 5 }; + int out1[10]; + CHECK_THROW(etl::copy_s(std::end(data1), std::begin(data1), std::begin(out1), std::end(out1)), etl::algorithm_error); + CHECK_THROW(etl::copy_s(std::begin(data1), std::end(data1), std::end(out1), std::begin(out1)), etl::algorithm_error); + CHECK_THROW(etl::move_s(std::end(data1), std::begin(data1), std::begin(out1), std::end(out1)), etl::algorithm_error); + CHECK_THROW(etl::move_s(std::begin(data1), std::end(data1), std::end(out1), std::begin(out1)), etl::algorithm_error); + } + //************************************************************************* TEST(copy_4_parameter_non_random_iterator) { diff --git a/test/test_intrusive_forward_list.cpp b/test/test_intrusive_forward_list.cpp index 8134f921c..20c8d830c 100644 --- a/test/test_intrusive_forward_list.cpp +++ b/test/test_intrusive_forward_list.cpp @@ -859,35 +859,6 @@ namespace CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end()))); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_remove_by_pointer) - { - std::forward_list compare_data(sorted_data.begin(), sorted_data.end()); - DataNDC0 data0(sorted_data.begin(), sorted_data.end()); - DataNDC1 data1(sorted_data.begin(), sorted_data.end()); - - auto it = data0.begin(); - for (int i = 0; i < 7; ++i) - { - it++; - } - ItemNDCNode* element = ⁢ - - compare_data.remove(ItemNDCNode("7")); - data0.remove(*element); - - bool are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin()); - - CHECK(are_equal); - CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size()); - CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end())); - - are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin()); - CHECK(are_equal); - CHECK_EQUAL(sorted_data.size(), data1.size()); - CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end()))); - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_remove_if) { From 4ba2a99cca2239ca819d909bb75f59960a45d60b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 12 Mar 2025 10:21:53 +0100 Subject: [PATCH 20/28] Improve types --- include/etl/algorithm.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 6907b7f33..db5c3a2a5 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -2285,11 +2285,15 @@ namespace etl TOutputIterator o_begin, TOutputIterator o_end) { - ptrdiff_t s_size = etl::distance(i_begin, i_end); + using s_size_type = typename iterator_traits::difference_type; + using d_size_type = typename iterator_traits::difference_type; + using min_size_type = typename etl::common_type::type; + + s_size_type s_size = etl::distance(i_begin, i_end); ETL_ASSERT(s_size >= 0, ETL_ERROR(algorithm_error)); - ptrdiff_t d_size = etl::distance(o_begin, o_end); + d_size_type d_size = etl::distance(o_begin, o_end); ETL_ASSERT(d_size >= 0, ETL_ERROR(algorithm_error)); - ptrdiff_t size = etl::min(s_size, d_size); + min_size_type size = etl::min(s_size, d_size); return etl::copy(i_begin, i_begin + size, o_begin); } @@ -2454,11 +2458,15 @@ namespace etl TOutputIterator o_begin, TOutputIterator o_end) { - ptrdiff_t s_size = etl::distance(i_begin, i_end); + using s_size_type = typename iterator_traits::difference_type; + using d_size_type = typename iterator_traits::difference_type; + using min_size_type = typename etl::common_type::type; + + s_size_type s_size = etl::distance(i_begin, i_end); ETL_ASSERT(s_size >= 0, ETL_ERROR(algorithm_error)); - ptrdiff_t d_size = etl::distance(o_begin, o_end); + d_size_type d_size = etl::distance(o_begin, o_end); ETL_ASSERT(d_size >= 0, ETL_ERROR(algorithm_error)); - ptrdiff_t size = etl::min(s_size, d_size); + min_size_type size = etl::min(s_size, d_size); return etl::move(i_begin, i_begin + size, o_begin); } From 34a58deadcf14276f7005c57ad5b47ec56a397e7 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 8 Apr 2025 13:42:33 +0200 Subject: [PATCH 21/28] Support C++23 --- .github/workflows/clang-c++23.yml | 184 +++++++++++++ .github/workflows/gcc-c++20.yml | 2 +- .github/workflows/gcc-c++23.yml | 96 +++++++ .github/workflows/gcc-syntax-checks.yml | 72 +++++ README.md | 6 +- test/CMakeLists.txt | 13 +- .../assert_function/CMakeLists.txt | 5 +- .../exceptions/CMakeLists.txt | 5 +- .../log_errors/CMakeLists.txt | 7 +- .../log_errors_and_exceptions/CMakeLists.txt | 7 +- test/etl_initializer_list/CMakeLists.txt | 7 +- test/run-syntax-checks.sh | 248 +++++++++++++++++- test/run-tests.sh | 6 +- test/syntax_check/CMakeLists.txt | 13 +- test/test_mem_cast_ptr.cpp | 3 +- test/test_murmur3.cpp | 8 +- 16 files changed, 654 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/clang-c++23.yml create mode 100644 .github/workflows/gcc-c++23.yml diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml new file mode 100644 index 000000000..82c4a16da --- /dev/null +++ b/.github/workflows/clang-c++23.yml @@ -0,0 +1,184 @@ +name: clang-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-clang-cpp23-linux-no-stl: + name: Clang C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-linux-stl-force-cpp03: + name: Clang C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp2-linux-no-stl-force-cpp03: + name: Clang C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl: + name: Clang C++23 OSX - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl: + name: Clang C++23 OSX - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl-force-cpp03: + name: Clang C++23 OSX - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl-force-cpp03: + name: Clang C++23 OSX - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + diff --git a/.github/workflows/gcc-c++20.yml b/.github/workflows/gcc-c++20.yml index be28e824f..b17d379f2 100644 --- a/.github/workflows/gcc-c++20.yml +++ b/.github/workflows/gcc-c++20.yml @@ -88,7 +88,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++23.yml b/.github/workflows/gcc-c++23.yml new file mode 100644 index 000000000..93881f848 --- /dev/null +++ b/.github/workflows/gcc-c++23.yml @@ -0,0 +1,96 @@ +name: gcc-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-gcc-cpp23-linux-stl: + name: GCC C++23 Linux - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl: + name: GCC C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-stl-force-cpp03: + name: GCC C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl-force-cpp03: + name: GCC C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + - name: Run tests + run: ./test/etl_tests \ No newline at end of file diff --git a/.github/workflows/gcc-syntax-checks.yml b/.github/workflows/gcc-syntax-checks.yml index 75bcafa33..0e6e0d0ff 100644 --- a/.github/workflows/gcc-syntax-checks.yml +++ b/.github/workflows/gcc-syntax-checks.yml @@ -322,6 +322,78 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Build + run: | + export CC=gcc + export CXX=g++ + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-gcc-cpp23-linux-STL: + name: Syntax Check - GCC C++23 Linux STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=gcc + export CXX=g++ + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-gcc-cpp23-linux-No-STL: + name: Syntax Check - GCC C++23 Linux No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=gcc + export CXX=g++ + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-gcc-cpp23-linux-STL-Force-CPP03: + name: Syntax Check - GCC C++23 Linux STL Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=gcc + export CXX=g++ + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + gcc --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-gcc-cpp23-linux-No-STL-Force-CPP03: + name: Syntax Check - GCC C++23 Linux No STL Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + - name: Build run: | export CC=gcc diff --git a/README.md b/README.md index 50c564c75..b237c5e83 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,14 @@ Embedded Template Library (ETL) ![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++14.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++17.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++20.yml/badge.svg?branch=master) +![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++23.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-syntax-checks.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-c++11.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-c++14.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-c++17.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-c++20.yml/badge.svg?branch=master) +![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-c++23.yml/badge.svg?branch=master) ![CI](https://github.com/ETLCPP/etl/actions/workflows/clang-syntax-checks.yml/badge.svg?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/3c14cd918ccf40008d0bcd7b083d5946)](https://www.codacy.com/manual/jwellbelove/etl?utm_source=github.com&utm_medium=referral&utm_content=ETLCPP/etl&utm_campaign=Badge_Grade) @@ -44,13 +46,13 @@ The ETL is not designed to completely replace the STL, but complement it. Its design objective covers three areas. - Create a set of containers where the size or maximum size is determined at compile time. These containers are direct equivalents of those supplied in the STL. -- Be compatible with C++ 03 but implement as many of the C++ 11/14/17/20 additions as possible. +- Be compatible with C++ 03 but implement as many of the C++ 11/14/17/20/23 additions as possible. - Add other useful components that are not present in the standard library. The embedded template library has been designed for lower resource embedded applications. It contains a set of containers, algorithms and utilities, some of which emulate parts of the STL. There is no dynamic memory allocation. The library makes no use of the heap. All of the containers have a fixed capacity allowing all memory allocation to be determined at compile time. -The library is intended for any compiler that supports C++98/03/11/14/17/20. +The library is intended for any compiler that supports C++98/03/11/14/17/20/23. ## Main features diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bcc8a0da7..9b030539a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -321,20 +321,23 @@ if (ETL_CXX_STANDARD MATCHES "98") message(STATUS "Compiling for C++98") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98) elseif (ETL_CXX_STANDARD MATCHES "03") - message(STATUS "Compiling for C++03 (C++98)") + message(STATUS "Compiling for C++03 (C++98)") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98) elseif (ETL_CXX_STANDARD MATCHES "11") - message(STATUS "Compiling for C++11") + message(STATUS "Compiling for C++11") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11) elseif (ETL_CXX_STANDARD MATCHES "14") - message(STATUS "Compiling for C++14") + message(STATUS "Compiling for C++14") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14) elseif (ETL_CXX_STANDARD MATCHES "17") - message(STATUS "Compiling for C++17") + message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (NO_STL OR ETL_NO_STL) diff --git a/test/etl_error_handler/assert_function/CMakeLists.txt b/test/etl_error_handler/assert_function/CMakeLists.txt index e996a4e3a..06430b68e 100644 --- a/test/etl_error_handler/assert_function/CMakeLists.txt +++ b/test/etl_error_handler/assert_function/CMakeLists.txt @@ -31,9 +31,12 @@ elseif (ETL_CXX_STANDARD MATCHES "14") elseif (ETL_CXX_STANDARD MATCHES "17") message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (ETL_OPTIMISATION MATCHES "-O1") diff --git a/test/etl_error_handler/exceptions/CMakeLists.txt b/test/etl_error_handler/exceptions/CMakeLists.txt index fcbbdc488..4aef8c76b 100644 --- a/test/etl_error_handler/exceptions/CMakeLists.txt +++ b/test/etl_error_handler/exceptions/CMakeLists.txt @@ -29,9 +29,12 @@ elseif (ETL_CXX_STANDARD MATCHES "14") elseif (ETL_CXX_STANDARD MATCHES "17") message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (ETL_OPTIMISATION MATCHES "-O1") diff --git a/test/etl_error_handler/log_errors/CMakeLists.txt b/test/etl_error_handler/log_errors/CMakeLists.txt index 4019cf25d..6f0e8d678 100644 --- a/test/etl_error_handler/log_errors/CMakeLists.txt +++ b/test/etl_error_handler/log_errors/CMakeLists.txt @@ -27,11 +27,14 @@ elseif (ETL_CXX_STANDARD MATCHES "14") message(STATUS "Compiling for C++14") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14) elseif (ETL_CXX_STANDARD MATCHES "17") - message(STATUS "Compiling for C++17") + message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (ETL_OPTIMISATION MATCHES "-O1") diff --git a/test/etl_error_handler/log_errors_and_exceptions/CMakeLists.txt b/test/etl_error_handler/log_errors_and_exceptions/CMakeLists.txt index a043c9c25..8d08df63a 100644 --- a/test/etl_error_handler/log_errors_and_exceptions/CMakeLists.txt +++ b/test/etl_error_handler/log_errors_and_exceptions/CMakeLists.txt @@ -28,11 +28,14 @@ elseif (ETL_CXX_STANDARD MATCHES "14") message(STATUS "Compiling for C++14") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14) elseif (ETL_CXX_STANDARD MATCHES "17") - message(STATUS "Compiling for C++17") + message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (ETL_OPTIMISATION MATCHES "-O1") diff --git a/test/etl_initializer_list/CMakeLists.txt b/test/etl_initializer_list/CMakeLists.txt index 647b590ac..e9230ce16 100644 --- a/test/etl_initializer_list/CMakeLists.txt +++ b/test/etl_initializer_list/CMakeLists.txt @@ -43,11 +43,14 @@ elseif (ETL_CXX_STANDARD MATCHES "14") message(STATUS "Compiling for C++14") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14) elseif (ETL_CXX_STANDARD MATCHES "17") - message(STATUS "Compiling for C++17") + message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() target_include_directories(etl_tests diff --git a/test/run-syntax-checks.sh b/test/run-syntax-checks.sh index 92efb1b90..7d66ae10d 100644 --- a/test/run-syntax-checks.sh +++ b/test/run-syntax-checks.sh @@ -46,7 +46,7 @@ PrintHelp() echo "$HelpColour" echo "----------------------------------------------------------------------------------" echo " Syntax : ./runtests.sh " - echo " C++ Standard : a, 03, 11, 14, 17 or 20 (a = All standards) " + echo " C++ Standard : a, 03, 11, 14, 17, 20 or 23 (a = All standards) " echo " Threads : Number of threads to use. Default = 4 " echo " Compiler select : gcc or clang. Default All compilers " echo "----------------------------------------------------------------------------------" @@ -98,6 +98,8 @@ elif [ "$1" = "17" ]; then requested_cxx_standard="17" elif [ "$1" = "20" ]; then requested_cxx_standard="20" +elif [ "$1" = "23" ]; then + requested_cxx_standard="23" elif [ "$1" = "A" ]; then requested_cxx_standard="All" elif [ "$1" = "a" ]; then @@ -1291,4 +1293,248 @@ fi fi +############################################################################### +if [ "$requested_cxx_standard" = "23" ] || [ "$requested_cxx_standard" = "All" ]; then +SetCxxStandard "23" + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL - Force C++03" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL - Force C++03" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +#if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +#SetConfigurationName "No STL - User defined traits" +#compiler=$gcc_compiler +#PrintHeader +#rm -rdf bgcc +#rm -rdf bclang +#cmake -E make_directory bgcc bclang +#CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +#cmake --build bgcc +#if [ $? -eq 0 ]; then +# PassedCompilation +#else +# FailedCompilation +# exit $? +#fi +#fi + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL - Built-in traits" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL - Built-in traits" +compiler=$gcc_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bclang +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL - Force C++03" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bclang +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bclang +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL - Force C++03" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bclang +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +#if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +#SetConfigurationName "No STL - User defined traits" +#compiler=$clang_compiler +#PrintHeader +#rm -rdf bgcc +#rm -rdf bclang +#cmake -E make_directory bgcc bclang +#CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +#cmake --build bclang +#if [ $? -eq 0 ]; then +# PassedCompilation +#else +# FailedCompilation +# exit $? +#fi +#fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "STL - Built-in traits" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then +SetConfigurationName "No STL - Built-in traits" +compiler=$clang_compiler +PrintHeader +rm -rdf bgcc +rm -rdf bclang +cmake -E make_directory bgcc bclang +CC=clang CXX=clang++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=$cxx_standard .. +cmake --build bgcc +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +fi + +fi + ChecksCompleted diff --git a/test/run-tests.sh b/test/run-tests.sh index 34af8d07f..8d623201b 100644 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -56,10 +56,10 @@ PrintHelp() echo "$HelpColour" echo "-------------------------------------------------------------------------------------" echo " Syntax : ./runtests.sh " - echo " C++ Standard : 11, 14, 17 or 20 " + echo " C++ Standard : 11, 14, 17, 20 or 23 " echo " Optimisation : 0, 1, 2 or 3. Default = 0 " echo " Threads : Number of threads to use. Default = 4 " - echo " Sanitizer : s enables sanitizer checks, n disables. Default disabled " + echo " Sanitizer : s enables sanitizer checks, n disables. Default disabled " echo " Compiler select : gcc or clang. Default All compilers " echo "-------------------------------------------------------------------------------------" echo "$NoColour" @@ -123,6 +123,8 @@ elif [ "$1" = "17" ]; then cxx_standard="17" elif [ "$1" = "20" ]; then cxx_standard="20" +elif [ "$1" = "23" ]; then + cxx_standard="23" else PrintHelp exit diff --git a/test/syntax_check/CMakeLists.txt b/test/syntax_check/CMakeLists.txt index 84cce67b2..121697612 100644 --- a/test/syntax_check/CMakeLists.txt +++ b/test/syntax_check/CMakeLists.txt @@ -44,20 +44,23 @@ if (ETL_CXX_STANDARD MATCHES "98") message(STATUS "Compiling for C++98") set_property(TARGET tests PROPERTY CXX_STANDARD 98) elseif (ETL_CXX_STANDARD MATCHES "03") - message(STATUS "Compiling for C++03 (C++98)") + message(STATUS "Compiling for C++03 (C++98)") set_property(TARGET tests PROPERTY CXX_STANDARD 98) elseif (ETL_CXX_STANDARD MATCHES "11") - message(STATUS "Compiling for C++11") + message(STATUS "Compiling for C++11") set_property(TARGET tests PROPERTY CXX_STANDARD 11) elseif (ETL_CXX_STANDARD MATCHES "14") - message(STATUS "Compiling for C++14") + message(STATUS "Compiling for C++14") set_property(TARGET tests PROPERTY CXX_STANDARD 14) elseif (ETL_CXX_STANDARD MATCHES "17") - message(STATUS "Compiling for C++17") + message(STATUS "Compiling for C++17") set_property(TARGET tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET tests PROPERTY CXX_STANDARD 23) endif() target_sources(tests PRIVATE diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index e22c43222..90ce49307 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -30,6 +30,7 @@ SOFTWARE. #include "etl/mem_cast.h" #include "etl/largest.h" +#include "etl/alignment.h" #include #include @@ -72,7 +73,7 @@ namespace return reinterpret_cast(uintptr_t(i)); } - typename std::aligned_storage::type buffer; + typename etl::aligned_storage::type buffer; SUITE(test_mem_cast_ptr) { diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index c8dc0d81f..c999033f5 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -37,6 +37,8 @@ SOFTWARE. #include "etl/murmur3.h" +#include "etl/alignment.h" + namespace { SUITE(test_murmur3) @@ -44,7 +46,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_constructor) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -61,7 +63,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_values) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -85,7 +87,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_range) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; From 67ff567a9a02226a3c7d48c83aa7226759f6c8b8 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 8 Apr 2025 16:50:05 +0200 Subject: [PATCH 22/28] Fix syntax checks for correct C++ standard version --- .github/workflows/clang-syntax-checks.yml | 108 ++++++++++++++++++---- .github/workflows/gcc-syntax-checks.yml | 44 ++++----- 2 files changed, 112 insertions(+), 40 deletions(-) diff --git a/.github/workflows/clang-syntax-checks.yml b/.github/workflows/clang-syntax-checks.yml index 2baf9ef23..c0c5f4e25 100644 --- a/.github/workflows/clang-syntax-checks.yml +++ b/.github/workflows/clang-syntax-checks.yml @@ -20,7 +20,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=03 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -38,7 +38,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=03 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -56,7 +56,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -74,7 +74,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -92,7 +92,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=11 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -110,7 +110,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=11 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -128,7 +128,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -146,7 +146,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -164,7 +164,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=14 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -182,7 +182,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=14 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -200,7 +200,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -218,7 +218,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -236,7 +236,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -254,7 +254,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -272,7 +272,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -290,7 +290,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -308,7 +308,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -326,6 +326,78 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./test/syntax_check + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-clang-cpp23-linux-STL: + name: Syntax Check - Clang C++23 Linux STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./test/syntax_check + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-clang-cpp23-linux-No-STL: + name: Syntax Check - Clang C++23 Linux No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./test/syntax_check + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-clang-cpp23-linux-STL-Force-CPP03: + name: Syntax Check - Clang C++23 Linux STL Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./test/syntax_check + clang --version + make -j $(getconf _NPROCESSORS_ONLN) + + build-clang-cpp23-linux-No-STL-Force-CPP03: + name: Syntax Check - Clang C++23 Linux No STL Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./test/syntax_check clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-syntax-checks.yml b/.github/workflows/gcc-syntax-checks.yml index 0e6e0d0ff..106d6d3b5 100644 --- a/.github/workflows/gcc-syntax-checks.yml +++ b/.github/workflows/gcc-syntax-checks.yml @@ -20,7 +20,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=03 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -38,7 +38,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=03 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -56,7 +56,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -74,7 +74,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -92,7 +92,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=11 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -110,7 +110,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=11 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -128,7 +128,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -146,7 +146,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -164,7 +164,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=14 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -182,7 +182,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=14 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -200,7 +200,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -218,7 +218,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -236,7 +236,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -254,7 +254,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -272,7 +272,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -290,7 +290,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -308,7 +308,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -326,7 +326,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -344,7 +344,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -362,7 +362,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -380,7 +380,7 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -398,6 +398,6 @@ jobs: run: | export CC=gcc export CXX=g++ - cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ./test/syntax_check + cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./test/syntax_check gcc --version make -j $(getconf _NPROCESSORS_ONLN) \ No newline at end of file From 77707ecabf12bd53b792c3438bc4635f729a2f81 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 10 Apr 2025 09:10:51 +0200 Subject: [PATCH 23/28] Typo fixes --- .github/workflows/clang-c++11.yml | 4 +- .github/workflows/clang-c++14.yml | 4 +- .github/workflows/clang-c++17.yml | 4 +- .github/workflows/clang-c++20.yml | 14 +- .github/workflows/gcc-c++11.yml | 4 +- .github/workflows/gcc-c++14.yml | 4 +- .github/workflows/gcc-c++17.yml | 4 +- .github/workflows/gcc-c++20.yml | 8 +- .github/workflows/msvc.yml | 8 +- test/vs2019/etl.vcxproj | 2 +- test/vs2022/etl.vcxproj | 668 +++++++++++++++--------------- 11 files changed, 362 insertions(+), 362 deletions(-) diff --git a/.github/workflows/clang-c++11.yml b/.github/workflows/clang-c++11.yml index 3bfb863c2..2e243e80d 100644 --- a/.github/workflows/clang-c++11.yml +++ b/.github/workflows/clang-c++11.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++14.yml b/.github/workflows/clang-c++14.yml index 6ec45fdb9..7d2338d3e 100644 --- a/.github/workflows/clang-c++14.yml +++ b/.github/workflows/clang-c++14.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++17.yml b/.github/workflows/clang-c++17.yml index 789ce3be2..62afaf427 100644 --- a/.github/workflows/clang-c++17.yml +++ b/.github/workflows/clang-c++17.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++20.yml b/.github/workflows/clang-c++20.yml index 37d0b75b9..e403e5c0a 100644 --- a/.github/workflows/clang-c++20.yml +++ b/.github/workflows/clang-c++20.yml @@ -29,7 +29,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -58,7 +58,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -87,7 +87,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -109,7 +109,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -131,7 +131,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -153,7 +153,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -175,7 +175,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++11.yml b/.github/workflows/gcc-c++11.yml index 030d2482e..f4cea1b35 100644 --- a/.github/workflows/gcc-c++11.yml +++ b/.github/workflows/gcc-c++11.yml @@ -23,7 +23,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -46,7 +46,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++14.yml b/.github/workflows/gcc-c++14.yml index 9220446fd..a24f9312e 100644 --- a/.github/workflows/gcc-c++14.yml +++ b/.github/workflows/gcc-c++14.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++17.yml b/.github/workflows/gcc-c++17.yml index 34929496d..f16538ffa 100644 --- a/.github/workflows/gcc-c++17.yml +++ b/.github/workflows/gcc-c++17.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++20.yml b/.github/workflows/gcc-c++20.yml index be28e824f..35de10cff 100644 --- a/.github/workflows/gcc-c++20.yml +++ b/.github/workflows/gcc-c++20.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -66,7 +66,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -88,7 +88,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 8324c507a..f910048a0 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -21,7 +21,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -42,7 +42,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -64,7 +64,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -86,7 +86,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index ca3db2abf..2a6518f02 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1369,7 +1369,7 @@ Level2 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions) ../../../unittest-cpp/;../../include;../../test diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index dfa03400a..1bdfff066 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -49,12 +49,12 @@ Debug MSVC C++20 - Force C++03 x64 - - Debug MSVC C++20 - Forve C++03 - No virtual messages + + Debug MSVC C++20 - Force C++03 - No virtual messages Win32 - - Debug MSVC C++20 - Forve C++03 - No virtual messages + + Debug MSVC C++20 - Force C++03 - No virtual messages x64 @@ -150,7 +150,7 @@ Unicode false - + Application true v143 @@ -396,7 +396,7 @@ v143 Unicode - + Application true v143 @@ -653,7 +653,7 @@ - + @@ -764,7 +764,7 @@ - + @@ -902,7 +902,7 @@ true $(Configuration)\ - + true true $(Configuration)\ @@ -1089,7 +1089,7 @@ true true - + true true @@ -1351,7 +1351,7 @@ "$(OutDir)\etl.exe" - + @@ -1655,7 +1655,7 @@ Level2 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions) ../../../unittest-cpp/;../../include;../../test @@ -2258,7 +2258,7 @@ $(OutDir)\etl.exe - + @@ -3449,14 +3449,14 @@ true true true - true + true true true true true - true + true true true true @@ -3495,7 +3495,7 @@ true true true - true + true true true true @@ -3534,7 +3534,7 @@ true true true - true + true true true true @@ -3573,7 +3573,7 @@ true true true - true + true true true true @@ -3665,7 +3665,7 @@ true true true - true + true true @@ -3681,14 +3681,14 @@ true true true - true + true true true true true - true + true true true true @@ -3727,7 +3727,7 @@ true true true - true + true true true true @@ -3766,7 +3766,7 @@ true true true - true + true true true true @@ -3805,7 +3805,7 @@ true true true - true + true true true true @@ -3855,7 +3855,7 @@ true true true - true + true true @@ -3871,7 +3871,7 @@ true true true - true + true true @@ -3887,7 +3887,7 @@ true true true - true + true true @@ -3903,7 +3903,7 @@ true true true - true + true true @@ -3919,7 +3919,7 @@ true true true - true + true true @@ -3935,7 +3935,7 @@ true true true - true + true true @@ -3951,7 +3951,7 @@ true true true - true + true true @@ -3967,7 +3967,7 @@ true true true - true + true true @@ -3983,7 +3983,7 @@ true true true - true + true true true true @@ -3997,7 +3997,7 @@ true true true - true + true true @@ -4013,7 +4013,7 @@ true true true - true + true true true true @@ -4027,7 +4027,7 @@ true true true - true + true true @@ -4043,7 +4043,7 @@ true true true - true + true true @@ -4059,7 +4059,7 @@ true true true - true + true true @@ -4075,7 +4075,7 @@ true true true - true + true true @@ -4091,7 +4091,7 @@ true true true - true + true true @@ -4107,7 +4107,7 @@ true true true - true + true true @@ -4123,7 +4123,7 @@ true true true - true + true true @@ -4139,7 +4139,7 @@ true true true - true + true true true true @@ -4153,7 +4153,7 @@ true true true - true + true true @@ -4169,7 +4169,7 @@ true true true - true + true true @@ -4185,7 +4185,7 @@ true true true - true + true true @@ -4201,7 +4201,7 @@ true true true - true + true true @@ -4217,7 +4217,7 @@ true true true - true + true true @@ -4233,7 +4233,7 @@ true true true - true + true true @@ -4249,7 +4249,7 @@ true true true - true + true true @@ -4265,7 +4265,7 @@ true true true - true + true true @@ -4281,7 +4281,7 @@ true true true - true + true true @@ -4297,7 +4297,7 @@ true true true - true + true true @@ -4313,7 +4313,7 @@ true true true - true + true true @@ -4329,7 +4329,7 @@ true true true - true + true true @@ -4345,7 +4345,7 @@ true true true - true + true true @@ -4361,7 +4361,7 @@ true true true - true + true true @@ -4377,7 +4377,7 @@ true true true - true + true true @@ -4393,7 +4393,7 @@ true true true - true + true true @@ -4409,7 +4409,7 @@ true true true - true + true true @@ -4425,7 +4425,7 @@ true true true - true + true true @@ -4441,7 +4441,7 @@ true true true - true + true true @@ -4457,7 +4457,7 @@ true true true - true + true true @@ -4473,7 +4473,7 @@ true true true - true + true true @@ -4489,7 +4489,7 @@ true true true - true + true true @@ -4505,7 +4505,7 @@ true true true - true + true true @@ -4521,7 +4521,7 @@ true true true - true + true true @@ -4537,7 +4537,7 @@ true true true - true + true true @@ -4553,7 +4553,7 @@ true true true - true + true true true true @@ -4567,7 +4567,7 @@ true true true - true + true true @@ -4583,7 +4583,7 @@ true true true - true + true true @@ -4599,7 +4599,7 @@ true true true - true + true true @@ -4615,7 +4615,7 @@ true true true - true + true true @@ -4631,7 +4631,7 @@ true true true - true + true true @@ -4647,7 +4647,7 @@ true true true - true + true true @@ -4663,7 +4663,7 @@ true true true - true + true true @@ -4679,7 +4679,7 @@ true true true - true + true true @@ -4695,7 +4695,7 @@ true true true - true + true true @@ -4711,7 +4711,7 @@ true true true - true + true true @@ -4727,7 +4727,7 @@ true true true - true + true true @@ -4743,7 +4743,7 @@ true true true - true + true true @@ -4759,7 +4759,7 @@ true true true - true + true true @@ -4775,7 +4775,7 @@ true true true - true + true true @@ -4791,7 +4791,7 @@ true true true - true + true true @@ -4807,7 +4807,7 @@ true true true - true + true true @@ -4823,7 +4823,7 @@ true true true - true + true true @@ -4839,7 +4839,7 @@ true true true - true + true true @@ -4855,7 +4855,7 @@ true true true - true + true true @@ -4871,7 +4871,7 @@ true true true - true + true true @@ -4887,7 +4887,7 @@ true true true - true + true true @@ -4903,7 +4903,7 @@ true true true - true + true true @@ -4919,7 +4919,7 @@ true true true - true + true true @@ -4935,7 +4935,7 @@ true true true - true + true true @@ -4951,7 +4951,7 @@ true true true - true + true true @@ -4967,7 +4967,7 @@ true true true - true + true true @@ -4983,7 +4983,7 @@ true true true - true + true true @@ -4999,7 +4999,7 @@ true true true - true + true true @@ -5015,7 +5015,7 @@ true true true - true + true true @@ -5031,7 +5031,7 @@ true true true - true + true true @@ -5047,7 +5047,7 @@ true true true - true + true true @@ -5063,7 +5063,7 @@ true true true - true + true true @@ -5079,7 +5079,7 @@ true true true - true + true true @@ -5095,7 +5095,7 @@ true true true - true + true true @@ -5111,7 +5111,7 @@ true true true - true + true true @@ -5127,7 +5127,7 @@ true true true - true + true true @@ -5143,7 +5143,7 @@ true true true - true + true true @@ -5159,7 +5159,7 @@ true true true - true + true true @@ -5175,7 +5175,7 @@ true true true - true + true true @@ -5191,7 +5191,7 @@ true true true - true + true true @@ -5207,7 +5207,7 @@ true true true - true + true true @@ -5223,7 +5223,7 @@ true true true - true + true true @@ -5239,7 +5239,7 @@ true true true - true + true true @@ -5255,7 +5255,7 @@ true true true - true + true true @@ -5271,7 +5271,7 @@ true true true - true + true true @@ -5287,7 +5287,7 @@ true true true - true + true true @@ -5303,7 +5303,7 @@ true true true - true + true true @@ -5319,7 +5319,7 @@ true true true - true + true true @@ -5335,7 +5335,7 @@ true true true - true + true true @@ -5351,7 +5351,7 @@ true true true - true + true true @@ -5367,7 +5367,7 @@ true true true - true + true true @@ -5383,7 +5383,7 @@ true true true - true + true true @@ -5399,7 +5399,7 @@ true true true - true + true true @@ -5415,7 +5415,7 @@ true true true - true + true true @@ -5431,7 +5431,7 @@ true true true - true + true true @@ -5447,7 +5447,7 @@ true true true - true + true true @@ -5463,7 +5463,7 @@ true true true - true + true true @@ -5479,7 +5479,7 @@ true true true - true + true true @@ -5495,7 +5495,7 @@ true true true - true + true true @@ -5511,7 +5511,7 @@ true true true - true + true true @@ -5527,7 +5527,7 @@ true true true - true + true true @@ -5543,7 +5543,7 @@ true true true - true + true true @@ -5559,7 +5559,7 @@ true true true - true + true true @@ -5575,7 +5575,7 @@ true true true - true + true true @@ -5591,7 +5591,7 @@ true true true - true + true true @@ -5607,7 +5607,7 @@ true true true - true + true true @@ -5623,7 +5623,7 @@ true true true - true + true true @@ -5639,7 +5639,7 @@ true true true - true + true true @@ -5655,7 +5655,7 @@ true true true - true + true true @@ -5671,7 +5671,7 @@ true true true - true + true true @@ -5687,7 +5687,7 @@ true true true - true + true true @@ -5703,7 +5703,7 @@ true true true - true + true true @@ -5719,7 +5719,7 @@ true true true - true + true true @@ -5735,7 +5735,7 @@ true true true - true + true true @@ -5751,7 +5751,7 @@ true true true - true + true true @@ -5767,7 +5767,7 @@ true true true - true + true true @@ -5783,7 +5783,7 @@ true true true - true + true true @@ -5799,7 +5799,7 @@ true true true - true + true true @@ -5815,7 +5815,7 @@ true true true - true + true true @@ -5831,7 +5831,7 @@ true true true - true + true true @@ -5847,7 +5847,7 @@ true true true - true + true true @@ -5863,7 +5863,7 @@ true true true - true + true true @@ -5879,7 +5879,7 @@ true true true - true + true true @@ -5895,7 +5895,7 @@ true true true - true + true true true true @@ -5909,7 +5909,7 @@ true true true - true + true true @@ -5925,7 +5925,7 @@ true true true - true + true true @@ -5941,7 +5941,7 @@ true true true - true + true true @@ -5957,7 +5957,7 @@ true true true - true + true true @@ -5973,7 +5973,7 @@ true true true - true + true true @@ -5989,7 +5989,7 @@ true true true - true + true true @@ -6005,7 +6005,7 @@ true true true - true + true true @@ -6021,7 +6021,7 @@ true true true - true + true true @@ -6037,7 +6037,7 @@ true true true - true + true true @@ -6053,7 +6053,7 @@ true true true - true + true true @@ -6069,7 +6069,7 @@ true true true - true + true true @@ -6085,7 +6085,7 @@ true true true - true + true true @@ -6101,7 +6101,7 @@ true true true - true + true true @@ -6117,7 +6117,7 @@ true true true - true + true true @@ -6133,7 +6133,7 @@ true true true - true + true true @@ -6149,7 +6149,7 @@ true true true - true + true true @@ -6165,7 +6165,7 @@ true true true - true + true true @@ -6181,7 +6181,7 @@ true true true - true + true true @@ -6197,7 +6197,7 @@ true true true - true + true true @@ -6213,7 +6213,7 @@ true true true - true + true true @@ -6229,7 +6229,7 @@ true true true - true + true true @@ -6245,7 +6245,7 @@ true true true - true + true true @@ -6261,7 +6261,7 @@ true true true - true + true true @@ -6277,7 +6277,7 @@ true true true - true + true true @@ -6293,7 +6293,7 @@ true true true - true + true true @@ -6309,7 +6309,7 @@ true true true - true + true true @@ -6325,7 +6325,7 @@ true true true - true + true true @@ -6341,7 +6341,7 @@ true true true - true + true true @@ -6357,7 +6357,7 @@ true true true - true + true true @@ -6373,7 +6373,7 @@ true true true - true + true true @@ -6389,7 +6389,7 @@ true true true - true + true true @@ -6405,7 +6405,7 @@ true true true - true + true true @@ -6421,7 +6421,7 @@ true true true - true + true true @@ -6437,7 +6437,7 @@ true true true - true + true true @@ -6453,7 +6453,7 @@ true true true - true + true true @@ -6469,7 +6469,7 @@ true true true - true + true true @@ -6485,7 +6485,7 @@ true true true - true + true true @@ -6501,7 +6501,7 @@ true true true - true + true true @@ -6517,7 +6517,7 @@ true true true - true + true true @@ -6533,7 +6533,7 @@ true true true - true + true true @@ -6549,7 +6549,7 @@ true true true - true + true true @@ -6565,7 +6565,7 @@ true true true - true + true true @@ -6581,7 +6581,7 @@ true true true - true + true true @@ -6597,7 +6597,7 @@ true true true - true + true true @@ -6613,7 +6613,7 @@ true true true - true + true true @@ -6629,7 +6629,7 @@ true true true - true + true true @@ -6645,7 +6645,7 @@ true true true - true + true true @@ -6661,7 +6661,7 @@ true true true - true + true true @@ -6677,7 +6677,7 @@ true true true - true + true true @@ -6693,7 +6693,7 @@ true true true - true + true true @@ -6709,7 +6709,7 @@ true true true - true + true true @@ -6725,7 +6725,7 @@ true true true - true + true true @@ -6741,7 +6741,7 @@ true true true - true + true true @@ -6757,7 +6757,7 @@ true true true - true + true true @@ -6773,7 +6773,7 @@ true true true - true + true true @@ -6789,7 +6789,7 @@ true true true - true + true true @@ -6805,7 +6805,7 @@ true true true - true + true true @@ -6821,7 +6821,7 @@ true true true - true + true true @@ -6837,7 +6837,7 @@ true true true - true + true true @@ -6853,7 +6853,7 @@ true true true - true + true true @@ -6869,7 +6869,7 @@ true true true - true + true true @@ -6885,7 +6885,7 @@ true true true - true + true true @@ -6901,7 +6901,7 @@ true true true - true + true true @@ -6917,7 +6917,7 @@ true true true - true + true true @@ -6933,7 +6933,7 @@ true true true - true + true true @@ -6949,7 +6949,7 @@ true true true - true + true true @@ -6965,7 +6965,7 @@ true true true - true + true true @@ -6981,7 +6981,7 @@ true true true - true + true true @@ -6997,7 +6997,7 @@ true true true - true + true true @@ -7013,7 +7013,7 @@ true true true - true + true true @@ -7029,7 +7029,7 @@ true true true - true + true true @@ -7045,7 +7045,7 @@ true true true - true + true true @@ -7061,7 +7061,7 @@ true true true - true + true true @@ -7077,7 +7077,7 @@ true true true - true + true true @@ -7093,7 +7093,7 @@ true true true - true + true true @@ -7109,7 +7109,7 @@ true true true - true + true true @@ -7125,7 +7125,7 @@ true true true - true + true true @@ -7141,7 +7141,7 @@ true true true - true + true true @@ -7157,7 +7157,7 @@ true true true - true + true true @@ -7173,7 +7173,7 @@ true true true - true + true true @@ -7189,7 +7189,7 @@ true true true - true + true true @@ -7205,7 +7205,7 @@ true true true - true + true true @@ -7221,7 +7221,7 @@ true true true - true + true true @@ -7237,7 +7237,7 @@ true true true - true + true true @@ -7253,7 +7253,7 @@ true true true - true + true true @@ -7269,7 +7269,7 @@ true true true - true + true true @@ -7285,7 +7285,7 @@ true true true - true + true true @@ -7301,7 +7301,7 @@ true true true - true + true true @@ -7317,7 +7317,7 @@ true true true - true + true true @@ -7333,7 +7333,7 @@ true true true - true + true true @@ -7349,7 +7349,7 @@ true true true - true + true true true true @@ -7363,7 +7363,7 @@ true true true - true + true true @@ -7379,7 +7379,7 @@ true true true - true + true true @@ -7395,7 +7395,7 @@ true true true - true + true true @@ -7411,7 +7411,7 @@ true true true - true + true true @@ -7427,7 +7427,7 @@ true true true - true + true true @@ -7443,7 +7443,7 @@ true true true - true + true true @@ -7459,7 +7459,7 @@ true true true - true + true true @@ -7475,7 +7475,7 @@ true true true - true + true true @@ -7491,7 +7491,7 @@ true true true - true + true true @@ -7507,7 +7507,7 @@ true true true - true + true true @@ -7523,7 +7523,7 @@ true true true - true + true true @@ -7539,7 +7539,7 @@ true true true - true + true true @@ -7555,7 +7555,7 @@ true true true - true + true true @@ -7571,7 +7571,7 @@ true true true - true + true true @@ -7587,7 +7587,7 @@ true true true - true + true true @@ -7603,7 +7603,7 @@ true true true - true + true true @@ -7619,7 +7619,7 @@ true true true - true + true true true true @@ -7633,7 +7633,7 @@ true true true - true + true true @@ -7649,7 +7649,7 @@ true true true - true + true true @@ -7665,7 +7665,7 @@ true true true - true + true true @@ -7681,7 +7681,7 @@ true true true - true + true true @@ -7697,7 +7697,7 @@ true true true - true + true true @@ -7713,7 +7713,7 @@ true true true - true + true true @@ -7729,7 +7729,7 @@ true true true - true + true true @@ -7745,7 +7745,7 @@ true true true - true + true true @@ -7761,7 +7761,7 @@ true true true - true + true true @@ -7777,7 +7777,7 @@ true true true - true + true true @@ -7793,7 +7793,7 @@ true true true - true + true true @@ -7809,7 +7809,7 @@ true true true - true + true true @@ -7825,7 +7825,7 @@ true true true - true + true true @@ -7841,7 +7841,7 @@ true true true - true + true true @@ -7857,7 +7857,7 @@ true true true - true + true true @@ -7873,7 +7873,7 @@ true true true - true + true true @@ -7889,7 +7889,7 @@ true true true - true + true true @@ -7905,7 +7905,7 @@ true true true - true + true true @@ -7921,7 +7921,7 @@ true true true - true + true true @@ -7937,7 +7937,7 @@ true true true - true + true true @@ -7953,7 +7953,7 @@ true true true - true + true true @@ -7969,7 +7969,7 @@ true true true - true + true true @@ -7985,7 +7985,7 @@ true true true - true + true true @@ -8001,7 +8001,7 @@ true true true - true + true true @@ -8017,7 +8017,7 @@ true true true - true + true true @@ -8033,7 +8033,7 @@ true true true - true + true true @@ -8049,7 +8049,7 @@ true true true - true + true true @@ -8065,7 +8065,7 @@ true true true - true + true true @@ -8081,7 +8081,7 @@ true true true - true + true true @@ -8097,7 +8097,7 @@ true true true - true + true true @@ -8113,7 +8113,7 @@ true true true - true + true true @@ -8129,7 +8129,7 @@ true true true - true + true true @@ -8145,7 +8145,7 @@ true true true - true + true true @@ -8161,7 +8161,7 @@ true true true - true + true true @@ -8177,7 +8177,7 @@ true true true - true + true true @@ -8193,7 +8193,7 @@ true true true - true + true true @@ -8209,7 +8209,7 @@ true true true - true + true true @@ -8225,7 +8225,7 @@ true true true - true + true true @@ -8241,7 +8241,7 @@ true true true - true + true true @@ -8257,7 +8257,7 @@ true true true - true + true true @@ -8273,7 +8273,7 @@ true true true - true + true true @@ -8289,7 +8289,7 @@ true true true - true + true true @@ -8305,7 +8305,7 @@ true true true - true + true true @@ -8321,7 +8321,7 @@ true true true - true + true true @@ -8337,7 +8337,7 @@ true true true - true + true true @@ -8353,7 +8353,7 @@ true true true - true + true true @@ -8369,7 +8369,7 @@ true true true - true + true @@ -8392,7 +8392,7 @@ false false false - false + false @@ -8546,7 +8546,7 @@ false false false - false + false false false false @@ -8587,7 +8587,7 @@ false false false - false + false false false false @@ -8647,7 +8647,7 @@ false false false - false + false false false false @@ -8688,7 +8688,7 @@ false false false - false + false false false false @@ -8743,7 +8743,7 @@ false false false - false + false false false false @@ -8784,7 +8784,7 @@ false false false - false + false false false false @@ -8829,7 +8829,7 @@ false false false - false + false false false false @@ -8870,7 +8870,7 @@ false false false - false + false false false false @@ -8915,7 +8915,7 @@ false false false - false + false false false false @@ -8956,7 +8956,7 @@ false false false - false + false false false false @@ -9001,7 +9001,7 @@ false false false - false + false false false false @@ -9042,7 +9042,7 @@ false false false - false + false false false false @@ -9092,7 +9092,7 @@ false false false - false + false false false false @@ -9133,7 +9133,7 @@ false false false - false + false false false false @@ -9182,7 +9182,7 @@ false false false - false + false false false false @@ -9223,7 +9223,7 @@ false false false - false + false false false false @@ -9280,7 +9280,7 @@ false false false - false + false false false false @@ -9321,7 +9321,7 @@ false false false - false + false false false false @@ -9577,14 +9577,14 @@ true true true - true + true true true true true - true + true true true true @@ -9623,7 +9623,7 @@ true true true - true + true true true true @@ -9662,7 +9662,7 @@ true true true - true + true true true true @@ -9701,7 +9701,7 @@ true true true - true + true true true true @@ -9755,7 +9755,7 @@ true true true - true + true @@ -9772,4 +9772,4 @@ - \ No newline at end of file + From 063f8d5a541f04ccffa081b3d75c4cac54bd13f7 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 10 Apr 2025 10:55:46 +0200 Subject: [PATCH 24/28] Fix typos --- .github/workflows/clang-c++11.yml | 4 ++-- .github/workflows/clang-c++14.yml | 4 ++-- .github/workflows/clang-c++17.yml | 4 ++-- .github/workflows/clang-c++20.yml | 14 +++++++------- .github/workflows/clang-c++23.yml | 14 +++++++------- .github/workflows/gcc-c++11.yml | 4 ++-- .github/workflows/gcc-c++14.yml | 4 ++-- .github/workflows/gcc-c++17.yml | 4 ++-- .github/workflows/gcc-c++20.yml | 8 ++++---- .github/workflows/gcc-c++23.yml | 8 ++++---- .github/workflows/msvc.yml | 8 ++++---- test/vs2019/etl.vcxproj | 2 +- test/vs2022/etl.vcxproj | 2 +- 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/clang-c++11.yml b/.github/workflows/clang-c++11.yml index 3bfb863c2..2e243e80d 100644 --- a/.github/workflows/clang-c++11.yml +++ b/.github/workflows/clang-c++11.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++14.yml b/.github/workflows/clang-c++14.yml index 6ec45fdb9..7d2338d3e 100644 --- a/.github/workflows/clang-c++14.yml +++ b/.github/workflows/clang-c++14.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++17.yml b/.github/workflows/clang-c++17.yml index 789ce3be2..62afaf427 100644 --- a/.github/workflows/clang-c++17.yml +++ b/.github/workflows/clang-c++17.yml @@ -22,7 +22,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++20.yml b/.github/workflows/clang-c++20.yml index 37d0b75b9..e403e5c0a 100644 --- a/.github/workflows/clang-c++20.yml +++ b/.github/workflows/clang-c++20.yml @@ -29,7 +29,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -58,7 +58,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -87,7 +87,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -109,7 +109,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -131,7 +131,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -153,7 +153,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -175,7 +175,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml index 82c4a16da..e38d7ea47 100644 --- a/.github/workflows/clang-c++23.yml +++ b/.github/workflows/clang-c++23.yml @@ -29,7 +29,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -58,7 +58,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -87,7 +87,7 @@ jobs: export CC=clang-17 export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ clang-17 --version make -j $(getconf _NPROCESSORS_ONLN) @@ -109,7 +109,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -131,7 +131,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -153,7 +153,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) @@ -175,7 +175,7 @@ jobs: export CC=clang export CXX=clang++ export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 - cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ clang --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++11.yml b/.github/workflows/gcc-c++11.yml index 030d2482e..f4cea1b35 100644 --- a/.github/workflows/gcc-c++11.yml +++ b/.github/workflows/gcc-c++11.yml @@ -23,7 +23,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -46,7 +46,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=11 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=11 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++14.yml b/.github/workflows/gcc-c++14.yml index 9220446fd..a24f9312e 100644 --- a/.github/workflows/gcc-c++14.yml +++ b/.github/workflows/gcc-c++14.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=14 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=14 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++17.yml b/.github/workflows/gcc-c++17.yml index 34929496d..f16538ffa 100644 --- a/.github/workflows/gcc-c++17.yml +++ b/.github/workflows/gcc-c++17.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++20.yml b/.github/workflows/gcc-c++20.yml index b17d379f2..35de10cff 100644 --- a/.github/workflows/gcc-c++20.yml +++ b/.github/workflows/gcc-c++20.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -66,7 +66,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -88,7 +88,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=20 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=20 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/gcc-c++23.yml b/.github/workflows/gcc-c++23.yml index 93881f848..c54029ee8 100644 --- a/.github/workflows/gcc-c++23.yml +++ b/.github/workflows/gcc-c++23.yml @@ -22,7 +22,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -44,7 +44,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=23 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -66,7 +66,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) @@ -88,7 +88,7 @@ jobs: export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 export CC=gcc export CXX=g++ - cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=23 ./ gcc --version make -j $(getconf _NPROCESSORS_ONLN) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 8324c507a..f910048a0 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -21,7 +21,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=20 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -42,7 +42,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -64,7 +64,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln @@ -86,7 +86,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=17 ./ + cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_CXX_STANDARD=17 ./ MSBuild.exe -version MSBuild.exe .\etl.sln diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index ca3db2abf..2a6518f02 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1369,7 +1369,7 @@ Level2 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions) ../../../unittest-cpp/;../../include;../../test diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index dfa03400a..caef5e307 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -1655,7 +1655,7 @@ Level2 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions) ../../../unittest-cpp/;../../include;../../test From 8201157d8e27276e45167beacc7b6038e8d2fc3f Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 10 Apr 2025 14:49:43 +0200 Subject: [PATCH 25/28] Fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa9253af5..a94b523d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ If your are considering creating a pull request, please observe the following: - Do not initiate a pull request until all of the units tests pass. - Branches should be based on the branch `master`. -There is a project file for VS2022 for C++14, 17, 20, and bash scripts that run the tests for C++11, 14, 17, 20 under Linux with GCC and Clang. +There is a project file for VS2022 for C++14, 17, 20, 23 and bash scripts that run the tests for C++11, 14, 17, 20, 23 under Linux with GCC and Clang. If you are thinking of adding a new feature then raise this on the GitHub Issues page for disccussion as the maintainers and user of the ETL may have questions or suggestions. It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature. From 93a8f472d97d24e1e3be5551de2c3e33ebb44e4c Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 10 Apr 2025 14:50:35 +0200 Subject: [PATCH 26/28] Fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa9253af5..693910fe1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,5 +9,5 @@ If your are considering creating a pull request, please observe the following: There is a project file for VS2022 for C++14, 17, 20, and bash scripts that run the tests for C++11, 14, 17, 20 under Linux with GCC and Clang. -If you are thinking of adding a new feature then raise this on the GitHub Issues page for disccussion as the maintainers and user of the ETL may have questions or suggestions. +If you are thinking of adding a new feature then raise this on the GitHub Issues page for discussion as the maintainers and user of the ETL may have questions or suggestions. It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature. From 0f1f0da4b73f27e51ea74e73320a3705086340de Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 25 Apr 2025 16:10:43 +0200 Subject: [PATCH 27/28] Support const pointers to etl::is_aligned() --- include/etl/alignment.h | 6 +++--- test/test_alignment.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/etl/alignment.h b/include/etl/alignment.h index c6a4de066..7de4d4718 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -74,7 +74,7 @@ namespace etl //***************************************************************************** /// Check that 'p' has 'required_alignment'. //***************************************************************************** - inline bool is_aligned(void* p, size_t required_alignment) + inline bool is_aligned(const void* p, size_t required_alignment) { uintptr_t address = reinterpret_cast(p); return (address % required_alignment) == 0U; @@ -84,7 +84,7 @@ namespace etl /// Check that 'p' has 'Alignment'. //***************************************************************************** template - bool is_aligned(void* p) + bool is_aligned(const void* p) { uintptr_t address = reinterpret_cast(p); return (address % Alignment) == 0U; @@ -94,7 +94,7 @@ namespace etl /// Check that 'p' has the alignment of 'T'. //***************************************************************************** template - bool is_aligned(void* p) + bool is_aligned(const void* p) { return is_aligned::value>(p); } diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 29de827a1..8b9d72015 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -144,6 +144,23 @@ namespace CHECK_FALSE(etl::is_aligned(p)); } + //************************************************************************* + TEST(test_is_aligned_tests_const) + { + alignas(uint32_t) const char buffer[2U * sizeof(uint32_t)] = {0, 1}; + + const char* p = buffer; + + CHECK_TRUE(etl::is_aligned(p, std::alignment_of())); + CHECK_TRUE(etl::is_aligned(p)); + CHECK_TRUE(etl::is_aligned(p)); + + ++p; + CHECK_FALSE(etl::is_aligned(p, std::alignment_of())); + CHECK_FALSE(etl::is_aligned(p)); + CHECK_FALSE(etl::is_aligned(p)); + } + //************************************************************************* TEST(test_type_with_alignment) { From bd18ba313f7d0ba1009fd94c844953bec39706e1 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 25 Apr 2025 16:00:28 +0200 Subject: [PATCH 28/28] Add take() to etl::span --- include/etl/alignment.h | 6 +- include/etl/span.h | 51 ++++++++++++ test/test_span_dynamic_extent.cpp | 131 ++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 3 deletions(-) diff --git a/include/etl/alignment.h b/include/etl/alignment.h index c6a4de066..7de4d4718 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -74,7 +74,7 @@ namespace etl //***************************************************************************** /// Check that 'p' has 'required_alignment'. //***************************************************************************** - inline bool is_aligned(void* p, size_t required_alignment) + inline bool is_aligned(const void* p, size_t required_alignment) { uintptr_t address = reinterpret_cast(p); return (address % required_alignment) == 0U; @@ -84,7 +84,7 @@ namespace etl /// Check that 'p' has 'Alignment'. //***************************************************************************** template - bool is_aligned(void* p) + bool is_aligned(const void* p) { uintptr_t address = reinterpret_cast(p); return (address % Alignment) == 0U; @@ -94,7 +94,7 @@ namespace etl /// Check that 'p' has the alignment of 'T'. //***************************************************************************** template - bool is_aligned(void* p) + bool is_aligned(const void* p) { return is_aligned::value>(p); } diff --git a/include/etl/span.h b/include/etl/span.h index 7e4ad35ad..2d06b4481 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -87,6 +87,20 @@ namespace etl } }; + //*************************************************************************** + ///\ingroup span + /// Bad size exception. + //*************************************************************************** + class span_size_exception : public span_exception + { + public: + + span_size_exception(string_type file_name_, numeric_type line_number_) + : span_exception(ETL_ERROR_TEXT("span:size", ETL_SPAN_FILE_ID"B"), file_name_, line_number_) + { + } + }; + //*************************************************************************** /// Span - Fixed Extent //*************************************************************************** @@ -878,6 +892,43 @@ namespace etl (pend - pbegin) * sizeof(element_type) / sizeof(TNew)); } + //************************************************************************* + /// Split off and return an initial span of specified type of this span. + /// The original span is advanced by the size of the returned span. + /// \tparam TRet Returned span type + /// \param n Number of elements in returned span + //************************************************************************* + template + ETL_NODISCARD etl::span take(size_t const n) + { + ETL_STATIC_ASSERT(sizeof(TRet) % sizeof(element_type) == 0, "sizeof(TRet) must be divisible by sizeof(T)"); + + ETL_ASSERT(etl::is_aligned::value>(pbegin), ETL_ERROR(span_alignment_exception)); + ETL_ASSERT(sizeof(TRet) * n <= sizeof(element_type) * size(), ETL_ERROR(span_size_exception)); + + etl::span result = reinterpret_as().first(n); + advance(sizeof(TRet) / sizeof(element_type) * n); + return result; + } + + //************************************************************************* + /// Split off and return an initial value of specified type of this span. + /// The original span is advanced by the size of TRet + /// \tparam TRet Returned span type + //************************************************************************* + template + ETL_NODISCARD TRet& take() + { + ETL_STATIC_ASSERT(sizeof(TRet) % sizeof(element_type) == 0, "sizeof(TRet) must be divisible by sizeof(T)"); + + ETL_ASSERT(etl::is_aligned::value>(pbegin), ETL_ERROR(span_alignment_exception)); + ETL_ASSERT(sizeof(TRet) <= sizeof(element_type) * size(), ETL_ERROR(span_size_exception)); + + TRet& result = *reinterpret_cast(data()); + advance(sizeof(TRet) / sizeof(element_type)); + return result; + } + private: pointer pbegin; diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index ee85f843b..ced5a73ab 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -1370,6 +1370,137 @@ namespace CHECK_EQUAL(etl::copy(data0, data1), true); } + //************************************************************************* + TEST(test_take_span_size_error) + { + uint8_t src[] = { 0x01, 0x02, 0x03 }; + etl::span data0 = src; + + CHECK_THROW({etl::span data1 = data0.take(1); (void) data1;}, etl::span_size_exception); + } + + //************************************************************************* + TEST(test_take_span) + { + uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; + etl::span data0 = src; + + etl::span data1 = data0.take(1); + + CHECK_EQUAL(data0.size(), 4); + CHECK_EQUAL(data1.size(), 1); + CHECK_EQUAL(data1[0], 0x01); + + etl::span data2 = data0.take(1); + + CHECK_EQUAL(data0.size(), 0); + CHECK_EQUAL(data2.size(), 1); + CHECK_EQUAL(data2[0], 0x02030405); + + data1 = data0.take(0); + + CHECK_EQUAL(data0.size(), 0); + CHECK_EQUAL(data1.size(), 0); + + CHECK_THROW({etl::span data3 = data0.take(1); (void) data3;}, etl::span_size_exception); + } + + //************************************************************************* + TEST(test_take_span_2) + { + + uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a }; + etl::span data0 = src; + + etl::span data1 = data0.take(2); + + CHECK_EQUAL(data0.size(), 2); + CHECK_EQUAL(data1.size(), 2); + CHECK_EQUAL(data1[0], 0x01020304); + CHECK_EQUAL(data1[1], 0x05060708); + + etl::span data2 = data0.take(1); + + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data2.size(), 1); + CHECK_EQUAL(data2[0], 0x09); + } + + //************************************************************************* + TEST(test_take_span_const) + { + const uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a }; + etl::span data0 = src; + + etl::span data1 = data0.take(2); + + CHECK_EQUAL(data0.size(), 2); + CHECK_EQUAL(data1.size(), 2); + CHECK_EQUAL(data1[0], 0x01020304); + CHECK_EQUAL(data1[1], 0x05060708); + + etl::span data2 = data0.take(1); + + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data2.size(), 1); + CHECK_EQUAL(data2[0], 0x09); + + data2 = data0.take(0); + + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data2.size(), 0); + } + + //************************************************************************* + TEST(test_take_value) + { + uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a }; + etl::span data0 = src; + + uint8_t& data1 = data0.take(); + CHECK_EQUAL(data0.size(), 9); + CHECK_EQUAL(data1, 0x01); + + etl::be_uint32_t& data2 = data0.take(); + CHECK_EQUAL(data0.size(), 5); + CHECK_EQUAL(data2, 0x02030405); + + etl::be_uint32_t& data3 = data0.take(); + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data3, 0x06070809); + + uint8_t& data4 = data0.take(); + CHECK_EQUAL(data0.size(), 0); + CHECK_EQUAL(data4, 0x0a); + + CHECK_THROW({uint8_t& data5 = data0.take(); (void) data5;}, etl::span_size_exception); + } + + //************************************************************************* + TEST(test_take_value_const) + { + const uint8_t src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a }; + etl::span data0 = src; + + const uint8_t& data1 = data0.take(); + CHECK_EQUAL(data0.size(), 9); + CHECK_EQUAL(data1, 0x01); + + const etl::be_uint32_t& data2 = data0.take(); + CHECK_EQUAL(data0.size(), 5); + CHECK_EQUAL(data2, 0x02030405); + + const etl::be_uint32_t& data3 = data0.take(); + CHECK_EQUAL(data0.size(), 1); + CHECK_EQUAL(data3, 0x06070809); + + const uint8_t& data4 = data0.take(); + CHECK_EQUAL(data0.size(), 0); + CHECK_EQUAL(data4, 0x0a); + + CHECK_THROW({const uint8_t& data5 = data0.take(); (void) data5;}, etl::span_size_exception); + } + #include "etl/private/diagnostic_pop.h" }; }