From c9b170a05ac050cee140df67340ea158b9723d78 Mon Sep 17 00:00:00 2001 From: Chiraffollo Date: Wed, 24 Mar 2021 09:57:28 +0100 Subject: [PATCH 1/4] Add moveable parameter support to delegate (#356) * Add moveable parameter support * Change std::forward to etl::forward --- include/etl/delegate.h | 17 ++++---- test/test_delegate.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/include/etl/delegate.h b/include/etl/delegate.h index f9ee7714..7fa1eaf7 100644 --- a/include/etl/delegate.h +++ b/include/etl/delegate.h @@ -52,6 +52,7 @@ Original publication: https://www.codeproject.com/Articles/1170503/The-Impossibl #include "error_handler.h" #include "exception.h" #include "type_traits.h" +#include "utility.h" #if ETL_CPP11_NOT_SUPPORTED #if !defined(ETL_IN_UNIT_TEST) @@ -198,7 +199,7 @@ namespace etl { ETL_ASSERT(is_valid(), ETL_ERROR(delegate_uninitialised)); - return (*invocation.stub)(invocation.object, args...); + return (*invocation.stub)(invocation.object, etl::forward(args)...); } //************************************************************************* @@ -315,7 +316,7 @@ namespace etl static TReturn method_stub(void* object, TParams... params) { T* p = static_cast(object); - return (p->*Method)(params...); + return (p->*Method)(etl::forward(params)...); } //************************************************************************* @@ -325,7 +326,7 @@ namespace etl static TReturn const_method_stub(void* object, TParams... params) { T* const p = static_cast(object); - return (p->*Method)(params...); + return (p->*Method)(etl::forward(params)...); } //************************************************************************* @@ -334,7 +335,7 @@ namespace etl template static TReturn method_instance_stub(void*, TParams... params) { - return (Instance.*Method)(params...); + return (Instance.*Method)(etl::forward(params)...); } //************************************************************************* @@ -343,7 +344,7 @@ namespace etl template static TReturn const_method_instance_stub(void*, TParams... params) { - return (Instance.*Method)(params...); + return (Instance.*Method)(etl::forward(params)...); } #if !defined(ETL_COMPILER_GCC) @@ -353,7 +354,7 @@ namespace etl template static TReturn operator_instance_stub(void*, TParams... params) { - return Instance.operator()(params...); + return Instance.operator()(etl::forward(params)...); } #endif @@ -363,7 +364,7 @@ namespace etl template static TReturn function_stub(void*, TParams... params) { - return (Method)(params...); + return (Method)(etl::forward(params)...); } //************************************************************************* @@ -373,7 +374,7 @@ namespace etl static TReturn lambda_stub(void* object, TParams... arg) { TLambda* p = static_cast(object); - return (p->operator())(arg...); + return (p->operator())(etl::forward(arg)...); } //************************************************************************* diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index 917da8d0..cd8f4cd9 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -46,6 +46,20 @@ namespace int d; }; + //***************************************************************************** + // Test moveable only data structure. + //***************************************************************************** + struct MoveableOnlyData + { + MoveableOnlyData() = default; + ~MoveableOnlyData() = default; + MoveableOnlyData(const MoveableOnlyData&) = delete; + MoveableOnlyData& operator=(const MoveableOnlyData&) = delete; + MoveableOnlyData(MoveableOnlyData&&) = default; + MoveableOnlyData& operator=(MoveableOnlyData&&) = default; + int d; + }; + //***************************************************************************** // The free function taking no parameters. //***************************************************************************** @@ -72,6 +86,15 @@ namespace parameter_correct = (data.d == VALUE1) && (j == VALUE2); } + //***************************************************************************** + // The free function taking a moveable only parameter. + //***************************************************************************** + void free_moveableonly(MoveableOnlyData&& data) + { + function_called = true; + parameter_correct = (data.d == VALUE1); + } + //***************************************************************************** // The test class with member functions. //***************************************************************************** @@ -119,6 +142,14 @@ namespace parameter_correct = (data.d == VALUE1) && (j = VALUE2); } + //******************************************* + // moveable only data + void member_moveableonly(MoveableOnlyData&& data) + { + function_called = true; + parameter_correct = (data.d == VALUE1); + } + //******************************************* // static static void member_static(const Data& data, int j) @@ -265,6 +296,34 @@ namespace CHECK(parameter_correct); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_free_moveableonly) + { + auto d = etl::delegate::create(); + + MoveableOnlyData data; + data.d = VALUE1; + + d(std::move(data)); + + CHECK(function_called); + CHECK(parameter_correct); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_free_moveableonly_constexpr) + { + constexpr auto d = etl::delegate::create(); + + MoveableOnlyData data; + data.d = VALUE1; + + d(std::move(data)); + + CHECK(function_called); + CHECK(parameter_correct); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_lambda_int) { @@ -553,6 +612,36 @@ namespace CHECK(parameter_correct); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_member_moveableonly) + { + Test test; + auto d = etl::delegate::create(test); + + MoveableOnlyData data; + data.d = VALUE1; + + d(std::move(data)); + + CHECK(function_called); + CHECK(parameter_correct); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_member_moveableonly_constexpr) + { + static Test test; + constexpr auto d = etl::delegate::create(test); + + MoveableOnlyData data; + data.d = VALUE1; + + d(std::move(data)); + + CHECK(function_called); + CHECK(parameter_correct); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_member_static) { From 01685a36e97590e90fd3f19d1b901acbceb323bd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 25 Mar 2021 15:19:20 +0000 Subject: [PATCH 2/4] Fix return type for const iterator operators from const_iterator to iterator. --- include/etl/circular_buffer.h | 4 ++-- include/etl/deque.h | 6 ++---- include/etl/forward_list.h | 6 +++--- include/etl/indirect_vector.h | 6 +++--- include/etl/intrusive_forward_list.h | 6 +++--- include/etl/intrusive_list.h | 6 +++--- include/etl/list.h | 6 +++--- include/etl/map.h | 6 +++--- include/etl/multimap.h | 6 +++--- include/etl/multiset.h | 6 +++--- include/etl/reference_flat_map.h | 6 +++--- include/etl/reference_flat_multimap.h | 6 +++--- include/etl/reference_flat_multiset.h | 6 +++--- include/etl/reference_flat_set.h | 6 +++--- include/etl/set.h | 6 +++--- include/etl/unordered_map.h | 6 +++--- include/etl/unordered_multimap.h | 6 +++--- include/etl/unordered_multiset.h | 6 +++--- include/etl/unordered_set.h | 6 +++--- test/test_deque.cpp | 17 +++++++++++++++++ 20 files changed, 72 insertions(+), 57 deletions(-) diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index 513ae868..bc91fbdc 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -199,7 +199,7 @@ namespace etl //************************************************************************* /// * operator //************************************************************************* - const_reference operator *() const + reference operator *() const { return picb->pbuffer[current]; } @@ -215,7 +215,7 @@ namespace etl //************************************************************************* /// -> operator //************************************************************************* - const_pointer operator ->() const + pointer operator ->() const { return picb->pbuffer[current]; } diff --git a/include/etl/deque.h b/include/etl/deque.h index 42ae771f..6206ac67 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -363,7 +363,7 @@ namespace etl } //*************************************************** - const_reference operator *() const + reference operator *() const { return p_buffer[index]; } @@ -375,7 +375,7 @@ namespace etl } //*************************************************** - const_pointer operator ->() const + pointer operator ->() const { return &p_buffer[index]; } @@ -624,8 +624,6 @@ namespace etl return &p_buffer[index]; } - - //*************************************************** friend const_iterator operator +(const const_iterator& lhs, difference_type offset) { diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 6cf66340..6ba204b6 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -444,7 +444,7 @@ namespace etl return iforward_list::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return iforward_list::data_cast(p_node)->value; } @@ -454,7 +454,7 @@ namespace etl return &(iforward_list::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(iforward_list::data_cast(p_node)->value); } @@ -464,7 +464,7 @@ namespace etl return &(iforward_list::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(iforward_list::data_cast(p_node)->value); } diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 98611db5..b5a5e8fa 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -245,7 +245,7 @@ namespace etl return **lookup_itr; } - const_reference operator *() const + reference operator *() const { return **lookup_itr; } @@ -255,7 +255,7 @@ namespace etl return &(**lookup_itr); } - const_pointer operator &() const + pointer operator &() const { return &(**lookup_itr); } @@ -265,7 +265,7 @@ namespace etl return &(**lookup_itr); } - const_pointer operator ->() const + pointer operator ->() const { return &(**lookup_itr); } diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 501415ef..b9706675 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -373,7 +373,7 @@ namespace etl return *p_value; } - const_reference operator *() const + reference operator *() const { return *p_value; } @@ -383,7 +383,7 @@ namespace etl return p_value; } - const_pointer operator &() const + pointer operator &() const { return p_value; } @@ -393,7 +393,7 @@ namespace etl return p_value; } - const_pointer operator ->() const + pointer operator ->() const { return p_value; } diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 3c8df192..2f7fc1c3 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -443,7 +443,7 @@ namespace etl return *p_value; } - const_reference operator *() const + reference operator *() const { return *p_value; } @@ -453,7 +453,7 @@ namespace etl return p_value; } - const_pointer operator &() const + pointer operator &() const { return p_value; } @@ -463,7 +463,7 @@ namespace etl return p_value; } - const_pointer operator ->() const + pointer operator ->() const { return p_value; } diff --git a/include/etl/list.h b/include/etl/list.h index 3185c58d..e0411bbb 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -538,7 +538,7 @@ namespace etl return ilist::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return ilist::data_cast(p_node)->value; } @@ -548,7 +548,7 @@ namespace etl return &(ilist::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(ilist::data_cast(p_node)->value); } @@ -558,7 +558,7 @@ namespace etl return &(ilist::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(ilist::data_cast(p_node)->value); } diff --git a/include/etl/map.h b/include/etl/map.h index 66f4af33..c6eca8cb 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -646,7 +646,7 @@ namespace etl return imap::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return imap::data_cast(p_node)->value; } @@ -656,7 +656,7 @@ namespace etl return &(imap::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(imap::data_cast(p_node)->value); } @@ -666,7 +666,7 @@ namespace etl return &(imap::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(imap::data_cast(p_node)->value); } diff --git a/include/etl/multimap.h b/include/etl/multimap.h index e6816491..427e7b25 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -804,7 +804,7 @@ namespace etl return imultimap::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return imultimap::data_cast(p_node)->value; } @@ -814,7 +814,7 @@ namespace etl return &(imultimap::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(imultimap::data_cast(p_node)->value); } @@ -824,7 +824,7 @@ namespace etl return &(imultimap::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(imultimap::data_cast(p_node)->value); } diff --git a/include/etl/multiset.h b/include/etl/multiset.h index f81bc172..c00d2c12 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -786,7 +786,7 @@ namespace etl return imultiset::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return imultiset::data_cast(p_node)->value; } @@ -796,7 +796,7 @@ namespace etl return &(imultiset::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(imultiset::data_cast(p_node)->value); } @@ -806,7 +806,7 @@ namespace etl return &(imultiset::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(imultiset::data_cast(p_node)->value); } diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 21845dc3..c23217a3 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -183,7 +183,7 @@ namespace etl return *(*ilookup); } - const_reference operator *() const + reference operator *() const { return *(*ilookup); } @@ -193,7 +193,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator &() const + pointer operator &() const { return &(*(*ilookup)); } @@ -203,7 +203,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator ->() const + pointer operator ->() const { return etl::addressof(*(*ilookup)); } diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 613c6bee..7ec9ee23 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -156,7 +156,7 @@ namespace etl return *(*ilookup); } - const_reference operator *() const + reference operator *() const { return *(*ilookup); } @@ -166,7 +166,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator &() const + pointer operator &() const { return &(*(*ilookup)); } @@ -176,7 +176,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator ->() const + pointer operator ->() const { return etl::addressof(*(*ilookup)); } diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index ef5416b2..1df13752 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -173,7 +173,7 @@ namespace etl return *(*ilookup); } - const_reference operator *() const + reference operator *() const { return *(*ilookup); } @@ -183,7 +183,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator &() const + pointer operator &() const { return &(*(*ilookup)); } @@ -193,7 +193,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator ->() const + pointer operator ->() const { return etl::addressof(*(*ilookup)); } diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 5896807d..d7552d66 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -175,7 +175,7 @@ namespace etl return *(*ilookup); } - const_reference operator *() const + reference operator *() const { return *(*ilookup); } @@ -185,7 +185,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator &() const + pointer operator &() const { return &(*(*ilookup)); } @@ -195,7 +195,7 @@ namespace etl return etl::addressof(*(*ilookup)); } - const_pointer operator ->() const + pointer operator ->() const { return etl::addressof(*(*ilookup)); } diff --git a/include/etl/set.h b/include/etl/set.h index 4166c5e5..dee8d6e9 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -624,7 +624,7 @@ namespace etl return iset::data_cast(p_node)->value; } - const_reference operator *() const + reference operator *() const { return iset::data_cast(p_node)->value; } @@ -634,7 +634,7 @@ namespace etl return &(iset::data_cast(p_node)->value); } - const_pointer operator &() const + pointer operator &() const { return &(iset::data_cast(p_node)->value); } @@ -644,7 +644,7 @@ namespace etl return &(iset::data_cast(p_node)->value); } - const_pointer operator ->() const + pointer operator ->() const { return &(iset::data_cast(p_node)->value); } diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 35ced3bc..14ac0fcc 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -253,7 +253,7 @@ namespace etl } //********************************* - const_reference operator *() const + reference operator *() const { return inode->key_value_pair; } @@ -265,7 +265,7 @@ namespace etl } //********************************* - const_pointer operator &() const + pointer operator &() const { return &(inode->key_value_pair); } @@ -277,7 +277,7 @@ namespace etl } //********************************* - const_pointer operator ->() const + pointer operator ->() const { return &(inode->key_value_pair); } diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 4854d56e..d9ff2b0a 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -251,7 +251,7 @@ namespace etl } //********************************* - const_reference operator *() const + reference operator *() const { return inode->key_value_pair; } @@ -263,7 +263,7 @@ namespace etl } //********************************* - const_pointer operator &() const + pointer operator &() const { return &(inode->key_value_pair); } @@ -275,7 +275,7 @@ namespace etl } //********************************* - const_pointer operator ->() const + pointer operator ->() const { return &(inode->key_value_pair); } diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index fcf7551f..5ed84b7c 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -248,7 +248,7 @@ namespace etl } //********************************* - const_reference operator *() const + reference operator *() const { return inode->key; } @@ -260,7 +260,7 @@ namespace etl } //********************************* - const_pointer operator &() const + pointer operator &() const { return &(inode->key); } @@ -272,7 +272,7 @@ namespace etl } //********************************* - const_pointer operator ->() const + pointer operator ->() const { return &(inode->key); } diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 1552d067..5b89bee2 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -249,7 +249,7 @@ namespace etl } //********************************* - const_reference operator *() const + reference operator *() const { return inode->key; } @@ -261,7 +261,7 @@ namespace etl } //********************************* - const_pointer operator &() const + pointer operator &() const { return &(inode->key); } @@ -273,7 +273,7 @@ namespace etl } //********************************* - const_pointer operator ->() const + pointer operator ->() const { return &(inode->key); } diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 9ffe7fe5..3147cf11 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -34,6 +34,7 @@ SOFTWARE. #include #include +#include #include #include #include @@ -1991,5 +1992,21 @@ namespace // No compilation error. etl::deque v(5, 5); } + + //************************************************************************* + TEST(test_sort) + { + std::array initial = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + std::array result = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + etl::deque data(initial.begin(), initial.end()); + std::sort(data.begin(), data.end()); + + bool is_equal = std::equal(data.begin(), + data.end(), + result.begin()); + + CHECK(is_equal); + } }; } From 61b0811d65054e6f99c650366a8b473a08a83d3c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 25 Mar 2021 17:12:17 +0000 Subject: [PATCH 3/4] Change static const to static ETL_CONSTANT --- include/etl/atomic/atomic_std.h | 12 +-- include/etl/basic_string.h | 4 +- include/etl/binary.h | 6 +- include/etl/bitset.h | 10 +- include/etl/constant.h | 2 +- include/etl/cumulative_moving_average.h | 14 +-- include/etl/flags.h | 2 +- include/etl/flat_map.h | 2 +- include/etl/flat_multimap.h | 2 +- include/etl/flat_multiset.h | 2 +- include/etl/flat_set.h | 2 +- include/etl/fnv_1.h | 16 ++-- include/etl/forward_list.h | 2 +- include/etl/generators/smallest_generator.h | 24 ++--- include/etl/generic_pool.h | 2 +- include/etl/indirect_vector.h | 2 +- include/etl/integral_limits.h | 96 ++++++++++---------- include/etl/list.h | 2 +- include/etl/map.h | 2 +- include/etl/multimap.h | 2 +- include/etl/multiset.h | 2 +- include/etl/murmur3.h | 14 +-- include/etl/pearson.h | 2 +- include/etl/priority_queue.h | 2 +- include/etl/queue.h | 2 +- include/etl/queue_mpmc_mutex.h | 2 +- include/etl/queue_spsc_atomic.h | 4 +- include/etl/queue_spsc_isr.h | 2 +- include/etl/queue_spsc_locked.h | 2 +- include/etl/random.h | 20 ++-- include/etl/reference_counted_message_pool.h | 4 +- include/etl/reference_flat_map.h | 2 +- include/etl/reference_flat_multimap.h | 2 +- include/etl/reference_flat_multiset.h | 2 +- include/etl/reference_flat_set.h | 2 +- include/etl/set.h | 2 +- include/etl/smallest.h | 24 ++--- include/etl/stack.h | 2 +- include/etl/string.h | 2 +- include/etl/unordered_map.h | 4 +- include/etl/unordered_multimap.h | 4 +- include/etl/unordered_multiset.h | 4 +- include/etl/unordered_set.h | 4 +- 43 files changed, 158 insertions(+), 158 deletions(-) diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index 7dce3647..91ac2184 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -45,12 +45,12 @@ namespace etl typedef std::memory_order memory_order; - static const etl::memory_order memory_order_relaxed = std::memory_order_relaxed; - static const etl::memory_order memory_order_consume = std::memory_order_consume; - static const etl::memory_order memory_order_acquire = std::memory_order_acquire; - static const etl::memory_order memory_order_release = std::memory_order_release; - static const etl::memory_order memory_order_acq_rel = std::memory_order_acq_rel; - static const etl::memory_order memory_order_seq_cst = std::memory_order_seq_cst; + static ETL_CONSTANT etl::memory_order memory_order_relaxed = std::memory_order_relaxed; + static ETL_CONSTANT etl::memory_order memory_order_consume = std::memory_order_consume; + static ETL_CONSTANT etl::memory_order memory_order_acquire = std::memory_order_acquire; + static ETL_CONSTANT etl::memory_order memory_order_release = std::memory_order_release; + static ETL_CONSTANT etl::memory_order memory_order_acq_rel = std::memory_order_acq_rel; + static ETL_CONSTANT etl::memory_order memory_order_seq_cst = std::memory_order_seq_cst; template class atomic diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 1c45bd4a..8467fc91 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -297,8 +297,8 @@ namespace etl { } - static const uint_least8_t IS_TRUNCATED = etl::bit<0>::value; - static const uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value; + static ETL_CONSTANT uint_least8_t IS_TRUNCATED = etl::bit<0>::value; + static ETL_CONSTANT uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value; size_type current_size; ///< The current number of elements in the string. const size_type CAPACITY; ///< The maximum number of elements in the string. diff --git a/include/etl/binary.h b/include/etl/binary.h index cebaa91f..62854473 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -85,7 +85,7 @@ namespace etl struct max_value_for_nbits { typedef typename etl::smallest_uint_for_bits::type value_type; - static const value_type value = (value_type(1) << (NBITS - 1)) | max_value_for_nbits::value; + static ETL_CONSTANT value_type value = (value_type(1) << (NBITS - 1)) | max_value_for_nbits::value; }; /// Specialisation for when NBITS == 0. @@ -93,7 +93,7 @@ namespace etl struct max_value_for_nbits<0> { typedef etl::smallest_uint_for_bits<0>::type value_type; - static const value_type value = 0; + static ETL_CONSTANT value_type value = 0; }; template @@ -357,7 +357,7 @@ namespace etl struct bit { typedef typename etl::smallest_uint_for_bits::type value_type; - static const value_type value = value_type(1) << POSITION; + static ETL_CONSTANT value_type value = value_type(1) << POSITION; }; template diff --git a/include/etl/bitset.h b/include/etl/bitset.h index d6b2401c..fdf8a2ce 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -137,10 +137,10 @@ namespace etl public: - static const element_t ALL_SET = etl::integral_limits::max; - static const element_t ALL_CLEAR = 0; + static ETL_CONSTANT element_t ALL_SET = etl::integral_limits::max; + static ETL_CONSTANT element_t ALL_CLEAR = 0; - static const size_t BITS_PER_ELEMENT = etl::integral_limits::bits; + static ETL_CONSTANT size_t BITS_PER_ELEMENT = etl::integral_limits::bits; #if ETL_CPP11_SUPPORTED typedef etl::span span_type; @@ -894,11 +894,11 @@ namespace etl class bitset : public etl::ibitset { - static const size_t ARRAY_SIZE = (MAXN % BITS_PER_ELEMENT == 0) ? MAXN / BITS_PER_ELEMENT : MAXN / BITS_PER_ELEMENT + 1; + static ETL_CONSTANT size_t ARRAY_SIZE = (MAXN % BITS_PER_ELEMENT == 0) ? MAXN / BITS_PER_ELEMENT : MAXN / BITS_PER_ELEMENT + 1; public: - static const size_t ALLOCATED_BITS = ARRAY_SIZE * BITS_PER_ELEMENT; + static ETL_CONSTANT size_t ALLOCATED_BITS = ARRAY_SIZE * BITS_PER_ELEMENT; public: diff --git a/include/etl/constant.h b/include/etl/constant.h index 633b5522..205e67d3 100644 --- a/include/etl/constant.h +++ b/include/etl/constant.h @@ -47,7 +47,7 @@ namespace etl typedef T value_type; - static const T value = VALUE; + static ETL_CONSTANT T value = VALUE; }; template diff --git a/include/etl/cumulative_moving_average.h b/include/etl/cumulative_moving_average.h index 3e49affc..b0aaf805 100644 --- a/include/etl/cumulative_moving_average.h +++ b/include/etl/cumulative_moving_average.h @@ -114,16 +114,16 @@ namespace etl typedef typename etl::conditional::value, int32_t, uint32_t>::type scale_t; typedef typename etl::conditional::value, int32_t, uint32_t>::type sample_t; - static const sample_t SAMPLES = static_cast(SAMPLE_SIZE_); - static const scale_t SCALE = static_cast(SCALING_); + static ETL_CONSTANT sample_t SAMPLES = static_cast(SAMPLE_SIZE_); + static ETL_CONSTANT scale_t SCALE = static_cast(SCALING_); public: typedef T value_type; typedef private_cumulative_moving_average::add_insert_iterator add_insert_iterator; - static const size_t SAMPLE_SIZE = SAMPLE_SIZE_; ///< The number of samples averaged over. - static const size_t SCALING = SCALING_; ///< The sample scaling factor. + static ETL_CONSTANT size_t SAMPLE_SIZE = SAMPLE_SIZE_; ///< The number of samples averaged over. + static ETL_CONSTANT size_t SCALING = SCALING_; ///< The sample scaling factor. //************************************************************************* /// Constructor @@ -191,14 +191,14 @@ namespace etl typedef typename etl::conditional::value, int32_t, uint32_t>::type scale_t; typedef typename etl::conditional::value, int32_t, uint32_t>::type sample_t; - static const scale_t SCALE = static_cast(SCALING_); + static ETL_CONSTANT scale_t SCALE = static_cast(SCALING_); public: typedef T value_type; typedef private_cumulative_moving_average::add_insert_iterator add_insert_iterator; - static const size_t SCALING = SCALING_; ///< The sample scaling factor. + static ETL_CONSTANT size_t SCALING = SCALING_; ///< The sample scaling factor. //************************************************************************* /// Constructor @@ -279,7 +279,7 @@ namespace etl typedef T value_type; typedef private_cumulative_moving_average::add_insert_iterator add_insert_iterator; - static const size_t SAMPLE_SIZE = SAMPLE_SIZE_; + static ETL_CONSTANT size_t SAMPLE_SIZE = SAMPLE_SIZE_; //************************************************************************* /// Constructor diff --git a/include/etl/flags.h b/include/etl/flags.h index 937342ef..717b156c 100644 --- a/include/etl/flags.h +++ b/include/etl/flags.h @@ -63,7 +63,7 @@ namespace etl static ETL_CONSTANT value_type ALL_SET = etl::integral_limits::max & MASK; static ETL_CONSTANT value_type ALL_CLEAR = 0; - static const size_t NBITS = etl::integral_limits::bits; + static ETL_CONSTANT size_t NBITS = etl::integral_limits::bits; //************************************************************************* /// Constructor diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index f6243742..3908999c 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -897,7 +897,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 5b7edf1e..81def0c1 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -800,7 +800,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 5833659b..9e0704da 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -752,7 +752,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 690b191d..fa1bc282 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -837,7 +837,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/fnv_1.h b/include/etl/fnv_1.h index b7fae671..a6e51627 100644 --- a/include/etl/fnv_1.h +++ b/include/etl/fnv_1.h @@ -75,8 +75,8 @@ namespace etl return hash; } - static const uint64_t OFFSET_BASIS = 0xCBF29CE484222325ull; - static const uint64_t PRIME = 0x00000100000001b3ull; + static ETL_CONSTANT uint64_t OFFSET_BASIS = 0xCBF29CE484222325ull; + static ETL_CONSTANT uint64_t PRIME = 0x00000100000001b3ull; }; //*************************************************************************** @@ -133,8 +133,8 @@ namespace etl return hash; } - static const uint64_t OFFSET_BASIS = 0xCBF29CE484222325ull; - static const uint64_t PRIME = 0x00000100000001b3ull; + static ETL_CONSTANT uint64_t OFFSET_BASIS = 0xCBF29CE484222325ull; + static ETL_CONSTANT uint64_t PRIME = 0x00000100000001b3ull; }; //*************************************************************************** @@ -192,8 +192,8 @@ namespace etl return hash; } - static const uint32_t OFFSET_BASIS = 0x811C9DC5; - static const uint32_t PRIME = 0x01000193; + static ETL_CONSTANT uint32_t OFFSET_BASIS = 0x811C9DC5; + static ETL_CONSTANT uint32_t PRIME = 0x01000193; }; //*************************************************************************** @@ -250,8 +250,8 @@ namespace etl return hash; } - static const uint32_t OFFSET_BASIS = 0x811C9DC5; - static const uint32_t PRIME = 0x01000193; + static ETL_CONSTANT uint32_t OFFSET_BASIS = 0x811C9DC5; + static ETL_CONSTANT uint32_t PRIME = 0x01000193; }; //*************************************************************************** diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 6cf66340..83b19a4e 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1621,7 +1621,7 @@ namespace etl ETL_STATIC_ASSERT((MAX_SIZE_ > 0U), "Zero capacity etl::forward_list is not valid"); - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; public: diff --git a/include/etl/generators/smallest_generator.h b/include/etl/generators/smallest_generator.h index 5bd7ef59..5dff3527 100644 --- a/include/etl/generators/smallest_generator.h +++ b/include/etl/generators/smallest_generator.h @@ -320,9 +320,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required number of bits. - static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + - ((NBITS > 16) ? 1 : 0) + - ((NBITS > 32) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + + ((NBITS > 16) ? 1 : 0) + + ((NBITS > 32) ? 1 : 0); public: @@ -346,9 +346,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required number of bits. - static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + - ((NBITS > 16) ? 1 : 0) + - ((NBITS > 32) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + + ((NBITS > 16) ? 1 : 0) + + ((NBITS > 32) ? 1 : 0); public: @@ -372,9 +372,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required value. - static const int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + - ((VALUE > UINT16_MAX) ? 1 : 0) + - ((VALUE > UINT32_MAX) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + + ((VALUE > UINT16_MAX) ? 1 : 0) + + ((VALUE > UINT32_MAX) ? 1 : 0); public: @@ -398,9 +398,9 @@ namespace etl private: // Determines the index of the best signed type for the required value. - static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); public: diff --git a/include/etl/generic_pool.h b/include/etl/generic_pool.h index b8aa9a8a..9979e425 100644 --- a/include/etl/generic_pool.h +++ b/include/etl/generic_pool.h @@ -187,7 +187,7 @@ namespace etl ///< The memory for the pool of objects. typename etl::aligned_storage::value>::type buffer[VSize]; - static const uint32_t Element_Size = sizeof(Element); + static ETL_CONSTANT uint32_t Element_Size = sizeof(Element); // Should not be copied. generic_pool(const generic_pool&); diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 98611db5..4d8efe02 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -1294,7 +1294,7 @@ namespace etl ETL_STATIC_ASSERT((MAX_SIZE_ > 0U), "Zero capacity etl::indirect_vector is not valid"); - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index 7b8d4dd0..bfd54ce3 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -59,10 +59,10 @@ namespace etl template <> struct integral_limits { - static const int min = 0; - static const int max = 0; - static const int bits = 0; - static const bool is_signed = false; + static ETL_CONSTANT int min = 0; + static ETL_CONSTANT int max = 0; + static ETL_CONSTANT int bits = 0; + static ETL_CONSTANT bool is_signed = false; }; //*************************************************************************** @@ -71,10 +71,10 @@ namespace etl template <> struct integral_limits { - static const signed char min = SCHAR_MIN; - static const signed char max = SCHAR_MAX; - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT signed char min = SCHAR_MIN; + static ETL_CONSTANT signed char max = SCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -83,10 +83,10 @@ namespace etl template <> struct integral_limits { - static const unsigned char min = 0; - static const unsigned char max = UCHAR_MAX; - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned char min = 0; + static ETL_CONSTANT unsigned char max = UCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -95,10 +95,10 @@ namespace etl template <> struct integral_limits { - static const char min = (etl::is_signed::value) ? SCHAR_MIN : 0; - static const char max = (etl::is_signed::value) ? SCHAR_MAX : char(UCHAR_MAX); - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : char(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -107,10 +107,10 @@ namespace etl template <> struct integral_limits { - static const short min = SHRT_MIN; - static const short max = SHRT_MAX; - static const int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT short min = SHRT_MIN; + static ETL_CONSTANT short max = SHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -119,10 +119,10 @@ namespace etl template <> struct integral_limits { - static const unsigned short min = 0; - static const unsigned short max = USHRT_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned short min = 0; + static ETL_CONSTANT unsigned short max = USHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -131,10 +131,10 @@ namespace etl template <> struct integral_limits { - static const int min = INT_MIN; - static const int max = INT_MAX; - static const int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT int min = INT_MIN; + static ETL_CONSTANT int max = INT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -143,10 +143,10 @@ namespace etl template <> struct integral_limits { - static const unsigned int min = 0; - static const unsigned int max = UINT_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned int min = 0; + static ETL_CONSTANT unsigned int max = UINT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -155,10 +155,10 @@ namespace etl template <> struct integral_limits { - static const long min = LONG_MIN; - static const long max = LONG_MAX; - static const int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT long min = LONG_MIN; + static ETL_CONSTANT long max = LONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -167,10 +167,10 @@ namespace etl template <> struct integral_limits { - static const unsigned long min = 0; - static const unsigned long max = ULONG_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned long min = 0; + static ETL_CONSTANT unsigned long max = ULONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; #ifndef LLONG_MAX @@ -191,10 +191,10 @@ namespace etl template <> struct integral_limits { - static const long long min = LLONG_MIN; - static const long long max = LLONG_MAX; - static const int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT long long min = LLONG_MIN; + static ETL_CONSTANT long long max = LLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -203,10 +203,10 @@ namespace etl template <> struct integral_limits { - static const unsigned long long min = 0; - static const unsigned long long max = ULLONG_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned long long min = 0; + static ETL_CONSTANT unsigned long long max = ULLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; } diff --git a/include/etl/list.h b/include/etl/list.h index 3185c58d..69c9d3ef 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -2029,7 +2029,7 @@ namespace etl ETL_STATIC_ASSERT((MAX_SIZE_ > 0U), "Zero capacity etl::list is not valid"); - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; public: diff --git a/include/etl/map.h b/include/etl/map.h index 66f4af33..70700fe8 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -2175,7 +2175,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Default constructor. diff --git a/include/etl/multimap.h b/include/etl/multimap.h index e6816491..b904b7ac 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -2037,7 +2037,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Default constructor. diff --git a/include/etl/multiset.h b/include/etl/multiset.h index f81bc172..3e8c4bdd 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -2021,7 +2021,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Default constructor. diff --git a/include/etl/murmur3.h b/include/etl/murmur3.h index 9862d7bf..74894707 100644 --- a/include/etl/murmur3.h +++ b/include/etl/murmur3.h @@ -226,13 +226,13 @@ namespace etl value_type hash; value_type seed; - static const uint8_t FULL_BLOCK = 4; - static const value_type CONSTANT1 = 0xCC9E2D51; - static const value_type CONSTANT2 = 0x1B873593; - static const value_type SHIFT1 = 15; - static const value_type SHIFT2 = 13; - static const value_type MULTIPLY = 5; - static const value_type ADD = 0xE6546B64; + static ETL_CONSTANT uint8_t FULL_BLOCK = 4; + static ETL_CONSTANT value_type CONSTANT1 = 0xCC9E2D51; + static ETL_CONSTANT value_type CONSTANT2 = 0x1B873593; + static ETL_CONSTANT value_type SHIFT1 = 15; + static ETL_CONSTANT value_type SHIFT2 = 13; + static ETL_CONSTANT value_type MULTIPLY = 5; + static ETL_CONSTANT value_type ADD = 0xE6546B64; }; } diff --git a/include/etl/pearson.h b/include/etl/pearson.h index d7379c78..045b7e02 100644 --- a/include/etl/pearson.h +++ b/include/etl/pearson.h @@ -116,7 +116,7 @@ namespace etl //************************************************************************* void add(uint8_t value_) { - static const uint8_t PEARSON_LOOKUP[] = + static ETL_CONSTANT uint8_t PEARSON_LOOKUP[] = { 228, 39, 61, 95, 227, 187, 0, 197, 31, 189, 161, 222, 34, 15, 221, 246, 19, 234, 6, 50, 113, 3, 91, 63, 77, 245, 144, 2, 183, 196, 25, 226, diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 49db2f1c..5c0cd0cb 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -419,7 +419,7 @@ namespace etl typedef typename TContainer::size_type size_type; - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue.h b/include/etl/queue.h index ef2b5c67..4dd12d88 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -588,7 +588,7 @@ namespace etl ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 4b6f1722..0d29b28c 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -601,7 +601,7 @@ namespace etl ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index bf350c2a..1d14226c 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -474,13 +474,13 @@ namespace etl private: - static const size_type RESERVED_SIZE = size_type(SIZE + 1); + static ETL_CONSTANT size_type RESERVED_SIZE = size_type(SIZE + 1); public: ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max - 1)), "Size too large for memory model"); - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index bee8aacf..0eed51ca 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -706,7 +706,7 @@ namespace etl ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index 9e4e6b42..60d4cc54 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -763,7 +763,7 @@ namespace etl ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); - static const size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/random.h b/include/etl/random.h index a2d8cc60..a66890f8 100644 --- a/include/etl/random.h +++ b/include/etl/random.h @@ -218,8 +218,8 @@ namespace etl private: - static const uint32_t a = 40014; - static const uint32_t m = 2147483563; + static ETL_CONSTANT uint32_t a = 40014; + static ETL_CONSTANT uint32_t m = 2147483563; uint32_t value; }; @@ -271,7 +271,7 @@ namespace etl //*************************************************************************** uint32_t operator()() { - static const uint32_t m = ((m1 > m2) ? m1 : m2); + static ETL_CONSTANT uint32_t m = ((m1 > m2) ? m1 : m2); value1 = (a1 * value1) % m1; value2 = (a2 * value2) % m2; @@ -294,11 +294,11 @@ namespace etl private: - static const uint32_t a1 = 40014; - static const uint32_t m1 = 2147483563; + static ETL_CONSTANT uint32_t a1 = 40014; + static ETL_CONSTANT uint32_t m1 = 2147483563; - static const uint32_t a2 = 40692; - static const uint32_t m2 = 2147483399; + static ETL_CONSTANT uint32_t a2 = 40692; + static ETL_CONSTANT uint32_t m2 = 2147483399; uint32_t value1; uint32_t value2; @@ -350,7 +350,7 @@ namespace etl //*************************************************************************** uint32_t operator()() { - static const uint32_t polynomial = 0x80200003; + static ETL_CONSTANT uint32_t polynomial = 0x80200003; value >>= 1; @@ -514,8 +514,8 @@ namespace etl private: - static const uint64_t multiplier = 6364136223846793005ULL; - static const uint64_t increment = 1ULL; + static ETL_CONSTANT uint64_t multiplier = 6364136223846793005ULL; + static ETL_CONSTANT uint64_t increment = 1ULL; uint64_t value; }; diff --git a/include/etl/reference_counted_message_pool.h b/include/etl/reference_counted_message_pool.h index ce612c8a..ca17cc9a 100644 --- a/include/etl/reference_counted_message_pool.h +++ b/include/etl/reference_counted_message_pool.h @@ -223,7 +223,7 @@ namespace etl ETL_STATIC_ASSERT((etl::is_base_of::value), "TMessage7 not derived from etl::imessage"); ETL_STATIC_ASSERT((etl::is_base_of::value), "TMessage8 not derived from etl::imessage"); - static const size_t max_size = etl::largest, + static ETL_CONSTANT size_t max_size = etl::largest, etl::reference_counted_message, etl::reference_counted_message, etl::reference_counted_message, @@ -233,7 +233,7 @@ namespace etl etl::reference_counted_message >::size; - static const size_t max_alignment = etl::largest, + static ETL_CONSTANT size_t max_alignment = etl::largest, etl::reference_counted_message, etl::reference_counted_message, etl::reference_counted_message, diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 21845dc3..51d9418b 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -923,7 +923,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 613c6bee..250e38ce 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -826,7 +826,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index ef5416b2..2077d4bb 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -807,7 +807,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 5896807d..c99e919e 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -791,7 +791,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/set.h b/include/etl/set.h index 4166c5e5..1fcd0f2c 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -2101,7 +2101,7 @@ namespace etl { public: - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Default constructor. diff --git a/include/etl/smallest.h b/include/etl/smallest.h index fbd953f7..5a694c42 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -290,9 +290,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required number of bits. - static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + - ((NBITS > 16) ? 1 : 0) + - ((NBITS > 32) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + + ((NBITS > 16) ? 1 : 0) + + ((NBITS > 32) ? 1 : 0); public: @@ -316,9 +316,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required number of bits. - static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + - ((NBITS > 16) ? 1 : 0) + - ((NBITS > 32) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + + ((NBITS > 16) ? 1 : 0) + + ((NBITS > 32) ? 1 : 0); public: @@ -342,9 +342,9 @@ namespace etl private: // Determines the index of the best unsigned type for the required value. - static const int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + - ((VALUE > UINT16_MAX) ? 1 : 0) + - ((VALUE > UINT32_MAX) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + + ((VALUE > UINT16_MAX) ? 1 : 0) + + ((VALUE > UINT32_MAX) ? 1 : 0); public: @@ -368,9 +368,9 @@ namespace etl private: // Determines the index of the best signed type for the required value. - static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); + static ETL_CONSTANT int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); public: diff --git a/include/etl/stack.h b/include/etl/stack.h index 2437494b..0b2324f3 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -529,7 +529,7 @@ namespace etl { public: - static const size_t MAX_SIZE = SIZE; + static ETL_CONSTANT size_t MAX_SIZE = SIZE; //************************************************************************* /// Default constructor. diff --git a/include/etl/string.h b/include/etl/string.h index bbdc13ca..85d892b2 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -63,7 +63,7 @@ namespace etl typedef istring::value_type value_type; - static const size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; //************************************************************************* /// Constructor. diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 35ced3bc..72200677 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -1540,8 +1540,8 @@ namespace etl public: - static const size_t MAX_SIZE = MAX_SIZE_; - static const size_t MAX_BUCKETS = MAX_BUCKETS_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_BUCKETS = MAX_BUCKETS_; //************************************************************************* /// Default constructor. diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 4854d56e..c53f1830 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -1446,8 +1446,8 @@ namespace etl public: - static const size_t MAX_SIZE = MAX_SIZE_; - static const size_t MAX_BUCKETS = MAX_BUCKETS_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_BUCKETS = MAX_BUCKETS_; //************************************************************************* /// Default constructor. diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index fcf7551f..a269edb1 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -1430,8 +1430,8 @@ namespace etl public: - static const size_t MAX_SIZE = MAX_SIZE_; - static const size_t MAX_BUCKETS = MAX_BUCKETS_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_BUCKETS = MAX_BUCKETS_; //************************************************************************* diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 1552d067..42aed2ad 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -1430,8 +1430,8 @@ namespace etl public: - static const size_t MAX_SIZE = MAX_SIZE_; - static const size_t MAX_BUCKETS = MAX_BUCKETS_; + static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_; + static ETL_CONSTANT size_t MAX_BUCKETS = MAX_BUCKETS_; //************************************************************************* /// Default constructor. From 04ca8335437c6dcfb92b7a3acb8b4ae97cf85b24 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 26 Mar 2021 17:32:27 +0000 Subject: [PATCH 4/4] Updated version numbers --- include/etl/version.h | 4 ++-- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index c54d8e7d..584b7aa0 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 6 -#define ETL_VERSION_PATCH 3 +#define ETL_VERSION_MINOR 7 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 3b326c55..5394e988 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.6.3", + "version": "20.7.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 973873e5..84b74663 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.6.3 +version=20.7.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 35e513b1..80328088 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,10 @@ +=============================================================================== +20.7.0 +Added etl::selection_sort. +etl::delegate accepts moveable parameters. +Fixed the return type of const iterators for containers from const_iterator to iterator. +Changed many instances of 'static const' to 'static ETL_CONSTANT'. + =============================================================================== 20.6.3 Updates to unit test CMake files.