From 15cbb12e4b88ddfab6a0b931b514b8b6dfed33fb Mon Sep 17 00:00:00 2001 From: David Ockey <2897027+ockeydockey@users.noreply.github.com> Date: Fri, 3 Oct 2025 02:44:16 -0500 Subject: [PATCH 1/6] Added conditional support of `noexcept` to fix IAR support (#1195) --- include/etl/platform.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/etl/platform.h b/include/etl/platform.h index af0b9a6d..ee0032c4 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -341,8 +341,13 @@ SOFTWARE. #define ETL_ENUM_CLASS(name) enum class name #define ETL_ENUM_CLASS_TYPE(name, type) enum class name : type #define ETL_LVALUE_REF_QUALIFIER & - #define ETL_NOEXCEPT noexcept - #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) + #if ETL_USING_EXCEPTIONS + #define ETL_NOEXCEPT noexcept + #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) + #else + #define ETL_NOEXCEPT + #define ETL_NOEXCEPT_EXPR(...) + #endif #else #define ETL_CONSTEXPR #define ETL_CONSTEXPR11 From b38feb17b55d078cdb15a2bdd41952b2499ab830 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 3 Oct 2025 10:18:21 +0100 Subject: [PATCH 2/6] Minor layout changes --- include/etl/platform.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/etl/platform.h b/include/etl/platform.h index ee0032c4..f6658d49 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -242,22 +242,22 @@ SOFTWARE. #endif //************************************* -// Indicate if C++ exceptions are enabled. +// Indicate if C++ exceptions within the ETL are enabled. #if defined(ETL_THROW_EXCEPTIONS) - #define ETL_USING_EXCEPTIONS 1 + #define ETL_USING_EXCEPTIONS 1 #define ETL_NOT_USING_EXCEPTIONS 0 #else - #define ETL_USING_EXCEPTIONS 0 + #define ETL_USING_EXCEPTIONS 0 #define ETL_NOT_USING_EXCEPTIONS 1 #endif //************************************* // Indicate if C++ exceptions are enabled for debug asserts. #if ETL_IS_DEBUG_BUILD && defined(ETL_DEBUG_THROW_EXCEPTIONS) - #define ETL_DEBUG_USING_EXCEPTIONS 1 + #define ETL_DEBUG_USING_EXCEPTIONS 1 #define ETL_DEBUG_NOT_USING_EXCEPTIONS 0 #else - #define ETL_DEBUG_USING_EXCEPTIONS 0 + #define ETL_DEBUG_USING_EXCEPTIONS 0 #define ETL_DEBUG_NOT_USING_EXCEPTIONS 1 #endif @@ -342,8 +342,8 @@ SOFTWARE. #define ETL_ENUM_CLASS_TYPE(name, type) enum class name : type #define ETL_LVALUE_REF_QUALIFIER & #if ETL_USING_EXCEPTIONS - #define ETL_NOEXCEPT noexcept - #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) + #define ETL_NOEXCEPT noexcept + #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) #else #define ETL_NOEXCEPT #define ETL_NOEXCEPT_EXPR(...) From e1126aafd2903d0411693ab72aa4266eb14209e5 Mon Sep 17 00:00:00 2001 From: Igor Pugachev Date: Fri, 3 Oct 2025 09:54:12 +0200 Subject: [PATCH 3/6] fix variant_variadic documentation (#1194) * fix variant_variadic default constructor documentation * fix valueless doc --- include/etl/private/variant_variadic.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 618e2366..8ec3f195 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -459,7 +459,7 @@ namespace etl //*************************************************************************** /// Default constructor. - /// Sets the state of the instance to containing no valid data. + /// Constructs a variant holding the value-initialized value of the first alternative (index() is zero). //*************************************************************************** #include "diagnostic_uninitialized_push.h" ETL_CONSTEXPR14 variant() @@ -779,8 +779,8 @@ namespace etl } //*************************************************************************** - /// Checks whether a valid value is currently stored. - ///\return true if the value is valid, otherwise false. + /// Checks whether the variant doesn't contain a valid value. + ///\return true if the value is invalid, otherwise false. //*************************************************************************** constexpr bool valueless_by_exception() const ETL_NOEXCEPT { From 24e603b27d83a549e4245eec5d25d5f7bc689139 Mon Sep 17 00:00:00 2001 From: mike919192 <91038685+mike919192@users.noreply.github.com> Date: Fri, 3 Oct 2025 05:10:15 -0400 Subject: [PATCH 4/6] Vector checks (#1193) * Add checks to vector and fix test failures * Add tests to vector * Add tests to external buffer and non trivial * All tests should be implemented * Add checks to vector_pointer and vector_pointer_ext * Get bad iterators from a second vector --- include/etl/private/pvoidvector.h | 18 ++ include/etl/vector.h | 25 ++- test/test_vector.cpp | 99 ++++++++++- test/test_vector_external_buffer.cpp | 68 +++++++- test/test_vector_non_trivial.cpp | 90 +++++++++- test/test_vector_pointer.cpp | 164 ++++++++++++++++++- test/test_vector_pointer_external_buffer.cpp | 148 ++++++++++++++++- 7 files changed, 594 insertions(+), 18 deletions(-) diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 9786d740..eda3b020 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -230,6 +230,7 @@ namespace etl //********************************************************************* reference operator [](size_t i) { + ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(vector_out_of_bounds)); return p_buffer[i]; } @@ -240,6 +241,7 @@ namespace etl //********************************************************************* const_reference operator [](size_t i) const { + ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(vector_out_of_bounds)); return p_buffer[i]; } @@ -273,6 +275,7 @@ namespace etl //********************************************************************* reference front() { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return p_buffer[0]; } @@ -282,6 +285,7 @@ namespace etl //********************************************************************* const_reference front() const { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return p_buffer[0]; } @@ -291,6 +295,7 @@ namespace etl //********************************************************************* reference back() { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *(p_end - 1); } @@ -300,6 +305,7 @@ namespace etl //********************************************************************* const_reference back() const { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *(p_end - 1); } @@ -440,6 +446,7 @@ namespace etl iterator insert(const_iterator position, value_type value) { ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -473,6 +480,7 @@ namespace etl iterator emplace(const_iterator position) { ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -503,6 +511,7 @@ namespace etl iterator emplace(const_iterator position, value_type value) { ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -536,6 +545,7 @@ namespace etl void insert(const_iterator position, size_t n, value_type value) { ETL_ASSERT_OR_RETURN((size() + n) <= CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -565,6 +575,7 @@ namespace etl iterator position_ = to_iterator(position); ETL_ASSERT_OR_RETURN((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); etl::mem_move(position_, p_end, position_ + count); etl::copy(first, last, position_); @@ -588,6 +599,7 @@ namespace etl iterator position_ = to_iterator(position); ETL_ASSERT_OR_RETURN((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); etl::mem_move(position_, p_end, position_ + count); etl::mem_move((void**)first, (void**)last, position_); @@ -601,6 +613,8 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= i_element && i_element < cend(), ETL_ERROR(vector_out_of_bounds)); + etl::mem_move(i_element + 1, end(), i_element); --p_end; @@ -614,6 +628,8 @@ namespace etl //********************************************************************* iterator erase(const_iterator i_element) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= i_element && i_element < cend(), ETL_ERROR(vector_out_of_bounds)); + iterator i_element_ = to_iterator(i_element); etl::mem_move(i_element_ + 1, end(), i_element_); @@ -632,6 +648,8 @@ namespace etl //********************************************************************* iterator erase(const_iterator first, const_iterator last) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(vector_out_of_bounds)); + iterator first_ = to_iterator(first); iterator last_ = to_iterator(last); diff --git a/include/etl/vector.h b/include/etl/vector.h index e85d58f2..c36f9b55 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -279,6 +279,7 @@ namespace etl //********************************************************************* reference operator [](size_t i) { + ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(vector_out_of_bounds)); return p_buffer[i]; } @@ -289,6 +290,7 @@ namespace etl //********************************************************************* const_reference operator [](size_t i) const { + ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(vector_out_of_bounds)); return p_buffer[i]; } @@ -322,6 +324,7 @@ namespace etl //********************************************************************* reference front() { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *p_buffer; } @@ -331,6 +334,7 @@ namespace etl //********************************************************************* const_reference front() const { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *p_buffer; } @@ -340,6 +344,7 @@ namespace etl //********************************************************************* reference back() { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *(p_end - 1); } @@ -349,6 +354,7 @@ namespace etl //********************************************************************* const_reference back() const { + ETL_ASSERT_CHECK_EXTRA(size() > 0, ETL_ERROR(vector_out_of_bounds)); return *(p_end - 1); } @@ -570,6 +576,7 @@ namespace etl iterator insert(const_iterator position, const_reference value) { ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -597,6 +604,7 @@ namespace etl iterator insert(const_iterator position, rvalue_reference value) { ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -623,6 +631,7 @@ namespace etl iterator emplace(const_iterator position, Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -650,6 +659,7 @@ namespace etl iterator emplace(const_iterator position, const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -677,6 +687,7 @@ namespace etl iterator emplace(const_iterator position, const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -704,6 +715,7 @@ namespace etl iterator emplace(const_iterator position, const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -731,6 +743,7 @@ namespace etl iterator emplace(const_iterator position, const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -765,6 +778,7 @@ namespace etl void insert(const_iterator position, size_t n, parameter_t value) { ETL_ASSERT_OR_RETURN((size() + n) <= CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); iterator position_ = to_iterator(position); @@ -804,8 +818,8 @@ namespace etl etl::uninitialized_fill_n(p_end, construct_new_n, value); ETL_ADD_DEBUG_COUNT(construct_new_n); - // Copy new. - etl::fill_n(p_buffer + insert_begin, copy_new_n, value); + // Copy new. + etl::fill_n(p_buffer + insert_begin, copy_new_n, value); p_end += n; } @@ -824,6 +838,7 @@ namespace etl size_t count = etl::distance(first, last); ETL_ASSERT_OR_RETURN((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); + ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position <= cend(), ETL_ERROR(vector_out_of_bounds)); size_t insert_n = count; size_t insert_begin = etl::distance(cbegin(), position); @@ -874,6 +889,8 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= i_element && i_element < cend(), ETL_ERROR(vector_out_of_bounds)); + etl::move(i_element + 1, end(), i_element); destroy_back(); @@ -887,6 +904,8 @@ namespace etl //********************************************************************* iterator erase(const_iterator i_element) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= i_element && i_element < cend(), ETL_ERROR(vector_out_of_bounds)); + iterator i_element_ = to_iterator(i_element); etl::move(i_element_ + 1, end(), i_element_); @@ -905,6 +924,8 @@ namespace etl //********************************************************************* iterator erase(const_iterator first, const_iterator last) { + ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(vector_out_of_bounds)); + iterator first_ = to_iterator(first); iterator last_ = to_iterator(last); diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 38c70791..f7df1aaf 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -276,8 +276,8 @@ namespace Data data(10); const Data constData(10); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -459,6 +459,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -472,6 +474,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -509,6 +513,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + Data emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -518,6 +525,9 @@ namespace const Data data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + const Data emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -527,6 +537,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + Data emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -536,8 +549,10 @@ namespace const Data data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); - } + const Data emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); + } //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) @@ -778,6 +793,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + const int INITIAL_VALUE = 1; + + Data data; + Data data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_position_value) { @@ -805,6 +832,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + const int INITIAL_VALUE = 1; + + Data data; + Data data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.emplace(data2.cbegin(), INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST(test_emplace_default) { @@ -849,6 +888,15 @@ namespace CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); } + //************************************************************************* + TEST(test_emplace_out_of_range) + { + etl::vector data; + etl::vector data2; + + CHECK_THROW(data.emplace(data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST(test_emplace_back_default) { @@ -943,6 +991,17 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_outofbounds) + { + const int INITIAL_VALUE = 0; + + Data data; + Data data2; + + CHECK_THROW(data.insert(data2.end(), 1, INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { @@ -996,6 +1055,15 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_out_of_bounds) + { + Data data; + Data data2; + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) { @@ -1046,6 +1114,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_iterator_outofbounds) + { + Data data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { @@ -1071,6 +1147,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator_outofbounds) + { + Data data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { @@ -1096,6 +1180,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range_outofbounds) + { + Data data(initial_data.begin(), initial_data.end()); + Data data2(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_clear) { diff --git a/test/test_vector_external_buffer.cpp b/test/test_vector_external_buffer.cpp index 773e68ea..a8b0c07b 100644 --- a/test/test_vector_external_buffer.cpp +++ b/test/test_vector_external_buffer.cpp @@ -268,8 +268,8 @@ namespace Data data(10, buffer1, SIZE); const Data constData(10, buffer1, SIZE); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -462,6 +462,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -475,6 +477,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -512,6 +516,9 @@ namespace Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK_EQUAL(compare_data.front(), data.front()); + + Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -521,6 +528,9 @@ namespace const Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK_EQUAL(compare_data.front(), data.front()); + + const Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -530,6 +540,9 @@ namespace Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK_EQUAL(compare_data.back(), data.back()); + + Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -539,8 +552,10 @@ namespace const Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK_EQUAL(compare_data.back(), data.back()); - } + const Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); + } //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) @@ -781,6 +796,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + const int INITIAL_VALUE = 1; + + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* #include "etl/private/diagnostic_array_bounds_push.h" TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) @@ -831,6 +858,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_outofbounds) + { + const int INITIAL_VALUE = 11; + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), 1, INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { @@ -909,6 +946,14 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_out_of_bounds) + { + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single) @@ -929,6 +974,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_iterator_outofbounds) + { + Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { @@ -948,6 +1001,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range_outofbounds) + { + Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + Data data2(initial_data.begin(), initial_data.end(), buffer2, SIZE); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_clear) { diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index 0acb1a22..413ca3cd 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -364,8 +364,8 @@ namespace DataDC data(10); const DataDC constData(10); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -465,6 +465,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -478,6 +480,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -515,6 +519,9 @@ namespace DataNDC data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + DataNDC emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -524,6 +531,9 @@ namespace const DataNDC data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + const DataNDC emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -533,6 +543,9 @@ namespace DataNDC data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + DataNDC emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -542,6 +555,9 @@ namespace const DataNDC data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + const DataNDC emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -934,6 +950,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + const NDC INITIAL_VALUE("1"); + + DataNDC data; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + DataNDC data2; + CHECK_THROW(data.insert(data2.cbegin(), INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_position_value) { @@ -961,6 +989,28 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + const std::string INITIAL_VALUE("1"); + + DataNDC data; + DataNDC data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.emplace(data2.cbegin(), INITIAL_VALUE), etl::vector_out_of_bounds); + } + + //************************************************************************* + TEST(test_emplace_out_of_range) + { + DataNDC data; + DataNDC data2; + const std::string INITIAL_VALUE("1"); + + CHECK_THROW(data.emplace(data2.end(), INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* #include "etl/private/diagnostic_array_bounds_push.h" TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) @@ -1012,6 +1062,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_outofbounds) + { + DataNDC data; + DataNDC data2; + const NDC INITIAL_VALUE("1"); + + CHECK_THROW(data.insert(data2.end(), 1, INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { @@ -1091,6 +1151,15 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_out_of_bounds) + { + DataNDC data; + DataNDC data2; + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single) { @@ -1110,6 +1179,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_iterator_outofbounds) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { @@ -1129,6 +1206,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range_outofbounds) + { + DataNDC data(initial_data.begin(), initial_data.end()); + DataNDC data2(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_clear) { diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index f59c8d29..aa41eac0 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -459,8 +459,8 @@ namespace Data data(10); const Data constData(10); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -469,8 +469,8 @@ namespace CData data(10); const CData constData(10); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -654,6 +654,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -667,6 +669,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -680,6 +684,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -693,6 +699,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -758,6 +766,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + Data emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -767,6 +778,9 @@ namespace CData data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + CData emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -776,6 +790,9 @@ namespace const Data data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + const Data emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -785,6 +802,9 @@ namespace const CData data(initial_data.begin(), initial_data.end()); CHECK(data.front() == compare_data.front()); + + const CData emptyData; + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -794,6 +814,9 @@ namespace Data data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + Data emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -803,6 +826,9 @@ namespace CData data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + CData emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -812,6 +838,9 @@ namespace const Data data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + const Data emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -821,6 +850,9 @@ namespace const CData data(initial_data.begin(), initial_data.end()); CHECK(data.back() == compare_data.back()); + + const CData emptyData; + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -1200,6 +1232,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + + Data data; + Data data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_value) { @@ -1225,6 +1269,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + + CData data; + CData data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* #include "etl/private/diagnostic_array_bounds_push.h" TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) @@ -1273,6 +1329,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + + Data data; + Data data2; + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.emplace(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { @@ -1296,6 +1364,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_outofbounds) + { + int INITIAL_VALUE = 0; + Data data; + Data data2; + + CHECK_THROW(data.insert(data2.end(), 1, &INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value) { @@ -1319,6 +1397,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value_outofbounds) + { + int INITIAL_VALUE = 0; + CData data; + CData data2; + + CHECK_THROW(data.insert(data2.end(), 1, &INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { @@ -1394,6 +1482,15 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_out_of_bounds) + { + Data data; + Data data2; + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_pointer_range) { @@ -1417,6 +1514,14 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_pointer_range_out_of_bounds) + { + Data data; + + CHECK_THROW(data.insert(data.data() + data.size() + 1, insert_data.data(), insert_data.data() + insert_data.size());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_range) { @@ -1440,6 +1545,15 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_range_out_of_bounds) + { + CData data; + CData data2; + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) { @@ -1506,6 +1620,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_outofbounds) + { + Data data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_erase_single_iterator) { @@ -1522,6 +1644,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_single_iterator_outofbounds) + { + CData data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_erase_single_const_iterator) { @@ -1538,6 +1668,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_single_const_iterator_outofbounds) + { + CData data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { @@ -1554,6 +1692,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range_outofbounds) + { + Data data(initial_data.begin(), initial_data.end()); + Data data2(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_erase_range) { @@ -1569,6 +1716,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_range_outofbounds) + { + CData data(initial_data.begin(), initial_data.end()); + CData data2(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_clear) { diff --git a/test/test_vector_pointer_external_buffer.cpp b/test/test_vector_pointer_external_buffer.cpp index 975a8d7c..330801d8 100644 --- a/test/test_vector_pointer_external_buffer.cpp +++ b/test/test_vector_pointer_external_buffer.cpp @@ -448,8 +448,8 @@ namespace Data data(10, buffer1, SIZE); const Data constData(10, buffer2, SIZE); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -458,8 +458,8 @@ namespace CData data(10, buffer1, SIZE); const CData constData(10, buffer2, SIZE); - CHECK_EQUAL(&data[10], data.end()); - CHECK_EQUAL(&constData[10], constData.end()); + CHECK_EQUAL(data.begin() + data.size(), data.end()); + CHECK_EQUAL(constData.begin() + constData.size(), constData.end()); } //************************************************************************* @@ -645,6 +645,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -658,6 +660,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -671,6 +675,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -684,6 +690,8 @@ namespace { CHECK_EQUAL(data[i], compare_data[i]); } + + CHECK_THROW(data[data.size()], etl::vector_out_of_bounds); } //************************************************************************* @@ -749,6 +757,9 @@ namespace Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.front() == compare_data.front()); + + Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -758,6 +769,9 @@ namespace CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.front() == compare_data.front()); + + CData emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -767,6 +781,9 @@ namespace const Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.front() == compare_data.front()); + + const Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -776,6 +793,9 @@ namespace const CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.front() == compare_data.front()); + + const CData emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.front(), etl::vector_out_of_bounds); } //************************************************************************* @@ -785,6 +805,9 @@ namespace Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.back() == compare_data.back()); + + Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -794,6 +817,9 @@ namespace CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.back() == compare_data.back()); + + CData emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -803,6 +829,9 @@ namespace const Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.back() == compare_data.back()); + + const Data emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -812,6 +841,9 @@ namespace const CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); CHECK(data.back() == compare_data.back()); + + const CData emptyData(buffer1, SIZE); + CHECK_THROW(emptyData.back(), etl::vector_out_of_bounds); } //************************************************************************* @@ -1149,6 +1181,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5UL; + int INITIAL_VALUE = 1; + + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_value) { @@ -1174,6 +1218,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5UL; + int INITIAL_VALUE = 1; + + CData data(buffer1, SIZE); + CData data2(buffer2, SIZE); + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.insert(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* #include "etl/private/diagnostic_array_bounds_push.h" TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) @@ -1222,6 +1278,18 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_value_outofbounds) + { + const size_t INITIAL_SIZE = 5UL; + int INITIAL_VALUE = 1; + + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + CHECK_THROW(data.emplace(data2.cbegin(), &INITIAL_VALUE), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { @@ -1245,6 +1313,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_outofbounds) + { + int INITIAL_VALUE = 0; + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), 1, &INITIAL_VALUE);, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value) { @@ -1268,6 +1346,16 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value_outofbounds) + { + int INITIAL_VALUE = 0; + CData data(buffer1, SIZE); + CData data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), 1, &INITIAL_VALUE);, etl::vector_out_of_bounds); + } + #include "etl/private/diagnostic_array_bounds_push.h" //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) @@ -1345,6 +1433,15 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_out_of_bounds) + { + Data data(buffer1, SIZE); + Data data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_insert_position_range) { @@ -1368,6 +1465,15 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_range_out_of_bounds) + { + CData data(buffer1, SIZE); + CData data2(buffer2, SIZE); + + CHECK_THROW(data.insert(data2.end(), insert_data.cbegin(), insert_data.cend());, etl::vector_out_of_bounds); + } + #include "etl/private/diagnostic_array_bounds_push.h" //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) @@ -1435,6 +1541,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_outofbounds) + { + Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_erase_single) { @@ -1450,6 +1564,14 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_single_outofbounds) + { + CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + + CHECK_THROW(data.erase(data.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { @@ -1465,6 +1587,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range_outofbounds) + { + Data data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + Data data2(initial_data.begin(), initial_data.end(), buffer2, SIZE); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_erase_range) { @@ -1480,6 +1611,15 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_range_outofbounds) + { + CData data(initial_data.begin(), initial_data.end(), buffer1, SIZE); + CData data2(initial_data.begin(), initial_data.end(), buffer2, SIZE); + + CHECK_THROW(data.erase(data2.begin(), data2.end());, etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_clear) { From ed718a97e9aea99649b9140a9b410d45e4930c6a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 17 Sep 2025 20:44:52 +0100 Subject: [PATCH 5/6] Added and fixed noexcept attributes Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function. # Conflicts: # include/etl/platform.h --- include/etl/array.h | 2 +- include/etl/array_view.h | 58 +++++++-------- include/etl/array_wrapper.h | 36 +++++----- include/etl/char_traits.h | 42 +++++------ include/etl/memory.h | 4 +- include/etl/platform.h | 1 + include/etl/span.h | 4 +- include/etl/string_view.h | 138 ++++++++++++++++++------------------ 8 files changed, 143 insertions(+), 142 deletions(-) diff --git a/include/etl/array.h b/include/etl/array.h index a238269e..953b5bea 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -397,7 +397,7 @@ namespace etl /// Swaps the contents of this array and another. ///\param other A reference to the other array. //************************************************************************* - ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT + ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval(), etl::declval())) { using ETL_OR_STD::swap; // Allow ADL diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 653a8954..5015d55e 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -123,7 +123,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - ETL_CONSTEXPR array_view() + ETL_CONSTEXPR array_view() ETL_NOEXCEPT : mbegin(ETL_NULLPTR), mend(ETL_NULLPTR) { @@ -238,7 +238,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) + ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT : mbegin(etl::to_address(begin_)), mend(etl::to_address(begin_) + etl::distance(begin_, end_)) { @@ -249,7 +249,7 @@ namespace etl //************************************************************************* template - ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) + ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) ETL_NOEXCEPT : mbegin(etl::to_address(begin_)), mend(etl::to_address(begin_) + size_) { @@ -259,7 +259,7 @@ namespace etl /// Construct from C array //************************************************************************* template - ETL_CONSTEXPR array_view(T(&begin_)[Array_Size]) + ETL_CONSTEXPR array_view(T(&begin_)[Array_Size]) ETL_NOEXCEPT : mbegin(begin_), mend(begin_ + Array_Size) { @@ -268,7 +268,7 @@ namespace etl //************************************************************************* /// Copy constructor //************************************************************************* - ETL_CONSTEXPR array_view(const array_view& other) + ETL_CONSTEXPR array_view(const array_view& other) ETL_NOEXCEPT : mbegin(other.mbegin), mend(other.mend) { @@ -309,7 +309,7 @@ namespace etl //************************************************************************* /// Returns a pointer to the first element of the internal storage. //************************************************************************* - pointer data() + pointer data() ETL_NOEXCEPT { return mbegin; } @@ -317,7 +317,7 @@ namespace etl //************************************************************************* /// Returns a const pointer to the first element of the internal storage. //************************************************************************* - const_pointer data() const + const_pointer data() const ETL_NOEXCEPT { return mbegin; } @@ -325,7 +325,7 @@ namespace etl //************************************************************************* /// Returns an iterator to the beginning of the array. //************************************************************************* - iterator begin() + iterator begin() ETL_NOEXCEPT { return mbegin; } @@ -333,7 +333,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - const_iterator begin() const + const_iterator begin() const ETL_NOEXCEPT { return mbegin; } @@ -341,7 +341,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - const_iterator cbegin() const + const_iterator cbegin() const ETL_NOEXCEPT { return mbegin; } @@ -349,7 +349,7 @@ namespace etl //************************************************************************* /// Returns an iterator to the end of the array. //************************************************************************* - iterator end() + iterator end() ETL_NOEXCEPT { return mend; } @@ -357,7 +357,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the end of the array. //************************************************************************* - const_iterator end() const + const_iterator end() const ETL_NOEXCEPT { return mend; } @@ -365,7 +365,7 @@ namespace etl //************************************************************************* // Returns a const iterator to the end of the array. //************************************************************************* - const_iterator cend() const + const_iterator cend() const ETL_NOEXCEPT { return mend; } @@ -373,7 +373,7 @@ namespace etl //************************************************************************* // Returns an reverse iterator to the reverse beginning of the array. //************************************************************************* - reverse_iterator rbegin() + reverse_iterator rbegin() ETL_NOEXCEPT { return reverse_iterator(mend); } @@ -381,7 +381,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - const_reverse_iterator rbegin() const + const_reverse_iterator rbegin() const ETL_NOEXCEPT { return const_reverse_iterator(mend); } @@ -389,7 +389,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - const_reverse_iterator crbegin() const + const_reverse_iterator crbegin() const ETL_NOEXCEPT { return const_reverse_iterator(mend); } @@ -397,7 +397,7 @@ namespace etl //************************************************************************* /// Returns a reverse iterator to the end of the array. //************************************************************************* - reverse_iterator rend() + reverse_iterator rend() ETL_NOEXCEPT { return reverse_iterator(mbegin); } @@ -405,7 +405,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - const_reverse_iterator rend() const + const_reverse_iterator rend() const ETL_NOEXCEPT { return const_reverse_iterator(mbegin); } @@ -413,7 +413,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - const_reverse_iterator crend() const + const_reverse_iterator crend() const ETL_NOEXCEPT { return const_reverse_iterator(mbegin); } @@ -421,7 +421,7 @@ namespace etl //************************************************************************* /// Returns true if the array size is zero. //************************************************************************* - ETL_CONSTEXPR bool empty() const + ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT { return (mbegin == mend); } @@ -429,7 +429,7 @@ namespace etl //************************************************************************* /// Returns the size of the array. //************************************************************************* - ETL_CONSTEXPR size_t size() const + ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT { return static_cast(mend - mbegin); } @@ -437,7 +437,7 @@ namespace etl //************************************************************************* /// Returns the maximum possible size of the array. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT { return size(); } @@ -445,7 +445,7 @@ namespace etl //************************************************************************* /// Assign from a view. //************************************************************************* - array_view& operator=(const array_view& other) + array_view& operator=(const array_view& other) ETL_NOEXCEPT { mbegin = other.mbegin; mend = other.mend; @@ -477,7 +477,7 @@ namespace etl //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* - reference operator[](const size_t i) + reference operator[](const size_t i) ETL_NOEXCEPT { return mbegin[i]; } @@ -486,7 +486,7 @@ namespace etl //************************************************************************* /// Returns a const reference to the indexed value. //************************************************************************* - const_reference operator[](const size_t i) const + const_reference operator[](const size_t i) const ETL_NOEXCEPT { return mbegin[i]; } @@ -516,7 +516,7 @@ namespace etl //************************************************************************* /// Swaps with another array_view. //************************************************************************* - void swap(array_view& other) + void swap(array_view& other) ETL_NOEXCEPT { using ETL_OR_STD::swap; // Allow ADL @@ -527,7 +527,7 @@ namespace etl //************************************************************************* /// Shrinks the view by moving its start forward. //************************************************************************* - void remove_prefix(const size_type n) + void remove_prefix(const size_type n) ETL_NOEXCEPT { if (n < size()) mbegin += n; @@ -538,7 +538,7 @@ namespace etl //************************************************************************* /// Shrinks the view by moving its end backward. //************************************************************************* - void remove_suffix(const size_type n) + void remove_suffix(const size_type n) ETL_NOEXCEPT { if (n < size()) mend -= n; @@ -647,7 +647,7 @@ namespace etl /// Swaps the values. //************************************************************************* template -void swap(etl::array_view& lhs, etl::array_view& rhs) +void swap(etl::array_view& lhs, etl::array_view& rhs) ETL_NOEXCEPT { lhs.swap(rhs); } diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index 72655f98..b422634d 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -141,7 +141,7 @@ namespace etl //************************************************************************* /// Returns a pointer to the first element of the internal storage. //************************************************************************* - pointer data() + pointer data() ETL_NOEXCEPT { return &ARRAY_[BEGIN]; } @@ -149,7 +149,7 @@ namespace etl //************************************************************************* /// Returns a const pointer to the first element of the internal storage. //************************************************************************* - ETL_CONSTEXPR const_pointer data() const + ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT { return &ARRAY_[BEGIN]; } @@ -157,7 +157,7 @@ namespace etl //************************************************************************* /// Returns an iterator to the beginning of the array. //************************************************************************* - iterator begin() + iterator begin() ETL_NOEXCEPT { return &ARRAY_[BEGIN]; } @@ -165,7 +165,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator begin() const + ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT { return &ARRAY_[BEGIN]; } @@ -173,7 +173,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator cbegin() const + ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT { return &ARRAY_[BEGIN]; } @@ -181,7 +181,7 @@ namespace etl //************************************************************************* /// Returns an iterator to the end of the array. //************************************************************************* - iterator end() + iterator end() ETL_NOEXCEPT { return &ARRAY_[END]; } @@ -189,7 +189,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator end() const + ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT { return &ARRAY_[END]; } @@ -197,7 +197,7 @@ namespace etl //************************************************************************* // Returns a const iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator cend() const + ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT { return &ARRAY_[END]; } @@ -205,7 +205,7 @@ namespace etl //************************************************************************* // Returns an reverse iterator to the reverse beginning of the array. //************************************************************************* - reverse_iterator rbegin() + reverse_iterator rbegin() ETL_NOEXCEPT { return reverse_iterator(&ARRAY_[END]); } @@ -213,7 +213,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator rbegin() const + ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT { return const_reverse_iterator(&ARRAY_[END]); } @@ -221,7 +221,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator crbegin() const + ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT { return const_reverse_iterator(&ARRAY_[END]); } @@ -229,7 +229,7 @@ namespace etl //************************************************************************* /// Returns a reverse iterator to the end of the array. //************************************************************************* - reverse_iterator rend() + reverse_iterator rend() ETL_NOEXCEPT { return reverse_iterator(&ARRAY_[BEGIN]); } @@ -237,7 +237,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator rend() const + ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT { return const_reverse_iterator(&ARRAY_[BEGIN]); } @@ -245,7 +245,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator crend() const + ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT { return const_reverse_iterator(&ARRAY_[BEGIN]); } @@ -253,7 +253,7 @@ namespace etl //************************************************************************* /// Returns the size of the array. //************************************************************************* - ETL_CONSTEXPR size_t size() const + ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT { return SIZE; } @@ -261,7 +261,7 @@ namespace etl //************************************************************************* /// Returns the maximum possible size of the array. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT { return MAX_SIZE; } @@ -269,7 +269,7 @@ namespace etl //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* - reference operator[](size_t i) + reference operator[](size_t i) ETL_NOEXCEPT { return ARRAY_[i]; } @@ -277,7 +277,7 @@ namespace etl //************************************************************************* /// Returns a const reference to the indexed value. //************************************************************************* - ETL_CONSTEXPR const_reference operator[](size_t i) const + ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT { return ARRAY_[i]; } diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index 25ed1638..d298914f 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -125,19 +125,19 @@ namespace etl typedef typename char_traits_types::state_type state_type; //************************************************************************* - static ETL_CONSTEXPR bool eq(char_type a, char_type b) + static ETL_CONSTEXPR bool eq(char_type a, char_type b) ETL_NOEXCEPT { return a == b; } //************************************************************************* - static ETL_CONSTEXPR bool lt(char_type a, char_type b) + static ETL_CONSTEXPR bool lt(char_type a, char_type b) ETL_NOEXCEPT { return a < b; } //************************************************************************* - static ETL_CONSTEXPR14 size_t length(const char_type* begin) + static ETL_CONSTEXPR14 size_t length(const char_type* begin) ETL_NOEXCEPT { if (begin == ETL_NULLPTR) { @@ -155,7 +155,7 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 size_t length(const char_type* str, size_t max_length) + static ETL_CONSTEXPR14 size_t length(const char_type* str, size_t max_length) ETL_NOEXCEPT { size_t count = 0UL; @@ -171,13 +171,13 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 void assign(char_type& r, const char_type& c) + static ETL_CONSTEXPR14 void assign(char_type& r, const char_type& c) ETL_NOEXCEPT { r = c; } //************************************************************************* - static ETL_CONSTEXPR14 char_type* assign(char_type* p, size_t n, char_type c) + static ETL_CONSTEXPR14 char_type* assign(char_type* p, size_t n, char_type c) ETL_NOEXCEPT { if (p != ETL_NULLPTR) { @@ -188,7 +188,7 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 char_type* move(char_type* dst, const char_type* src, size_t count) + static ETL_CONSTEXPR14 char_type* move(char_type* dst, const char_type* src, size_t count) ETL_NOEXCEPT { if ((dst < src) || (dst > (src + count))) { @@ -205,7 +205,7 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 char_type* copy(char_type* dst, const char_type* src, size_t count) + static ETL_CONSTEXPR14 char_type* copy(char_type* dst, const char_type* src, size_t count) ETL_NOEXCEPT { etl::copy_n(src, count, dst); @@ -213,7 +213,7 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 int compare(const char_type* s1, const char_type* s2, size_t count) + static ETL_CONSTEXPR14 int compare(const char_type* s1, const char_type* s2, size_t count) ETL_NOEXCEPT { for (size_t i = 0UL; i < count; ++i) { @@ -234,7 +234,7 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR14 const char_type* find(const char_type* p, size_t count, const char_type& ch) + static ETL_CONSTEXPR14 const char_type* find(const char_type* p, size_t count, const char_type& ch) ETL_NOEXCEPT { for (size_t i = 0UL; i < count; ++i) { @@ -250,31 +250,31 @@ namespace etl } //************************************************************************* - static ETL_CONSTEXPR char_type to_char_type(int_type c) + static ETL_CONSTEXPR char_type to_char_type(int_type c) ETL_NOEXCEPT { return static_cast(c); } //************************************************************************* - static ETL_CONSTEXPR int_type to_int_type(char_type c) + static ETL_CONSTEXPR int_type to_int_type(char_type c) ETL_NOEXCEPT { return static_cast(c); } //************************************************************************* - static ETL_CONSTEXPR bool eq_int_type(int_type c1, int_type c2) + static ETL_CONSTEXPR bool eq_int_type(int_type c1, int_type c2) ETL_NOEXCEPT { return (c1 == c2); } //************************************************************************* - static ETL_CONSTEXPR int_type eof() + static ETL_CONSTEXPR int_type eof() ETL_NOEXCEPT { return -1; } //************************************************************************* - static ETL_CONSTEXPR int_type not_eof(int_type e) + static ETL_CONSTEXPR int_type not_eof(int_type e) ETL_NOEXCEPT { return (e == eof()) ? eof() - 1 : e; } @@ -284,7 +284,7 @@ namespace etl /// Alternative strlen for all character types. //*************************************************************************** template - ETL_CONSTEXPR14 size_t strlen(const T* t) + ETL_CONSTEXPR14 size_t strlen(const T* t) ETL_NOEXCEPT { return etl::char_traits::length(t); } @@ -293,7 +293,7 @@ namespace etl /// Alternative strlen for all character types, with maximum length. //*************************************************************************** template - ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length) + ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length) ETL_NOEXCEPT { return etl::char_traits::length(t, max_length); } @@ -302,7 +302,7 @@ namespace etl /// Alternative strcmp for all character types. //*************************************************************************** template - ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2) + ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2) ETL_NOEXCEPT { while ((*t1 != 0) || (*t2 != 0)) { @@ -327,7 +327,7 @@ namespace etl /// Alternative strncmp for all character types. //*************************************************************************** template - ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n) + ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n) ETL_NOEXCEPT { while (((*t1 != 0) || (*t2 != 0)) && (n != 0)) { @@ -352,7 +352,7 @@ namespace etl /// Alternative strcpy for all character types. //*************************************************************************** template - ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src) + ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src) ETL_NOEXCEPT { T* result = dst; @@ -370,7 +370,7 @@ namespace etl /// Alternative strncpy for all character types. //*************************************************************************** template - ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n) + ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n) ETL_NOEXCEPT { T* result = dst; diff --git a/include/etl/memory.h b/include/etl/memory.h index 119c1fce..c2e162bd 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -59,7 +59,7 @@ namespace etl /// Defined when not using the STL or C++20 //***************************************************************************** template - ETL_CONSTEXPR T* to_address(T* p) + ETL_CONSTEXPR T* to_address(T* p) ETL_NOEXCEPT { return p; } @@ -70,7 +70,7 @@ namespace etl /// Defined when not using the STL or C++20 //***************************************************************************** template - ETL_CONSTEXPR typename Iterator::pointer to_address(const Iterator& itr) + ETL_CONSTEXPR typename Iterator::pointer to_address(const Iterator& itr) ETL_NOEXCEPT { return etl::to_address(itr.operator->()); } diff --git a/include/etl/platform.h b/include/etl/platform.h index f6658d49..5e239aa4 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -359,6 +359,7 @@ SOFTWARE. #define ETL_NORETURN #define ETL_NOEXCEPT #define ETL_NOEXCEPT_EXPR(...) + #define ETL_NOEXCEPT_FROM(x) #define ETL_MOVE(x) x #define ETL_ENUM_CLASS(name) enum name #define ETL_ENUM_CLASS_TYPE(name, type) enum name diff --git a/include/etl/span.h b/include/etl/span.h index 935e82da..b2d6f76b 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -141,7 +141,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - ETL_CONSTEXPR explicit span(const TIterator begin_, const TIterator /*end_*/) + ETL_CONSTEXPR explicit span(const TIterator begin_, const TIterator /*end_*/) ETL_NOEXCEPT : pbegin(etl::to_address(begin_)) { } @@ -585,7 +585,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - ETL_CONSTEXPR span(const TIterator begin_, const TIterator end_) + ETL_CONSTEXPR span(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT : pbegin(etl::to_address(begin_)) , pend(etl::to_address(begin_) + etl::distance(begin_, end_)) { diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 0ed1ad85..4e596594 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -132,7 +132,7 @@ namespace etl //************************************************************************* /// Construct from string. //************************************************************************* - ETL_CONSTEXPR basic_string_view(const etl::ibasic_string& str) + ETL_CONSTEXPR basic_string_view(const etl::ibasic_string& str) ETL_NOEXCEPT : mbegin(str.begin()) , mend(str.end()) { @@ -141,7 +141,7 @@ namespace etl //************************************************************************* /// Construct from T*. //************************************************************************* - ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_) + ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_) ETL_NOEXCEPT : mbegin(begin_) , mend(begin_ + TTraits::length(begin_)) { @@ -150,7 +150,7 @@ namespace etl //************************************************************************* /// Construct from pointer range. //************************************************************************* - ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_) + ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_) ETL_NOEXCEPT : mbegin(begin_) , mend(end_) { @@ -159,7 +159,7 @@ namespace etl //************************************************************************* /// Construct from pointer/size. //************************************************************************* - ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_) + ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_) ETL_NOEXCEPT : mbegin(begin_) , mend(begin_ + size_) { @@ -193,7 +193,7 @@ namespace etl //************************************************************************* /// Returns a const pointer to the first element of the internal storage. //************************************************************************* - ETL_CONSTEXPR const_pointer data() const + ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT { return mbegin; } @@ -201,7 +201,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator begin() const + ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT { return mbegin; } @@ -209,7 +209,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator cbegin() const + ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT { return mbegin; } @@ -217,7 +217,7 @@ namespace etl //************************************************************************* /// Returns a const iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator end() const + ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT { return mend; } @@ -225,7 +225,7 @@ namespace etl //************************************************************************* // Returns a const iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_iterator cend() const + ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT { return mend; } @@ -233,7 +233,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator rbegin() const + ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT { return const_reverse_iterator(mend); } @@ -241,7 +241,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the reverse beginning of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator crbegin() const + ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT { return const_reverse_iterator(mend); } @@ -249,7 +249,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator rend() const + ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT { return const_reverse_iterator(mbegin); } @@ -257,7 +257,7 @@ namespace etl //************************************************************************* /// Returns a const reverse iterator to the end of the array. //************************************************************************* - ETL_CONSTEXPR const_reverse_iterator crend() const + ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT { return const_reverse_iterator(mbegin); } @@ -269,7 +269,7 @@ namespace etl //************************************************************************* /// Returns true if the array size is zero. //************************************************************************* - ETL_CONSTEXPR bool empty() const + ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT { return (mbegin == mend); } @@ -277,7 +277,7 @@ namespace etl //************************************************************************* /// Returns the size of the array. //************************************************************************* - ETL_CONSTEXPR size_t size() const + ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT { return static_cast(mend - mbegin); } @@ -285,7 +285,7 @@ namespace etl //************************************************************************* /// Returns the size of the array. //************************************************************************* - ETL_CONSTEXPR size_t length() const + ETL_CONSTEXPR size_t length() const ETL_NOEXCEPT { return size(); } @@ -293,7 +293,7 @@ namespace etl //************************************************************************* /// Returns the maximum possible size of the array. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT { return size(); } @@ -301,7 +301,7 @@ namespace etl //************************************************************************* /// Assign from a view. //************************************************************************* - ETL_CONSTEXPR14 etl::basic_string_view& operator=(const etl::basic_string_view& other) + ETL_CONSTEXPR14 etl::basic_string_view& operator=(const etl::basic_string_view& other) ETL_NOEXCEPT { mbegin = other.mbegin; mend = other.mend; @@ -311,7 +311,7 @@ namespace etl //************************************************************************* /// Assign from iterators //************************************************************************* - ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_) + ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_) ETL_NOEXCEPT { mbegin = begin_; mend = end_; @@ -320,7 +320,7 @@ namespace etl //************************************************************************* /// Assign from iterator and size. //************************************************************************* - ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_) + ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_) ETL_NOEXCEPT { mbegin = begin_; mend = begin_ + size_; @@ -329,7 +329,7 @@ namespace etl //************************************************************************* /// Returns a const reference to the indexed value. //************************************************************************* - ETL_CONSTEXPR const_reference operator[](size_t i) const + ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT { return mbegin[i]; } @@ -358,7 +358,7 @@ namespace etl //************************************************************************* /// Copies characters //************************************************************************* - ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const + ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const ETL_NOEXCEPT { size_t n = 0UL; @@ -375,7 +375,7 @@ namespace etl //************************************************************************* /// Returns a substring //************************************************************************* - ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const + ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const ETL_NOEXCEPT { basic_string_view view = basic_string_view(); @@ -392,7 +392,7 @@ namespace etl //************************************************************************* /// Shrinks the view by moving its start forward. //************************************************************************* - ETL_CONSTEXPR14 void remove_prefix(size_type n) + ETL_CONSTEXPR14 void remove_prefix(size_type n) ETL_NOEXCEPT { mbegin += n; } @@ -400,7 +400,7 @@ namespace etl //************************************************************************* /// Shrinks the view by moving its end backward. //************************************************************************* - ETL_CONSTEXPR14 void remove_suffix(size_type n) + ETL_CONSTEXPR14 void remove_suffix(size_type n) ETL_NOEXCEPT { mend -= n; } @@ -408,24 +408,24 @@ namespace etl //************************************************************************* /// Compares two views //************************************************************************* - ETL_CONSTEXPR14 int compare(basic_string_view view) const + ETL_CONSTEXPR14 int compare(basic_string_view view) const ETL_NOEXCEPT { return (*this == view) ? 0 : ((*this > view) ? 1 : -1); } - ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const + ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const ETL_NOEXCEPT { return substr(position, count).compare(view); } ETL_CONSTEXPR14 int compare(size_type position1, size_type count1, basic_string_view view, - size_type position2, size_type count2) const + size_type position2, size_type count2) const ETL_NOEXCEPT { return substr(position1, count1).compare(view.substr(position2, count2)); } - ETL_CONSTEXPR14 int compare(const T* text) const + ETL_CONSTEXPR14 int compare(const T* text) const ETL_NOEXCEPT { const T* view_itr = mbegin; const T* text_itr = text; @@ -458,12 +458,12 @@ namespace etl } } - ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const + ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const ETL_NOEXCEPT { return substr(position, count).compare(text); } - ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const + ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const ETL_NOEXCEPT { return substr(position, count1).compare(etl::basic_string_view(text, count2)); } @@ -471,18 +471,18 @@ namespace etl //************************************************************************* /// Checks if the string view starts with the given prefix //************************************************************************* - ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view view) const + ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view view) const ETL_NOEXCEPT { return (size() >= view.size()) && (compare(0, view.size(), view) == 0); } - ETL_CONSTEXPR14 bool starts_with(T c) const + ETL_CONSTEXPR14 bool starts_with(T c) const ETL_NOEXCEPT { return !empty() && (front() == c); } - ETL_CONSTEXPR14 bool starts_with(const T* text) const + ETL_CONSTEXPR14 bool starts_with(const T* text) const ETL_NOEXCEPT { size_t lengthtext = TTraits::length(text); @@ -493,7 +493,7 @@ namespace etl //************************************************************************* /// Checks if the string view ends with the given suffix //************************************************************************* - ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view view) const + ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view view) const ETL_NOEXCEPT { return (size() >= view.size()) && (compare(size() - view.size(), npos, view) == 0); @@ -516,7 +516,7 @@ namespace etl //************************************************************************* /// Find characters in the view //************************************************************************* - ETL_CONSTEXPR14 size_type find(etl::basic_string_view view, size_type position = 0) const + ETL_CONSTEXPR14 size_type find(etl::basic_string_view view, size_type position = 0) const ETL_NOEXCEPT { if ((size() < view.size())) { @@ -535,17 +535,17 @@ namespace etl } } - ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const + ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const ETL_NOEXCEPT { return find(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return find(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const + ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const ETL_NOEXCEPT { return find(etl::basic_string_view(text), position); } @@ -553,7 +553,7 @@ namespace etl //************************************************************************* /// Find the last occurrence of a substring //************************************************************************* - ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view view, size_type position = npos) const + ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view view, size_type position = npos) const ETL_NOEXCEPT { if ((size() < view.size())) { @@ -577,17 +577,17 @@ namespace etl } } - ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const + ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const ETL_NOEXCEPT { return rfind(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return rfind(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const + ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const ETL_NOEXCEPT { return rfind(etl::basic_string_view(text), position); } @@ -595,7 +595,7 @@ namespace etl //************************************************************************* /// Find first occurrence of characters //************************************************************************* - ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view view, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view view, size_type position = 0) const ETL_NOEXCEPT { const size_t lengthtext = size(); @@ -618,17 +618,17 @@ namespace etl return npos; } - ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const ETL_NOEXCEPT { return find_first_of(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return find_first_of(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const ETL_NOEXCEPT { return find_first_of(etl::basic_string_view(text), position); } @@ -636,7 +636,7 @@ namespace etl //************************************************************************* /// Find last occurrence of characters //************************************************************************* - ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view view, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view view, size_type position = npos) const ETL_NOEXCEPT { if (empty()) { @@ -666,17 +666,17 @@ namespace etl return npos; } - ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const ETL_NOEXCEPT { return find_last_of(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return find_last_of(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const ETL_NOEXCEPT { return find_last_of(etl::basic_string_view(text), position); } @@ -684,7 +684,7 @@ namespace etl //************************************************************************* /// Find first absence of characters //************************************************************************* - ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view view, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view view, size_type position = 0) const ETL_NOEXCEPT { const size_t lengthtext = size(); @@ -715,17 +715,17 @@ namespace etl return npos; } - ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const ETL_NOEXCEPT { return find_first_not_of(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return find_first_not_of(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const + ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const ETL_NOEXCEPT { return find_first_not_of(etl::basic_string_view(text), position); } @@ -733,7 +733,7 @@ namespace etl //************************************************************************* /// Find last absence of characters //************************************************************************* - ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view view, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view view, size_type position = npos) const ETL_NOEXCEPT { if (empty()) { @@ -771,17 +771,17 @@ namespace etl return npos; } - ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const ETL_NOEXCEPT { return find_last_not_of(etl::basic_string_view(&c, 1), position); } - ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const + ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const ETL_NOEXCEPT { return find_last_not_of(etl::basic_string_view(text, count), position); } - ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const + ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const ETL_NOEXCEPT { return find_last_not_of(etl::basic_string_view(text), position); } @@ -789,7 +789,7 @@ namespace etl //********************************************************************* /// Checks that the view is within this string //********************************************************************* - bool contains(const etl::basic_string_view& view) const + bool contains(const etl::basic_string_view& view) const ETL_NOEXCEPT { return find(view) != npos; } @@ -797,7 +797,7 @@ namespace etl //********************************************************************* /// Checks that text is within this string //********************************************************************* - bool contains(const_pointer s) const + bool contains(const_pointer s) const ETL_NOEXCEPT { return find(s) != npos; } @@ -805,7 +805,7 @@ namespace etl //********************************************************************* /// Checks that character is within this string //********************************************************************* - bool contains(value_type c) const + bool contains(value_type c) const ETL_NOEXCEPT { return find(c) != npos; } @@ -875,7 +875,7 @@ namespace etl /// make_string_view. //************************************************************************* template - ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size]) + ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size]) ETL_NOEXCEPT { size_t length = etl::char_traits::length(text, Array_Size - 1U); @@ -884,7 +884,7 @@ namespace etl //*********************************** template - ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size]) + ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size]) ETL_NOEXCEPT { size_t length = etl::char_traits::length(text, Array_Size - 1U); @@ -893,7 +893,7 @@ namespace etl //*********************************** template - ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size]) + ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size]) ETL_NOEXCEPT { size_t length = etl::char_traits::length(text, Array_Size - 1U); @@ -902,7 +902,7 @@ namespace etl //*********************************** template - ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size]) + ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size]) ETL_NOEXCEPT { size_t length = etl::char_traits::length(text, Array_Size - 1U); @@ -911,7 +911,7 @@ namespace etl //*********************************** template - ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size]) + ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size]) ETL_NOEXCEPT { size_t length = etl::char_traits::length(text, Array_Size - 1U); @@ -968,13 +968,13 @@ namespace etl /// Swaps the values. //************************************************************************* template -void swap(etl::basic_string_view& lhs, etl::basic_string_view& rhs) +void swap(etl::basic_string_view& lhs, etl::basic_string_view& rhs) ETL_NOEXCEPT { lhs.swap(rhs); } template -void swap(etl::basic_string_view >& lhs, etl::basic_string_view >& rhs) +void swap(etl::basic_string_view >& lhs, etl::basic_string_view >& rhs) ETL_NOEXCEPT { lhs.swap(rhs); } From d21b0a27f0310867dc765ac7cac81e51d521206b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 4 Oct 2025 08:02:17 +0100 Subject: [PATCH 6/6] Restore ETL_NOEXCEPT_FROM missing from merges --- include/etl/platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/etl/platform.h b/include/etl/platform.h index 5e239aa4..a4710d09 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -344,9 +344,11 @@ SOFTWARE. #if ETL_USING_EXCEPTIONS #define ETL_NOEXCEPT noexcept #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) + #define ETL_NOEXCEPT_FROM(x) noexcept(noexcept(x)) #else #define ETL_NOEXCEPT #define ETL_NOEXCEPT_EXPR(...) + #define ETL_NOEXCEPT_FROM(x) #endif #else #define ETL_CONSTEXPR