From 70e4850a0b17e1d50f60a87cf1545e4d419c0036 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 27 Feb 2026 17:43:47 +0000 Subject: [PATCH 01/12] Updated version and release notes --- arduino/library-arduino.json | 2 +- arduino/library-arduino.properties | 2 +- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 135 ++++++++++++++++++----------- version.txt | 2 +- 7 files changed, 90 insertions(+), 57 deletions(-) diff --git a/arduino/library-arduino.json b/arduino/library-arduino.json index e6485f26..20ff8c86 100644 --- a/arduino/library-arduino.json +++ b/arduino/library-arduino.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library ETL", - "version": "20.45.0", + "version": "20.46.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/arduino/library-arduino.properties b/arduino/library-arduino.properties index a63e6411..5eae7e44 100644 --- a/arduino/library-arduino.properties +++ b/arduino/library-arduino.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.45.0 +version=20.46.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/include/etl/version.h b/include/etl/version.h index 02e931b1..962e55a6 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 45 +#define ETL_VERSION_MINOR 46 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 7f66b3b7..bc4f1da9 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.45.0", + "version": "20.46.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 16be9c21..7f1ffc3a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.45.0 +version=20.46.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 8b438c1e..12664b63 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,4 +1,37 @@ =============================================================================== +20.46.0 + +#1257 Fix year_month arithmetic and correct chrono API behavior +#1259 Suppress warnings from std in optimized builds +#1261 Fix incorrect namespace for iter_swap calls +#1262 Document how to implement platform specifics +#1264 Add template deduction guide for span from vector +#1265 Fix etl::tuple template signature error in pair assignment operator +#1266 Fix etl::as_bytes for etl::span +#1267 Update C++26 deprecated constructs to ensure future standard compliance +#1268 Remove some UB in test_vector_non_trivial.cpp +#1269 Deduce underlying storage size when constructing string_ext from char[]. +#1271 Fix return value of get_token_list +#1275 Add etl::type_list API to more classes. +#1277 Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" +#1281 Remove advance() on static spans +#1285 Manchester coding +#1286 Add missing includes +#1287 Move comparison operators of etl::expected to namespace etl +#1288 Add basic_format_arg constructor for ibasic_string +#1290 Add support for size_t and unsigned long to etl::format +#1291 Make typed_storage constructor constexpr +#1292 Add ref-qualifiers to basic_format_spec +#1299 Fix link rotations for etl::tree_node +#1303 Add constexpr to array comparison operators +#1304 Fix etl::variant get() for ambiguous types +#1307 Add more features to etl::type_list +#1308 Fix comparison and swap operators not in etl namespace +#1309 Reduce string flash usage +#1312 Enforce worse-case O(log n) dispatch for messages when using message router for c++11 and up +#1315 Add get endianness to byte stream reader + +=============================================================================== 20.45.0 Issues: @@ -18,8 +51,8 @@ Pull requests: #1238 Various cleanup #1239 Indirect vector checks #1244 Fix no check macros -#1245 Fix discrepancy with STL in max_element and minmax_element -#1246 Implement .begin() and .end() for etl::optional +#1245 Fix discrepancy with STL in max_element and minmax_element +#1246 Implement .begin() and .end() for etl::optional #1251 Add etl::inplace_function #1252 Add ThreadX mutex support #1254 Make code base with tests compile under gcc-14 @@ -149,7 +182,7 @@ Fix gamma tests (removed integral tests) #1151 test failure in i386 in 20.42.1: test_replace_strings in test_string_utilities.c fails #1152 Patch: use "python3 -m cogapp" instead of "cog" in generate.bat #1153 ROM size increase after algorithm_exception introduction -#1156 Name conflict between template parameter and status register macro on MSP430 devices +#1156 Name conflict between template parameter and status register macro on MSP430 devices #1158 Bug: Inverted logic in ! __has_include() check causes compilation failure on compilers without header Pull Requests: @@ -209,7 +242,7 @@ Pull Requests: Fixes: Fixed std::string_view include warning for < C++17 -#1123 Bug: Possible NULL Pointer Dereference in set.h +#1123 Bug: Possible NULL Pointer Dereference in set.h #1124 alignment.h won't compile as C++03 #1125 For cogapp, use cog instead of python @@ -267,7 +300,7 @@ Fixes: Pull Requests: #1109 Add detection of C++23 -#1108 Add unit tests for bit_stream +#1108 Add unit tests for bit_stream =============================================================================== 20.41.1 @@ -289,21 +322,21 @@ Added etl::tuple Added get_token_list to string_utilities to retrieve multiple tokens #757 Add etl::chrono time/date classes #962 Allow (overload) string append a string_view -#966 A constructor for delegate with a freestanding function -#1047 Deprecate etl::parameter_pack and replace with etl::type_list -#1068 Add swap(circular_buffer_ext&&) for circular_buffer_ext +#966 A constructor for delegate with a freestanding function +#1047 Deprecate etl::parameter_pack and replace with etl::type_list +#1068 Add swap(circular_buffer_ext&&) for circular_buffer_ext #1084 Add 'type' Alias to Strong Types #1085 Add The Remaining Math Operators To ETL_TYPEDEF Fixes: #1041 Incorrect rounding of scaled natural numbers in scaled_rounding -#1042 Incorrect rounding in scaled_rounding with scale of 1 +#1042 Incorrect rounding in scaled_rounding with scale of 1 #1056 variadic_variant doesn't use the type_id_t type to store type_id -#1057 ETL_DECLARE_DEBUG_COUNT increases RAM usage even when ETL_DEBUG_COUNT NOT defined -#1064 v20.40.0 error: has no member named ‘is_secure’ -#1070 MacOs Circlular buffer type conversion error (-Werror) +#1057 ETL_DECLARE_DEBUG_COUNT increases RAM usage even when ETL_DEBUG_COUNT NOT defined +#1064 v20.40.0 error: has no member named ‘is_secure’ +#1070 MacOs Circlular buffer type conversion error (-Werror) #1073 Test failure on 32-bit x86 arches -#1076 circular_buffer::pop(N) when holding trivially destructible items +#1076 circular_buffer::pop(N) when holding trivially destructible items #1077 Builds on i386 trigger -Werror=useless-cast #1078 Have etl::make_array Check for noexcept Condition #1079 Compilation errors in algorithm.h in C++03 @@ -313,30 +346,30 @@ Fixes: #1102 Optimise clear of sequence containers for trivially destructible types Pull Requests: -#1033 Add newline to end of parameter_pack.h -#1036 Add contains() and contains_node() to etl::intrusive_forward_list -#1039 Minor cleanup -#1040 Implement << operator for std basic_ostream and etl string_view -#1043 Added iterator and const_iterator to etl::ipool -#1044 Add traits to type_list -#1045 Support etl::underlying_type with compiler builtin -#1049 Various cleanup changes -#1052 Returning const ref of member from const member function +#1033 Add newline to end of parameter_pack.h +#1036 Add contains() and contains_node() to etl::intrusive_forward_list +#1039 Minor cleanup +#1040 Implement << operator for std basic_ostream and etl string_view +#1043 Added iterator and const_iterator to etl::ipool +#1044 Add traits to type_list +#1045 Support etl::underlying_type with compiler builtin +#1049 Various cleanup changes +#1052 Returning const ref of member from const member function #1055 Add enable_if restriction for span constructor from c array -#1065 Fix cmake helper functions collision -#1067 Fix missing is_secure function +#1065 Fix cmake helper functions collision +#1067 Fix missing is_secure function #1069 Support C++23 -#1072 Add swap(circular_buffer_ext&&) (#1068) -#1074 Add Zephyr build system module.yml -#1075 Add full West support for ETL in Zephyr builds +#1072 Add swap(circular_buffer_ext&&) (#1068) +#1074 Add Zephyr build system module.yml +#1075 Add full West support for ETL in Zephyr builds #1080 Fixed compilation errors in algorithm.h in C++03 and compiler warning -#1082 Support const pointers in etl::is_aligned() -#1083 Add take() to etl::span -#1088 Fix numeric overflow in bip buffer's get_write_reserve -#1089 Cleanup fixes for C++03 -#1090 Fix copy_s() for C++03 -#1103 Add IWYU pragmas to private headers which provide library symbols -#1104 Use etl::clamp for setting value in cyclic_value +#1082 Support const pointers in etl::is_aligned() +#1083 Add take() to etl::span +#1088 Fix numeric overflow in bip buffer's get_write_reserve +#1089 Cleanup fixes for C++03 +#1090 Fix copy_s() for C++03 +#1103 Add IWYU pragmas to private headers which provide library symbols +#1104 Use etl::clamp for setting value in cyclic_value =============================================================================== 20.40.0 @@ -366,7 +399,7 @@ Fixes: #957 Support heterogenous lookup for maps #959 Treat bitset with size_type #972 Template not allowed warning in parameter pack -#979 QueuedMessageRouter does not work : message are not sent to queue +#979 QueuedMessageRouter does not work : message are not sent to queue #980 Documentation clarification: Add link from endianess to unaligned_type #982 Added return to etl::optional emplace, fixed typo #984 Update Base64 Documentation @@ -452,13 +485,13 @@ Modified io_port classes so that they are not derived from iterator types. Fixes: #921 unique_ptr reset -#923 Missing equality operator for class expected +#923 Missing equality operator for class expected #930 Unused parameter warnings #931 Using etl::make_vector to make a vector of two pairs causes a compile error Features: #918 Request for additional operator support for etl::io_port_* -#919 callback_timer: expose callback_timer_data::is_active() as icallback_timer public method +#919 callback_timer: expose callback_timer_data::is_active() as icallback_timer public method #920 Define ETL_USING_LEGACY_VARIANT as a convenience macro for code that tries to support both new and legacy variants #940 Allow etl::observer notification without argument @@ -645,7 +678,7 @@ Refactored etl::itr_swap for maximum efficiency. =============================================================================== 20.38.3 -#767 etl::pool silently produces unaligned allocations for types with stricter alignment requirements than built in types +#767 etl::pool silently produces unaligned allocations for types with stricter alignment requirements than built in types =============================================================================== 20.38.2 @@ -657,7 +690,7 @@ Refactored etl::itr_swap for maximum efficiency. #758 Move assignment not working for non-empty containers #761 Make "private" includes relative #765 etl::optional cannot be constexpr -#766 etl::unique_ptr::reset() can call deleter with nullptr argument +#766 etl::unique_ptr::reset() can call deleter with nullptr argument Re-enabled bit_stream_writer tests =============================================================================== @@ -729,7 +762,7 @@ Re-enabled memcast tests. #663 Make unit tests compile for C++20 #675 Compilation error in optional.h #684 Added sanitization fix for MinGW -#687 Build failure. constexpr keyword before template keyword +#687 Build failure. constexpr keyword before template keyword #689 Add as_bytes and as_writable_bytes #690 Add rvalue accessors to expected and optional and update constructors #692 operator [] for flat_map always calls default constructor for mapped_type @@ -780,7 +813,7 @@ Convert the Visual Studio project to VS2022 20.35.13 #649 Fixed the false positive 'array-bounds' errors for ETL unit tests. #652 Fixed false positives 'maybe-uninitialized' errors for ETL unit tests. -Moved virtual functions in etl::fixed_sized_memory_block_allocator from 'private' to 'protected'. +Moved virtual functions in etl::fixed_sized_memory_block_allocator from 'private' to 'protected'. =============================================================================== 20.35.12 @@ -821,7 +854,7 @@ Added Ubuntu 22.04 to Github Actions =============================================================================== 20.35.8 -#648 Improve is_constructible, is_copy_constructible, is_move_constructible for type traits with default definitions +#648 Improve is_constructible, is_copy_constructible, is_move_constructible for type traits with default definitions #645 Avoid 'missing return statement at end of non-void function' in `etl::visit<>()`. Removed unused ETL_USE_MEM_BUILTINS option @@ -939,7 +972,7 @@ Added tests for error handler macros =============================================================================== 20.31.2 -#567 error-handler: only return when the condition is false +#567 error-handler: only return when the condition is false =============================================================================== 20.31.1 @@ -1012,7 +1045,7 @@ Updates to etl::successor and derived classes. =============================================================================== 20.27.3 -#531 Fixed: Compilation of etl::reference_counted_message_pool with ETL_LOG_ERROR +#531 Fixed: Compilation of etl::reference_counted_message_pool with ETL_LOG_ERROR enabled due to non-public inheritance. =============================================================================== @@ -1103,7 +1136,7 @@ Updated C++ standard detection. Split callback and message timer to atomic and locked interrupt versions. #480 Fixed: Double formatting with precision > 9 #481 Fixed: etl::span const data cannot be created from non const c array of data. -#482 Fixed: Two or more etl::span/array_view of different types create ambiguous overloading set +#482 Fixed: Two or more etl::span/array_view of different types create ambiguous overloading set #483 Fixed: Added Green Hills compiler to minmax push and pop. #484 Fixed: etl::vector test_uninitialized_resize_excess not calling uninitialized_resize. #485 Fixed: etl::message_packet takes message types that are not in its list. @@ -1182,7 +1215,7 @@ Improved compliance with MISRA rules Extended 'successor' handling for all derived message router types =============================================================================== -20.16.2 +20.16.2 Fixed incomplete template specialisations in type_traits.h for C++11 =============================================================================== @@ -1238,7 +1271,7 @@ Added Arduino examples. =============================================================================== 20.11.4 -Fixed etl::circular_buffer copy and move assignment bug where the destination +Fixed etl::circular_buffer copy and move assignment bug where the destination buffer was not cleared before assignment. =============================================================================== @@ -1392,7 +1425,7 @@ Added ETL_CONSTANT to numeric_limits member functions. Added initialize_free_space(), trim_to_terminator() and data_end() functions to strings for easier integration with C APIs. -=============================================================================== +=============================================================================== 20.2.3 Fixed indexing error in find_next() for etl::bitset. @@ -1679,9 +1712,9 @@ Fixed etl::stack top level assignment operator not clearing before copy. =============================================================================== 18.12.5 -Fixed issue for incorrect operation of erase(const_iterator, const_iterator) when +Fixed issue for incorrect operation of erase(const_iterator, const_iterator) when the terminating iterator was end() for etl::unordered_map, etl::unordered_multimap, -etl::unordered_set and etl::unordered_multiset. +etl::unordered_set and etl::unordered_multiset. =============================================================================== 18.12.4 @@ -1786,7 +1819,7 @@ C++03 compatibility fix for type_traits.h =============================================================================== 18.3.0 -Added etl::parameter_pack to easily extract information about the types in a +Added etl::parameter_pack to easily extract information about the types in a template parameter pack. =============================================================================== diff --git a/version.txt b/version.txt index aae4b050..cec3020e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.45.0 +20.46.0 From 7ee7f10f58d7742500197033c4ff748acccc4f06 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Mar 2026 12:27:39 +0000 Subject: [PATCH 02/12] Hotfix/etl multiset iterator invalidation during erase leads to incorrect sorted order in depth first traversal (#1317) * Fixed issue for both multiset and multimap * Added std::is_sorted checks to all map/set tests * Updated with coderabbit suggestions --------- Co-authored-by: John Wellbelove --- include/etl/multimap.h | 8 +- include/etl/multiset.h | 8 +- test/test_map.cpp | 122 +++++++++++++++++++----- test/test_multimap.cpp | 104 +++++++++++++++----- test/test_multiset.cpp | 75 ++++++++++++--- test/test_set.cpp | 163 ++++++++++++++++++++------------ test/vs2022/etl.vcxproj.filters | 6 +- 7 files changed, 353 insertions(+), 133 deletions(-) diff --git a/include/etl/multimap.h b/include/etl/multimap.h index f585e45d..b19989e0 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -761,7 +761,7 @@ namespace etl friend class imultimap; friend class const_iterator; - iterator() + iterator() : p_multimap(ETL_NULLPTR) , p_node(ETL_NULLPTR) { @@ -2181,7 +2181,7 @@ namespace etl else { // Update the direction to the replace node - node->dir = node->children[(uint_least8_t) kLeft] ? (uint_least8_t) kLeft : (uint_least8_t) kRight; + node->dir = 1 - found->dir; } } // while(node) @@ -2506,8 +2506,8 @@ namespace etl template bool operator <(const etl::imultimap& lhs, const etl::imultimap& rhs) { - return etl::lexicographical_compare(lhs.begin(), lhs.end(), - rhs.begin(), rhs.end(), + return etl::lexicographical_compare(lhs.begin(), lhs.end(), + rhs.begin(), rhs.end(), lhs.value_comp()); } diff --git a/include/etl/multiset.h b/include/etl/multiset.h index de020d28..046664af 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -1089,8 +1089,8 @@ namespace etl size_type count(key_parameter_t key) const { return count_nodes(key); - } - + } + #if ETL_USING_CPP11 //********************************************************************* template ::value, int> = 0> @@ -2167,7 +2167,7 @@ namespace etl else { // Update the direction to the replace node - node->dir = node->children[kLeft] ? kLeft : kRight; + node->dir = 1 - found->dir; } } // while(node) @@ -2487,7 +2487,7 @@ namespace etl bool operator <(const etl::imultiset& lhs, const etl::imultiset& rhs) { return ETL_OR_STD::lexicographical_compare(lhs.begin(), lhs.end(), - rhs.begin(), rhs.end(), + rhs.begin(), rhs.end(), etl::imultiset::value_compare()); } diff --git a/test/test_map.cpp b/test/test_map.cpp index 251e8408..610aa146 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -49,8 +49,8 @@ using Data = etl::map>; using Compare_Data = std::map>; #else -using Data = etl::map>; -using IData = etl::imap>; +using Data = etl::map>; +using IData = etl::imap>; using Compare_Data = std::map>; #endif @@ -233,6 +233,8 @@ namespace CHECK_EQUAL(10U, data.capacity()); CHECK_EQUAL(10U, data.max_size()); CHECK(data == check); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -257,6 +259,8 @@ namespace data2.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -281,6 +285,8 @@ namespace CHECK(2 == data2.at("2").value); CHECK(3 == data2.at("3").value); CHECK(4 == data2.at("4").value); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -304,6 +310,7 @@ namespace CHECK(d == MAX_SIZE); CHECK(data.size() == MAX_SIZE); CHECK(!data.empty()); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #if ETL_HAS_INITIALIZER_LIST @@ -324,6 +331,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -340,6 +349,8 @@ namespace otherData.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(otherData.begin(), otherData.end(), otherData.value_comp())); } //************************************************************************* @@ -358,6 +369,8 @@ namespace data2.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -366,9 +379,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); Data other_data(data); -#include "etl/private/diagnostic_self_assign_overloaded_push.h" +#include "etl/private/diagnostic_self_assign_overloaded_push.h" other_data = other_data; -#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" bool isEqual = std::equal(data.begin(), data.end(), @@ -399,6 +412,8 @@ namespace CHECK(2 == data2.at("2").value); CHECK(3 == data2.at("3").value); CHECK(4 == data2.at("4").value); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -633,6 +648,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -655,6 +672,8 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -679,6 +698,8 @@ namespace CHECK(2 == data.at("2").value); CHECK(3 == data.at("3").value); CHECK(4 == data.at("4").value); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -704,6 +725,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -723,18 +746,20 @@ namespace // Check that elements in map are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(data_result.first, ETL_OR_STD::make_pair(std::string("1"), 1)); compare_data.insert(compare_result.first, ETL_OR_STD::make_pair(std::string("1"), 1)); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -754,8 +779,8 @@ namespace // Check that elements in map are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(Data::const_iterator(data_result.first), @@ -764,10 +789,12 @@ namespace ETL_OR_STD::make_pair(std::string("1"), 1)); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -792,6 +819,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -804,10 +833,12 @@ namespace compare_data.insert(random_data.begin(), random_data.end()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -887,8 +918,8 @@ namespace CHECK(data_result.second->second == compare_result.second->second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } @@ -932,6 +963,8 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -949,6 +982,8 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -973,6 +1008,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -993,10 +1030,12 @@ namespace CHECK(i_compare1->second == i_data1->second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -1024,6 +1063,8 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -1048,9 +1089,11 @@ namespace data.erase(i_data, i_data_end); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -1576,7 +1619,7 @@ namespace #if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST && !defined(ETL_TEMPLATE_DEDUCTION_GUIDE_TESTS_DISABLED) TEST_FIXTURE(SetupFixture, test_map_template_deduction) { - using Pair = std::pair, int>; + using Pair = std::pair; etl::map data { Pair{"0", 0}, Pair{"1", 1}, Pair{"2", 2}, Pair{"3", 3}, Pair{"4", 4}, Pair{"5", 5} }; @@ -1590,6 +1633,8 @@ namespace CHECK_EQUAL(3, data.at("3")); CHECK_EQUAL(4, data.at("4")); CHECK_EQUAL(5, data.at("5")); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -1597,9 +1642,9 @@ namespace #if ETL_HAS_INITIALIZER_LIST TEST_FIXTURE(SetupFixture, test_make_map) { - using Pair = ETL_OR_STD::pair, int>; + using Pair = ETL_OR_STD::pair; - auto data = etl::make_map, int, std::less>>(Pair{ "0", 0 }, Pair{ "1", 1 }, Pair{ "2", 2 }, Pair{ "3", 3 }, Pair{ "4", 4 }, Pair{ "5", 5 }); + auto data = etl::make_map>(Pair{ "0", 0 }, Pair{ "1", 1 }, Pair{ "2", 2 }, Pair{ "3", 3 }, Pair{ "4", 4 }, Pair{ "5", 5 }); auto v = *data.begin(); using Type = decltype(v); @@ -1611,6 +1656,8 @@ namespace CHECK_EQUAL(3, data.at("3")); CHECK_EQUAL(4, data.at("4")); CHECK_EQUAL(5, data.at("5")); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -1634,5 +1681,34 @@ namespace CHECK(!data.contains(std::string("99"))); CHECK(!data.contains(Key("99"))); } + + //************************************************************************* + TEST(test_if_issue_1298_multiset_iterator_invalidation_during_erase_is_also_in_map) + { + using element = std::pair; + + std::vector permutation{ {1, 11}, {2, 12}, {3, 13}, {4, 14} }; + const std::vector expected{ {1, 11}, {3, 13}, {4, 14} }; + + do + { + etl::map data; + + for (auto i : permutation) + { + data.insert(i); + } + + auto it = data.find(2); + data.erase(it); + + const std::vector actual(data.begin(), data.end()); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); + CHECK_EQUAL(expected.size(), actual.size()); + CHECK_TRUE(actual == expected); + + } while (std::next_permutation(permutation.begin(), permutation.end())); + } } } diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index 667cccea..b44a2aed 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -234,6 +234,7 @@ namespace CHECK_EQUAL(10U, data.capacity()); CHECK_EQUAL(10U, data.max_size()); CHECK(data == check); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -258,6 +259,7 @@ namespace data2.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -300,6 +302,8 @@ namespace CHECK(itr != data2.end()); result = itr->second.value; CHECK_EQUAL(4, result); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -340,6 +344,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -374,6 +379,7 @@ namespace data2.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -382,9 +388,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); Data other_data(data); -#include "etl/private/diagnostic_self_assign_overloaded_push.h" +#include "etl/private/diagnostic_self_assign_overloaded_push.h" other_data = other_data; -#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" bool isEqual = std::equal(data.begin(), data.end(), @@ -433,6 +439,8 @@ namespace CHECK(itr != data2.end()); result = itr->second.value; CHECK_EQUAL(4, result); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.value_comp())); } //************************************************************************* @@ -488,6 +496,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -554,6 +563,7 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -573,18 +583,19 @@ namespace // Check that elements in map are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(data_result, ETL_OR_STD::make_pair(std::string("1"), 1)); compare_data.insert(compare_result, ETL_OR_STD::make_pair(std::string("1"), 1)); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -604,8 +615,8 @@ namespace // Check that elements in map are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(Data::const_iterator(data_result), @@ -614,10 +625,11 @@ namespace ETL_OR_STD::make_pair(std::string("1"), 1)); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -642,6 +654,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -654,8 +667,8 @@ namespace compare_data.insert(random_data.begin(), random_data.end()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } @@ -730,8 +743,8 @@ namespace CHECK(compare_result.second->second == data_result.second->second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } @@ -756,8 +769,8 @@ namespace CHECK(compare_result.second->second == data_result.second->second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } @@ -789,10 +802,11 @@ namespace CHECK(compare_count == data_count); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -825,10 +839,12 @@ namespace CHECK(compare_count == data_count); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -850,6 +866,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -870,10 +887,11 @@ namespace CHECK(i_compare1->second == i_data1->second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -901,6 +919,7 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -913,9 +932,10 @@ namespace data.erase(data.cbegin(), data.cend()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -1622,6 +1642,8 @@ namespace } CHECK(pass); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } //************************************************************************* @@ -1649,6 +1671,8 @@ namespace CHECK_EQUAL(4, itr->second); ++itr; CHECK_EQUAL(5, itr->second); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -1677,6 +1701,8 @@ namespace CHECK_EQUAL(4, itr->second); ++itr; CHECK_EQUAL(5, itr->second); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); } #endif @@ -1691,5 +1717,35 @@ namespace CHECK(!data.contains(std::string("99"))); CHECK(!data.contains(Key("99"))); } + + //************************************************************************* + TEST(test_if_issue_1298_multiset_iterator_invalidation_during_erase_is_also_in_multimap) + { + using element = std::pair; + + std::vector permutation{ {1, 11}, {2, 12}, {2, 12}, {3, 14} }; + const std::vector expected{ {1, 11}, {2, 12}, {3, 14} }; + + do + { + etl::multimap data; + + for (auto i : permutation) + { + data.insert(i); + } + + auto it = data.find(2); + ++it; + data.erase(it); + + const std::vector actual(data.begin(), data.end()); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.value_comp())); + CHECK_EQUAL(expected.size(), actual.size()); + CHECK_TRUE(actual == expected); + + } while (std::next_permutation(permutation.begin(), permutation.end())); + } } } diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index 47bca6e1..f4e47cc0 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -247,6 +247,7 @@ namespace CHECK_EQUAL(10U, data.capacity()); CHECK_EQUAL(10U, data.max_size()); CHECK(data == check); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -271,6 +272,7 @@ namespace data2.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -290,6 +292,7 @@ namespace DataM data2(std::move(data1)); CHECK(!data1.empty()); // Move does not clear the source. + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -310,6 +313,7 @@ namespace CHECK(data.size() == MAX_SIZE); CHECK(!data.empty()); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #if ETL_HAS_INITIALIZER_LIST @@ -325,6 +329,7 @@ namespace bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -341,6 +346,7 @@ namespace otherData.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(otherData.begin(), otherData.end(), otherData.key_comp())); } //************************************************************************* @@ -359,6 +365,7 @@ namespace data2.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -367,9 +374,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); Data other_data(data); -#include "etl/private/diagnostic_self_assign_overloaded_push.h" +#include "etl/private/diagnostic_self_assign_overloaded_push.h" other_data = other_data; -#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" bool isEqual = std::equal(data.begin(), data.end(), @@ -398,6 +405,7 @@ namespace data2 = std::move(data1); CHECK(!data1.empty()); // Move does not clear the source. + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -453,6 +461,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -510,6 +519,7 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -526,18 +536,19 @@ namespace // Check that elements in multiset are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(data_result, 1); compare_data.insert(compare_result, 1); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -566,6 +577,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -590,6 +602,7 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -602,10 +615,11 @@ namespace compare_data.insert(random_data.begin(), random_data.end()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -638,6 +652,8 @@ namespace CHECK_EQUAL(2, data.find(ItemM(2))->value); CHECK_EQUAL(3, data.find(ItemM(3))->value); CHECK_EQUAL(4, data.find(ItemM(4))->value); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -707,6 +723,7 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -714,7 +731,7 @@ namespace { using CSet = std::multiset>; CSet compare_data(initial_data.begin(), initial_data.end()); - + using ESet = etl::multiset>; ESet data(initial_data.begin(), initial_data.end()); @@ -741,6 +758,7 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -760,6 +778,7 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -780,10 +799,11 @@ namespace CHECK_EQUAL(*i_compare1, *i_data1); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -811,6 +831,7 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -823,9 +844,11 @@ namespace data.erase(data.cbegin(), data.cend()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -1621,5 +1644,31 @@ namespace CHECK(!data.contains(99)); CHECK(!data.contains(Key(99))); } + + //************************************************************************* + TEST(test_issue_1298_multiset_iterator_invalidation_during_erase) + { + std::vector permutation{1, 2, 2, 3}; + const std::vector expected{1, 2, 3}; + + do + { + etl::multiset data; + + for (auto i : permutation) + { + data.insert(i); + } + + auto it = data.find(2); + ++it; + data.erase(it); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); + CHECK_EQUAL(expected.size(), data.size()); + CHECK_TRUE((std::equal(data.begin(), data.end(), expected.begin()))); + + } while (std::next_permutation(permutation.begin(), permutation.end())); + } } } diff --git a/test/test_set.cpp b/test/test_set.cpp index 852b6866..708996a8 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -204,6 +204,7 @@ namespace CHECK_EQUAL(10U, data.capacity()); CHECK_EQUAL(10U, data.max_size()); CHECK(data == check); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -228,6 +229,8 @@ namespace data2.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -252,6 +255,8 @@ namespace CHECK(data2.find(ItemM(2)) != data2.end()); CHECK(data2.find(ItemM(3)) != data2.end()); CHECK(data2.find(ItemM(4)) != data2.end()); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -275,6 +280,8 @@ namespace bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #if ETL_HAS_INITIALIZER_LIST @@ -290,6 +297,8 @@ namespace bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -306,6 +315,8 @@ namespace otherData.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(otherData.begin(), otherData.end(), otherData.key_comp())); } //************************************************************************* @@ -324,6 +335,8 @@ namespace data2.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -332,15 +345,17 @@ namespace Data data(initial_data.begin(), initial_data.end()); Data otherData(data); -#include "etl/private/diagnostic_self_assign_overloaded_push.h" +#include "etl/private/diagnostic_self_assign_overloaded_push.h" data = data; -#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" bool isEqual = Check_Equal(data.begin(), data.end(), otherData.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -363,6 +378,8 @@ namespace data2 = std::move(data1); CHECK(!data1.empty()); // Move does not clear the source. + + CHECK_TRUE(std::is_sorted(data2.begin(), data2.end(), data2.key_comp())); } //************************************************************************* @@ -418,6 +435,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -464,6 +483,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -480,18 +501,20 @@ namespace // Check that elements in set are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(data_result.first, 1); compare_data.insert(compare_result.first, 1); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -510,18 +533,20 @@ namespace // Check that elements in set are the same bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.insert(data_result.first, 1); compare_data.insert(compare_result.first, 1); isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -546,6 +571,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -558,10 +585,12 @@ namespace compare_data.insert(random_data.begin(), random_data.end()); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -594,6 +623,8 @@ namespace CHECK_EQUAL(2, data.find(ItemM(2))->value); CHECK_EQUAL(3, data.find(ItemM(3))->value); CHECK_EQUAL(4, data.find(ItemM(4))->value); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -634,46 +665,9 @@ namespace compare_data.begin()); CHECK(isEqual); + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } - ////************************************************************************* - //TEST_FIXTURE(SetupFixture, test_emplace_value) - //{ - // Compare_Data compare_data; - // Data data; - - // ETL_OR_STD::pair data_result = data.emplace(0); - // ETL_OR_STD::pair compare_result = compare_data.emplace(0); - - // // Check that both return successful return results - // CHECK_EQUAL(*data_result.first, *compare_result.first); - - // // Try adding a duplicate (should return iterator pointing to duplicate) - // data_result = data.insert(0); - // compare_result = compare_data.insert(0); - - // // Check that both return successful return results - // CHECK_EQUAL(*data_result.first, *compare_result.first); - - // // Check that elements in set are the same - // bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); - // CHECK(isEqual); - - // data.insert(2); - // compare_data.insert(2); - - // isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); - - // CHECK(isEqual); - - // data.insert(1); - // compare_data.insert(1); - - // isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); - - // CHECK(isEqual); - //} - //************************************************************************* TEST_FIXTURE(SetupFixture, test_equal_range) { @@ -693,6 +687,8 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -711,10 +707,12 @@ namespace CHECK_EQUAL(*data_result.second, *compare_result.second); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -729,6 +727,8 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -746,6 +746,8 @@ namespace bool isEqual = Check_Equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -770,6 +772,8 @@ namespace compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -790,10 +794,12 @@ namespace CHECK_EQUAL(*i_compare1, *i_data1); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -821,6 +827,8 @@ namespace data.end(), compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -845,9 +853,11 @@ namespace data.erase(i_data, i_data_end); bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } //************************************************************************* @@ -1298,14 +1308,14 @@ namespace ETL_OR_STD::pair etlret = data.equal_range(i); CHECK_EQUAL(stlret.first == compare.end(), etlret.first == data.end()); - + if((stlret.first != compare.end()) && (etlret.first != data.end())) { CHECK_EQUAL(*stlret.first, *etlret.first); } - + CHECK_EQUAL(stlret.second == compare.end(), etlret.second == data.end()); - + if((stlret.second != compare.end()) && (etlret.second != data.end())) { CHECK_EQUAL(*stlret.second, *etlret.second); @@ -1365,14 +1375,14 @@ namespace ETL_OR_STD::pair etlret = data.equal_range(Key(i)); CHECK_EQUAL(stlret.first == compare.end(), etlret.first == data.end()); - + if ((stlret.first != compare.end()) && (etlret.first != data.end())) { CHECK_EQUAL(*stlret.first, *etlret.first); } - + CHECK_EQUAL(stlret.second == compare.end(), etlret.second == data.end()); - + if ((stlret.second != compare.end()) && (etlret.second != data.end())) { CHECK_EQUAL(*stlret.second, *etlret.second); @@ -1417,6 +1427,8 @@ namespace CHECK_EQUAL("E", *itr); ++itr; CHECK_EQUAL("F", *itr); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -1443,6 +1455,8 @@ namespace CHECK_EQUAL("E", *itr); ++itr; CHECK_EQUAL("F", *itr); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); } #endif @@ -1468,5 +1482,30 @@ namespace CHECK(!data.contains(99)); CHECK(!data.contains(Key(99))); } + + //************************************************************************* + TEST(test_if_issue_1298_multiset_iterator_invalidation_during_erase_is_also_in_set) + { + std::vector permutation{1, 2, 3, 4}; + const std::vector expected{1, 3, 4}; + + do + { + etl::set data; + + for (auto i : permutation) + { + data.insert(i); + } + + auto it = data.find(2); + data.erase(it); + + CHECK_TRUE(std::is_sorted(data.begin(), data.end(), data.key_comp())); + CHECK_EQUAL(expected.size(), data.size()); + CHECK_TRUE((std::equal(data.begin(), data.end(), expected.begin()))); + + } while (std::next_permutation(permutation.begin(), permutation.end())); + } } } diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters index 6deed683..e78247d6 100644 --- a/test/vs2022/etl.vcxproj.filters +++ b/test/vs2022/etl.vcxproj.filters @@ -1278,9 +1278,6 @@ ETL\Messaging - - ETL\Messaging\Generators - ETL\Messaging\Generators @@ -1539,6 +1536,9 @@ ETL\Utilities + + ETL\Messaging + From 6ed9ca3f1ddbc4b046ec40061c7e1016a653135c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Mar 2026 13:12:39 +0000 Subject: [PATCH 03/12] Updated release notes and version --- arduino/library-arduino.json | 2 +- arduino/library-arduino.properties | 2 +- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 6 ++++++ version.txt | 2 +- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arduino/library-arduino.json b/arduino/library-arduino.json index 20ff8c86..02d871ce 100644 --- a/arduino/library-arduino.json +++ b/arduino/library-arduino.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library ETL", - "version": "20.46.0", + "version": "20.46.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/arduino/library-arduino.properties b/arduino/library-arduino.properties index 5eae7e44..2d433107 100644 --- a/arduino/library-arduino.properties +++ b/arduino/library-arduino.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.46.0 +version=20.46.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/include/etl/version.h b/include/etl/version.h index 962e55a6..517368af 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -40,7 +40,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 46 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index bc4f1da9..45676189 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.46.0", + "version": "20.46.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 7f1ffc3a..7e2f989e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.46.0 +version=20.46.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 12664b63..3398c650 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,4 +1,10 @@ =============================================================================== +20.46.1 + +#1317 etl multiset iterator invalidation during erase leads to incorrect sorted order in depth first traversal + Also fixed multimap erase and added tests for both. + +=============================================================================== 20.46.0 #1257 Fix year_month arithmetic and correct chrono API behavior diff --git a/version.txt b/version.txt index cec3020e..4d51fa8f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.46.0 +20.46.1 From 25c9235cbc1901b4911f5a15e2cdf9f578dc9231 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 2 Mar 2026 09:13:19 +0000 Subject: [PATCH 04/12] Changed std::is_same to etl::is_same in struct type_list_is_unique (#1320) Co-authored-by: John Wellbelove --- include/etl/type_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/type_list.h b/include/etl/type_list.h index 1afd55f0..f87d97c6 100644 --- a/include/etl/type_list.h +++ b/include/etl/type_list.h @@ -653,7 +653,7 @@ namespace etl struct type_list_is_unique // Create a unique version of the type list, and check if it is the same as the original list. // If they are the same, then all types in the original list are unique. - : etl::bool_constant::type>::value> + : etl::bool_constant::type>::value> { ETL_STATIC_ASSERT((etl::is_type_list::value), "TTypeList must be an etl::type_list"); }; From 7bac1d02f7b4fe31592842ae824d6c1c6b0b16af Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 2 Mar 2026 09:16:18 +0000 Subject: [PATCH 05/12] Updated release notes and version --- arduino/library-arduino.json | 2 +- arduino/library-arduino.properties | 2 +- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 +++++ version.txt | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arduino/library-arduino.json b/arduino/library-arduino.json index 02d871ce..b77c5717 100644 --- a/arduino/library-arduino.json +++ b/arduino/library-arduino.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library ETL", - "version": "20.46.1", + "version": "20.46.2", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/arduino/library-arduino.properties b/arduino/library-arduino.properties index 2d433107..c1a4af8f 100644 --- a/arduino/library-arduino.properties +++ b/arduino/library-arduino.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.46.1 +version=20.46.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/include/etl/version.h b/include/etl/version.h index 517368af..f4d8b7f9 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -40,7 +40,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 46 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 45676189..c6106bed 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.46.1", + "version": "20.46.2", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 7e2f989e..5ad61845 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.46.1 +version=20.46.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 3398c650..284c2018 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,4 +1,9 @@ =============================================================================== +20.46.2 + +#1320 Changed std::is_same to etl::is_same in struct type_list_is_unique + +=============================================================================== 20.46.1 #1317 etl multiset iterator invalidation during erase leads to incorrect sorted order in depth first traversal diff --git a/version.txt b/version.txt index 4d51fa8f..8b8b5e80 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.46.1 +20.46.2 From a8ebe338f80ee25fcc79d53cdbc8140bf208fae1 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 6 Mar 2026 11:11:46 +0100 Subject: [PATCH 06/12] Fix etl::rotate (#1327) Per the C++ standard, std::rotate returns first + (last - middle): * When first == middle, return last * When middle == last, return first --- include/etl/algorithm.h | 28 +++++++++-- test/iterators_for_unit_tests.h | 6 +++ test/test_algorithm.cpp | 87 +++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 4 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 74fbb8ed..8ee795a8 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -1193,7 +1193,12 @@ namespace etl typename etl::enable_if::value, TIterator>::type rotate_general(TIterator first, TIterator middle, TIterator last) { - if (first == middle || middle == last) + if (first == middle) + { + return last; + } + + if (middle == last) { return first; } @@ -1242,7 +1247,12 @@ namespace etl typename etl::enable_if::value, TIterator>::type rotate_general(TIterator first, TIterator middle, TIterator last) { - if (first == middle || middle == last) + if (first == middle) + { + return last; + } + + if (middle == last) { return first; } @@ -1292,7 +1302,12 @@ namespace etl typename etl::enable_if::value, TIterator>::type rotate_general(TIterator first, TIterator middle, TIterator last) { - if (first == middle || middle == last) + if (first == middle) + { + return last; + } + + if (middle == last) { return first; } @@ -1314,7 +1329,12 @@ namespace etl typename etl::enable_if::value, TIterator>::type rotate_general(TIterator first, TIterator middle, TIterator last) { - if (first == middle || middle == last) + if (first == middle) + { + return last; + } + + if (middle == last) { return first; } diff --git a/test/iterators_for_unit_tests.h b/test/iterators_for_unit_tests.h index 16085f87..82d28c6c 100644 --- a/test/iterators_for_unit_tests.h +++ b/test/iterators_for_unit_tests.h @@ -113,6 +113,12 @@ struct non_random_iterator : public etl::iterator +bool operator ==(const non_random_iterator& lhs, const non_random_iterator& rhs) +{ + return lhs.ptr == rhs.ptr; +} + template bool operator !=(const non_random_iterator& lhs, const non_random_iterator& rhs) { diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index abdab9d5..4dd01e9f 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -1236,6 +1236,93 @@ namespace } } + //************************************************************************* + TEST(rotate_return_value) + { + // Verify that etl::rotate returns the same iterator as std::rotate + // in all cases, including the degenerate first==middle and middle==last cases. + std::vector initial_data = { 1, 2, 3, 4, 5 }; + + for (size_t i = 0UL; i <= initial_data.size(); ++i) + { + std::vector data1(initial_data); + std::vector data2(initial_data); + + auto std_result = std::rotate(data1.data(), data1.data() + i, data1.data() + data1.size()); + auto etl_result = etl::rotate(data2.data(), data2.data() + i, data2.data() + data2.size()); + + // Check that the return value offset matches + ptrdiff_t std_offset = std_result - data1.data(); + ptrdiff_t etl_offset = etl_result - data2.data(); + CHECK_EQUAL(std_offset, etl_offset); + } + + // Explicitly test first == middle (empty left half): should return last + { + std::vector data = { 1, 2, 3 }; + auto result = etl::rotate(data.data(), data.data(), data.data() + data.size()); + CHECK(result == data.data() + data.size()); + } + + // Explicitly test middle == last (empty right half): should return first + { + std::vector data = { 1, 2, 3 }; + auto result = etl::rotate(data.data(), data.data() + data.size(), data.data() + data.size()); + CHECK(result == data.data()); + } + } + + //************************************************************************* + TEST(rotate_return_value_non_random_iterator) + { + // Verify that etl::rotate returns the correct iterator when called with + // non-random (bidirectional) iterators, exercising rotate_general for + // bidirectional iterators rather than the random-access overload. + std::vector initial_data = { 1, 2, 3, 4, 5 }; + + for (size_t i = 0UL; i <= initial_data.size(); ++i) + { + std::vector data1(initial_data); + std::vector data2(initial_data); + + auto std_result = std::rotate(data1.data(), data1.data() + i, data1.data() + data1.size()); + + non_random_iterator nr_first(data2.data()); + non_random_iterator nr_middle(data2.data() + i); + non_random_iterator nr_last(data2.data() + data2.size()); + auto etl_result = etl::rotate(nr_first, nr_middle, nr_last); + + // Check that the data was rotated correctly + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + // Check that the return value offset matches + ptrdiff_t std_offset = std_result - data1.data(); + ptrdiff_t etl_offset = etl_result.ptr - data2.data(); + CHECK_EQUAL(std_offset, etl_offset); + } + + // Explicitly test first == middle (empty left half): should return last + { + std::vector data = { 1, 2, 3 }; + non_random_iterator nr_first(data.data()); + non_random_iterator nr_middle(data.data()); + non_random_iterator nr_last(data.data() + data.size()); + auto result = etl::rotate(nr_first, nr_middle, nr_last); + CHECK(result.ptr == data.data() + data.size()); + } + + // Explicitly test middle == last (empty right half): should return first + { + std::vector data = { 1, 2, 3 }; + non_random_iterator nr_first(data.data()); + non_random_iterator nr_middle(data.data() + data.size()); + non_random_iterator nr_last(data.data() + data.size()); + auto result = etl::rotate(nr_first, nr_middle, nr_last); + CHECK(result.ptr == data.data()); + } + } + //************************************************************************* TEST(any_of) { From f96510bd79dca27c7a9445b56d3625d85e219843 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 2 Mar 2026 09:59:08 +0000 Subject: [PATCH 07/12] Added missing files from VS2022 project --- test/vs2022/etl.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index 6396b761..2b069673 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -3552,6 +3552,7 @@ + @@ -10362,6 +10363,7 @@ + From 4ad6126ec5fdd7c27ed359ee09de2482e922bebb Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 6 Mar 2026 21:08:31 +0100 Subject: [PATCH 08/12] Fix greater_equal and less_equal (#1331) --- include/etl/functional.h | 10 +++--- test/test_functional.cpp | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/include/etl/functional.h b/include/etl/functional.h index 0f0172ec..73b1685b 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -224,9 +224,9 @@ namespace etl typedef int is_transparent; template - constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) < static_cast(rhs)) + constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(!(static_cast(rhs) < static_cast(lhs))) { - return !(static_cast(lhs) < static_cast(rhs)); + return !(static_cast(rhs) < static_cast(lhs)); } }; #endif @@ -250,7 +250,7 @@ namespace etl typedef int is_transparent; template - constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) < static_cast(rhs)) + constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(rhs) < static_cast(lhs)) { return static_cast(rhs) < static_cast(lhs); } @@ -276,9 +276,9 @@ namespace etl typedef int is_transparent; template - constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) < static_cast(rhs)) + constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(!(static_cast(lhs) < static_cast(rhs))) { - return static_cast(rhs) < static_cast(lhs); + return !(static_cast(lhs) < static_cast(rhs)); } }; #endif diff --git a/test/test_functional.cpp b/test/test_functional.cpp index 1204d330..5bbe6beb 100644 --- a/test/test_functional.cpp +++ b/test/test_functional.cpp @@ -85,6 +85,24 @@ namespace mutable std::string result; }; +#if ETL_USING_CPP11 + // Lightweight type used to verify transparent heterogeneous comparison. + // Only operator<(int, Wrapper) is defined; operator<(Wrapper, int) is + // intentionally absent. less_equal is implemented as + // !(rhs < lhs), so less_equal{}(Wrapper, int) needs + // operator<(int, Wrapper) which IS provided. + struct Wrapper + { + int value; + constexpr explicit Wrapper(int v) : value(v) {} + }; + + // int < Wrapper -- defined + constexpr bool operator<(int lhs, const Wrapper& rhs) { return lhs < rhs.value; } + + // Wrapper < int -- intentionally NOT defined +#endif + SUITE(test_functional) { //************************************************************************* @@ -101,6 +119,32 @@ namespace CHECK((compare>(1, 2))); CHECK(!(compare>(2, 1))); CHECK((compare>(1, 1))); + +#if ETL_USING_CPP11 + CHECK((compare>(1, 2))); + CHECK(!(compare>(2, 1))); + CHECK((compare>(1, 1))); +#endif + } + + //************************************************************************* + TEST(test_less_equal_void_heterogeneous) + { +#if ETL_USING_CPP11 + // less_equal{}(lhs, rhs) is !(rhs < lhs). + // With only operator<(int, Wrapper) defined, we can call + // less_equal{}(Wrapper, int) because the implementation + // evaluates !(int < Wrapper). + + // Wrapper(1) <= 2 → !(2 < Wrapper(1)) → !(2 < 1) → !false → true + CHECK((etl::less_equal{}(Wrapper(1), 2))); + + // Wrapper(2) <= 1 → !(1 < Wrapper(2)) → !(1 < 2) → !true → false + CHECK(!(etl::less_equal{}(Wrapper(2), 1))); + + // Wrapper(3) <= 3 → !(3 < Wrapper(3)) → !(3 < 3) → !false → true + CHECK((etl::less_equal{}(Wrapper(3), 3))); +#endif } //************************************************************************* @@ -117,6 +161,32 @@ namespace CHECK(!(compare>(1, 2))); CHECK((compare>(2, 1))); CHECK((compare>(1, 1))); + +#if ETL_USING_CPP11 + CHECK(!(compare>(1, 2))); + CHECK((compare>(2, 1))); + CHECK((compare>(1, 1))); +#endif + } + + //************************************************************************* + TEST(test_greater_equal_void_heterogeneous) + { +#if ETL_USING_CPP11 + // greater_equal{}(lhs, rhs) is !(lhs < rhs). + // With only operator<(int, Wrapper) defined, we can call + // greater_equal{}(int, Wrapper) because the implementation + // evaluates !(int < Wrapper). + + // 2 >= Wrapper(1) → !(2 < Wrapper(1)) → !(2 < 1) → !false → true + CHECK((etl::greater_equal{}(2, Wrapper(1)))); + + // 1 >= Wrapper(2) → !(1 < Wrapper(2)) → !(1 < 2) → !true → false + CHECK(!(etl::greater_equal{}(1, Wrapper(2)))); + + // 3 >= Wrapper(3) → !(3 < Wrapper(3)) → !(3 < 3) → !false → true + CHECK((etl::greater_equal{}(3, Wrapper(3)))); +#endif } //************************************************************************* From 7329efc7dfde1116de974899558be5345ec0e5c2 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 6 Mar 2026 21:29:58 +0100 Subject: [PATCH 09/12] Align comparison operators (#1330) In functional.h, the comparison operators for equal_to and not_equal_to mismatch between the actual comparison execution and the type inference for the return type. This change adjusts it by using the same operator==() in the return type inference as used in the comparison execution. Co-authored-by: John Wellbelove --- include/etl/functional.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/functional.h b/include/etl/functional.h index 73b1685b..3c1c55b4 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -303,7 +303,7 @@ namespace etl typedef int is_transparent; template - constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) < static_cast(rhs)) + constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) == static_cast(rhs)) { return static_cast(lhs) == static_cast(rhs); } @@ -329,7 +329,7 @@ namespace etl typedef int is_transparent; template - constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(static_cast(lhs) < static_cast(rhs)) + constexpr auto operator()(T1&& lhs, T2&& rhs) const -> decltype(!(static_cast(lhs) == static_cast(rhs))) { return !(static_cast(lhs) == static_cast(rhs)); } From 67ecc8e11e2be245c15f03b231108b1adbd5882e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 6 Mar 2026 22:34:54 +0100 Subject: [PATCH 10/12] Add missing tests (#1321) * Add missing tests * Typo fixes --------- Co-authored-by: John Wellbelove --- include/etl/algorithm.h | 2 +- include/etl/array.h | 6 +++--- include/etl/functional.h | 2 +- include/etl/numeric.h | 2 +- test/CMakeLists.txt | 9 +++++++++ test/test_etl_assert.cpp | 2 ++ 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 8ee795a8..7317889c 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -34,7 +34,7 @@ SOFTWARE. #define ETL_ALGORITHM_INCLUDED ///\defgroup algorithm algorithm -/// Including reverse engineered algorithms from C++ 0x11, 0x14, 0x17 +/// Including reverse engineered algorithms from C++11, 14, 17 /// Additional new variants of certain algorithms. ///\ingroup utilities diff --git a/include/etl/array.h b/include/etl/array.h index f1624209..1f2f5044 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -46,7 +46,7 @@ SOFTWARE. #include ///\defgroup array array -/// A replacement for std::array if you haven't got C++0x11. +/// A replacement for std::array if you haven't got C++11. ///\ingroup containers namespace etl @@ -81,7 +81,7 @@ namespace etl //*************************************************************************** ///\ingroup array - /// A replacement for std::array if you haven't got C++0x11. + /// A replacement for std::array if you haven't got C++11. //*************************************************************************** template class array @@ -646,7 +646,7 @@ namespace etl //*************************************************************************** ///\ingroup array - /// A replacement for std::array if you haven't got C++0x11. + /// A replacement for std::array if you haven't got C++11. /// Specialisation for zero sized array. //*************************************************************************** template diff --git a/include/etl/functional.h b/include/etl/functional.h index 3c1c55b4..e313325e 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -43,7 +43,7 @@ SOFTWARE. namespace etl { //*************************************************************************** - /// A definition of reference_wrapper for those that don't have C++ 0x11 support. + /// A definition of reference_wrapper for those that don't have C++11 support. ///\ingroup reference //*************************************************************************** template diff --git a/include/etl/numeric.h b/include/etl/numeric.h index dbb43696..3283b338 100644 --- a/include/etl/numeric.h +++ b/include/etl/numeric.h @@ -47,7 +47,7 @@ namespace etl { //*************************************************************************** /// iota - /// Reverse engineered version of std::iota for non C++ 0x11 compilers. + /// Reverse engineered version of std::iota for non C++11 compilers. /// Fills a range of elements with sequentially increasing values starting with value. ///\param first An iterator to the first position to fill. ///\param last An iterator to the last + 1 position. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2fdfc71c..2bec7847 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -86,6 +86,7 @@ add_executable(etl_tests test_closure.cpp test_closure_constexpr.cpp test_compare.cpp + test_concepts.cpp test_constant.cpp test_const_map.cpp test_const_map_constexpr.cpp @@ -172,6 +173,7 @@ add_executable(etl_tests test_endian.cpp test_enum_type.cpp test_error_handler.cpp + test_etl_assert.cpp test_etl_traits.cpp test_exception.cpp test_expected.cpp @@ -183,6 +185,7 @@ add_executable(etl_tests test_flat_multiset.cpp test_flat_set.cpp test_fnv_1.cpp + test_format.cpp test_format_spec.cpp test_forward_list.cpp test_forward_list_shared_pool.cpp @@ -194,10 +197,12 @@ add_executable(etl_tests test_hash.cpp test_hfsm.cpp test_hfsm_recurse_to_inner_state_on_start.cpp + test_hfsm_transition_on_enter.cpp test_histogram.cpp test_index_of_type.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 @@ -206,7 +211,9 @@ add_executable(etl_tests test_intrusive_queue.cpp test_intrusive_stack.cpp test_invert.cpp + test_invoke.cpp test_io_port.cpp + test_is_invocable.cpp test_iterator.cpp test_jenkins.cpp test_largest.cpp @@ -259,6 +266,7 @@ add_executable(etl_tests test_pool.cpp test_pool_external_buffer.cpp test_priority_queue.cpp + test_print.cpp test_pseudo_moving_average.cpp test_quantize.cpp test_queue.cpp @@ -286,6 +294,7 @@ add_executable(etl_tests test_scaled_rounding.cpp test_set.cpp test_shared_message.cpp + test_signal.cpp test_singleton.cpp test_singleton_base.cpp test_smallest.cpp diff --git a/test/test_etl_assert.cpp b/test/test_etl_assert.cpp index e927a0b2..26fcced4 100644 --- a/test/test_etl_assert.cpp +++ b/test/test_etl_assert.cpp @@ -34,6 +34,8 @@ SOFTWARE. #include "etl/error_handler.h" #include "etl/exception.h" +#include + namespace { class TestException1 : public etl::exception From 8ce59792fd4667c33f61e749f3397a565514fc4d Mon Sep 17 00:00:00 2001 From: Niu Zhihong Date: Sat, 7 Mar 2026 06:04:32 +0800 Subject: [PATCH 11/12] Add ETL_FORMAT_NO_FLOATING_POINT control macro for etl::format (#1329) When ETL_FORMAT_NO_FLOATING_POINT is defined, all floating-point formatting support (float, double, long double) is excluded from etl::format. This reduces code size on targets that do not require floating-point formatting. Guarded sections: - #include - float/double/long double in supported_format_types variant - float/double/long double constructors in basic_format_arg - format_floating_* functions and format_aligned_floating - formatter, formatter, formatter - Floating-point test cases in test_format.cpp Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus Co-authored-by: John Wellbelove --- include/etl/format.h | 14 ++++++++++++++ include/etl/platform.h | 11 +++++++++++ test/test_format.cpp | 2 ++ 3 files changed, 27 insertions(+) diff --git a/include/etl/format.h b/include/etl/format.h index 3268f43b..7812f9ab 100644 --- a/include/etl/format.h +++ b/include/etl/format.h @@ -48,7 +48,9 @@ SOFTWARE. #include "variant.h" #include "visitor.h" +#if ETL_USING_FORMAT_FLOATING_POINT #include +#endif #if ETL_USING_CPP11 @@ -138,9 +140,11 @@ namespace etl unsigned int, long long int, unsigned long long int, +#if ETL_USING_FORMAT_FLOATING_POINT float, double, long double, +#endif const char*, etl::string_view, const void* @@ -302,6 +306,7 @@ namespace etl { } +#if ETL_USING_FORMAT_FLOATING_POINT basic_format_arg(const float v) : data(v) { @@ -316,6 +321,7 @@ namespace etl : data(v) { } +#endif basic_format_arg(const etl::string_view v) : data(v) @@ -1039,6 +1045,7 @@ namespace etl format_plain_num(it, value, spec, width); } +#if ETL_USING_FORMAT_FLOATING_POINT template void format_floating_default(OutputIt& it, T value, const format_spec_t& spec) { @@ -1214,6 +1221,7 @@ namespace etl private_format::format_sequence(it, "."); private_format::format_plain_num(it, fractional_int, spec, fractional_decimals); } +#endif class dummy_assign_to { @@ -1336,6 +1344,7 @@ namespace etl size_t count; }; +#if ETL_USING_FORMAT_FLOATING_POINT template void format_floating_g(OutputIt& it, T value, const format_spec_t& spec) { @@ -1409,6 +1418,7 @@ namespace etl } } } +#endif template struct format_visitor @@ -1490,6 +1500,7 @@ namespace etl return it; } +#if ETL_USING_FORMAT_FLOATING_POINT template typename format_context::iterator format_aligned_floating(Float arg, format_context& fmt_ctx) { @@ -1534,6 +1545,7 @@ namespace etl private_format::fill(it, suffix_size, fmt_ctx.format_spec.fill); return it; } +#endif template void format_string_view(OutputIt& it, etl::string_view arg, const format_spec_t& spec) @@ -2072,6 +2084,7 @@ namespace etl } }; +#if ETL_USING_FORMAT_FLOATING_POINT template<> struct formatter { @@ -2119,6 +2132,7 @@ namespace etl return private_format::format_aligned_floating(arg, fmt_ctx); } }; +#endif template<> struct formatter diff --git a/include/etl/platform.h b/include/etl/platform.h index 6db7c305..a1ae4029 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -154,6 +154,16 @@ SOFTWARE. #define ETL_NOT_USING_WIDE_CHARACTERS 0 #endif +//************************************* +// Helper macro for ETL_FORMAT_NO_FLOATING_POINT. +#if defined(ETL_FORMAT_NO_FLOATING_POINT) + #define ETL_USING_FORMAT_FLOATING_POINT 0 + #define ETL_NOT_USING_FORMAT_FLOATING_POINT 1 +#else + #define ETL_USING_FORMAT_FLOATING_POINT 1 + #define ETL_NOT_USING_FORMAT_FLOATING_POINT 0 +#endif + //************************************* // Figure out things about the compiler, if haven't already done so in etl_profile.h #include "profiles/determine_compiler_version.h" @@ -651,6 +661,7 @@ namespace etl static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1); static ETL_CONSTANT bool using_libc_wchar_h = (ETL_USING_LIBC_WCHAR_H == 1); static ETL_CONSTANT bool using_std_exception = (ETL_USING_STD_EXCEPTION == 1); + static ETL_CONSTANT bool using_format_floating_point = (ETL_USING_FORMAT_FLOATING_POINT == 1); // Has... static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1); diff --git a/test/test_format.cpp b/test/test_format.cpp index a6c25eab..3d3338fa 100644 --- a/test/test_format.cpp +++ b/test/test_format.cpp @@ -197,6 +197,7 @@ namespace CHECK_EQUAL("-6759414", test_format(s, "{}", static_cast(-6759414))); } +#if ETL_USING_FORMAT_FLOATING_POINT //************************************************************************* TEST(test_format_float) { @@ -266,6 +267,7 @@ namespace CHECK_EQUAL("0x1.92a738p-5", test_format(s, "{:a}", 0.0000015f)); CHECK_EQUAL("0x1.6345785d8ap+e", test_format(s, "{:a}", 100000000000000000.l)); } +#endif //************************************************************************* TEST(test_format_char_array) From 521df8ee19bf0b84b82086c2441c1c2f0c463380 Mon Sep 17 00:00:00 2001 From: Timon Zijnge <47081647+tzijnge@users.noreply.github.com> Date: Sat, 7 Mar 2026 09:13:00 +0100 Subject: [PATCH 12/12] Manchester documentation (#1325) * manchester * Added manchester code and test * manchester * Formatting and added missing file * manchester * Some functions can only be constexpr since C++14 * manchester * Manchester decode and some refactoring * manchester * Added some missing typenames * manchester * constexpr void function not allowed in C++11 * manchester * condition on static_assert tests * manchester * revert CMakeLists.txt * Using ETL_STATIC_ASSERT * Some cleanup * manchester * Added static_assert message * manchester * Added compile time tests * manchester * Added invert manchester * Some refactoring * manchester * Disable test for now * Move ETL_NODISCARD before static * manchester * Test for valid_span * manchester * Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template * manchester * refactoring to get rid of specialized template functions in template class * manchester * cleanup * manchester * Added documentation comments * Some refactoring * manchester * introducing namespace detail_manchester * manchester * Some refactoring * Update tests * manchester * Some refactoring * Removed possible undefined behavior by refactoring encode_span * constexpr version of encode_span * Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t * manchester * renamed valid to is_valid * manchester * renamed is_valid_span to is_valid * Using etl exceptions in ETL_ASSERT * manchester * Removed _fast functions * merged encode_in_place with encode and decode_in_place with decode * removed _span to create normal overloads of encode and decode for span * Some renaming and minor refactoring * manchester * Fix build issues * manchester * Conditionally compile manchester_decoded * Update test_manchester.cpp Removed redundant semicolon * #1258 Manchester coding * Formatting * consistency: hex literals with lower case 0x * #1258 Manchester coding * Moved copyright to top of file * Make constexpr encode/decode span functions equal for little and big endian platforms * #1258 Manchester coding * Added missing include * Added missing 8bit/64bit guards * Fixed is_valid for big endian platforms * #1258 Manchester coding * private memcpy alias * #1258 Manchester coding * Review comments * #1258 Manchester coding * Cleanup * Fix build error * #1258 Manchester coding * Add manchester documentation * #1258 Manchester coding * Preparation for GitHub pages * #1324 Manchester documentation * Some small fixes --------- Co-authored-by: Timon Zijnge --- docs/_config.yml | 6 ++ docs/index.md | 7 ++ docs/manchester.md | 258 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 docs/_config.yml create mode 100644 docs/index.md create mode 100644 docs/manchester.md diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000..6fac68f0 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1,6 @@ +plugins: + - jekyll-relative-links +relative_links: + enabled: true +include: + - manchester.md diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..23e43ac5 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,7 @@ +--- +title: ETL documentation +--- + +## Pages + +* [Manchester](manchester.md) diff --git a/docs/manchester.md b/docs/manchester.md new file mode 100644 index 00000000..06c0cf7d --- /dev/null +++ b/docs/manchester.md @@ -0,0 +1,258 @@ +--- +title: Manchester encoding and decoding +--- + +Efficient Manchester encoding and decoding of data. The Manchester code represents a data bit as a sequence of a 'high' and a 'low' value. In software this translates to a conversion from one to two bits, or in a practical situation, from `n` bytes to `n*2` bytes. + +## See also + +[Manchester code](https://en.wikipedia.org/wiki/Manchester_code) + +## Features + +- Normal and inverted Manchester encoding +- Support for multiple encoding chunk sizes: 8-bit, 16-bit and 32-bit +- Span-based operations or chunk-based operations +- Constexpr functions for compile-time encoding/decoding (8-bit chunk size only) +- Validation of encoded data + +## Algorithm background + +To encode the value `0b11001100` we must first duplicate all bits to create the value `0b1111000011110000`. We then perform an XOR of this value with the constant `0b1010101010101010` (`0xAAAA`) to obtain the Manchester coded value of `0b1010010110100101`. We have now replaced each `1` bit with the sequence `10` and each `0` bit with the sequence `01`. + +### 2. Bit duplication + +Bit duplication is achieved with the following steps. This is also called binary interleaving. The example shows encoding of an 8-bit value. + +| Step | High Byte | Low Byte | Operation | +|------|--------------------|--------------------|----------------------------| +| 0 | `_ _ _ _ _ _ _ _` | `A B C D E F G H` | input value (i) | +| 1 | `_ _ _ _ A B C D` | `_ _ _ _ E F G H` | `(i \| (i << 4)) & 0x0F0F` | +| 2 | `_ _ A B _ _ C D` | `_ _ E F _ _ G H` | `(i \| (i << 2)) & 0x3333` | +| 3 | `_ A _ B _ C _ D` | `_ E _ F _ G _ H` | `(i \| (i << 1)) & 0x5555` | +| 4 | `A A B B C C D D` | `E E F F G G H H` | `(i \| (i << 1))` | + +This process can be easily extended to 16-bit or 32-bit values by adding additional steps to the bit duplication. + +### 3. Manchester Decoding + +Manchester decoding is done in a similar, but reversed way. + +### 4. Error Detection + +Error detection in Manchester coded data is done by comparing 2 neighboring bits. If they are +equal, then there is an error in the encoded input data. + +Comparing all 8 bit pairs in a 16-bit word is done as follows. + +| Step | Binary Value | Operation | Description | +|------|--------------|-------------------|-----------------------------------------------------------------------------------------------| +| 1 | `11011000` | Original | First bit pair (lsb, 00) is invalid. Last bit pair is also invalid. Other bit pairs are valid | +| 2 | `01101100` | Shift right by 1 | Shift the original value right by one bit | +| 3 | `10110100` | XOR | XOR the original with the shifted value | +| 4 | `01010101` | Mask with 0x55 | Apply mask to isolate bit pairs | +| 5 | `00010100` | Result | If result is not equal to 0x55, there was an error in the input | + +## Analysis + +Most traditional ways to Manchester encode data consist of a loop over all bits and a nested if-statement to check the value of the current bit. This approach does not scale well to increasing number of bits. The algorithm implemented here contains no conditional code and scales well. Doubling the number of processed bits per step (the chunk size) adds a single row to the bit duplication table. Because of the lack of loops and conditional code, this algorithm is likely to perform better than traditional ones on simple processors or when compiler optimization is disabled. On modern, powerful processors with caches and advanced optimization possibilities this algorithm may not show much benefit. In any case, the performance of the algorithm depends heavily on the processor type, compiler and compiler (optimization) settings. + +## API Reference + +### Classes + +Classes `etl::manchester` and `etl::manchester_inverted` contain static functions for encoding, decoding and validity checking. It is not necessary to instantiate objects of these classes. + +#### etl::manchester + +```cpp +typedef manchester_base manchester; +``` + +Manchester encoder using normal encoding (no inversion). + +#### etl::manchester_inverted + +```cpp +typedef manchester_base manchester_inverted; +``` + +Manchester encoder using inverted encoding. + +### Encoding Functions + +#### Encode single value + +```cpp +template +static ETL_CONSTEXPR14 typename encoded::type encode(TDecoded decoded) +``` + +Encodes a single value using Manchester encoding. + +**Parameters:** + +- `decoded`: The value to encode (`uint8_t`, `uint16_t`, or `uint32_t`) + +**Returns:** + +- The Manchester encoded value (twice the bit width of input) + +**Example:** + +```cpp +uint16_t encoded = etl::manchester::encode(0x55); +``` + +#### Encode range + +```cpp +template +static ETL_CONSTEXPR14 void encode(etl::span decoded, + etl::span encoded) +``` + +Encodes a span of data using the specified chunk size. + +**Parameters:** + +- `decoded`: Source data to encode +- `encoded`: Destination for encoded data (must be twice the size of `decoded`) + +**Template Parameters:** + +- `TChunk`: Chunk size for encoding (`uint8_t`, `uint16_t` or `uint32_t`) + +**Example:** + +```cpp +std::array data = {0x12, 0x34, 0x56, 0x78}; +std::array encoded_data1{}; +std::array encoded_data2{}; + +// Encode with TChunk == uint8_t +etl::manchester::encode(data, encoded_data1); + +// Encode with TChunk == uint32_t +etl::manchester::encode(data, encoded_data2); +``` + +### Decoding Functions + +#### Decode single value + +```cpp +template +static ETL_CONSTEXPR14 typename decoded::type decode(TEncoded encoded) +``` + +Decodes a single Manchester encoded value. + +**Parameters:** + +- `encoded`: The encoded value to decode (`uint16_t`, `uint32_t`, or `uint64_t`) + +**Returns:** + +- The Manchester decoded value (half the bit width of input) + +**Example:** + +```cpp +uint8_t decoded = etl::manchester::decode(0x5A5A); +``` + +#### Decode range + +```cpp +template ::type> +static ETL_CONSTEXPR14 void decode(etl::span encoded, + etl::span decoded) +``` + +Decodes a span of Manchester encoded data. + +**Parameters:** + +- `encoded`: Source data to decode +- `decoded`: Destination for decoded data (must be half the size of `encoded`) + +**Template Parameters:** + +- `TChunk`: Chunk type for decoding (`uint16_t`, `uint32_t`, or `uint64_t`) + +**Example:** + +```cpp +std::array encoded = {/* ... */}; +std::array decoded1 {}; +std::array decoded2 {}; + +// Decode with TChunk == uint16_t +etl::manchester::decode(encoded, decoded1); + +// Decode with TChunk == uint64_t +etl::manchester::decode(encoded, decoded2); +``` + +### Validation Functions + +#### Single value + +```cpp +template +static ETL_CONSTEXPR14 bool is_valid(TChunk encoded) +``` + +Validates that a single value contains valid Manchester encoded data. + +**Parameters:** + +- `encoded`: The encoded value to validate + +**Returns:** + +- `true` if the value contains valid Manchester encoded data, `false` otherwise + +**Example:** + +```cpp +bool valid = etl::manchester::is_valid(0x5A5A); +``` + +#### Range + +```cpp +static ETL_CONSTEXPR14 bool is_valid(etl::span encoded) +``` + +Validates that a range contains valid Manchester encoded data. + +**Parameters:** + +- `encoded`: The range of encoded data to validate + +**Returns:** + +- `true` if all data is valid Manchester encoding, `false` otherwise + +**Example:** + +```cpp +std::array encoded_data = {/* ... */}; +bool valid = etl::manchester::is_valid(encoded_data); +``` + +## Supported Types + +### Input/chunk types for encoding + +- `uint8_t` → `uint16_t` (if 8-bit types are supported) +- `uint16_t` → `uint32_t` +- `uint32_t` → `uint64_t` (if 64-bit types are supported) + +### Input/chunk types for decoding + +- `uint16_t` → `uint8_t` (if 8-bit types are supported) +- `uint32_t` → `uint16_t` +- `uint64_t` → `uint32_t` (if 64-bit types are supported)