From 6c4f111e9c6e81e80b2bde6751f23df8155de7cd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 11 Apr 2023 16:32:30 +0100 Subject: [PATCH 1/6] static member constants --- include/etl/private/choose_namespace.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/etl/private/choose_namespace.h b/include/etl/private/choose_namespace.h index 44b0c440..494d030f 100644 --- a/include/etl/private/choose_namespace.h +++ b/include/etl/private/choose_namespace.h @@ -33,6 +33,7 @@ SOFTWARE. #undef ETL_OR_STD #undef ETL_OR_STD11 +#undef ETL_OR_STD14 #if ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST) // If we're not using the STL and we are not unit testing, then use the ETL's definitions under the etl namespace @@ -58,4 +59,28 @@ SOFTWARE. #define ETL_USING_ETL11_NAMESPACE 0 #endif +#if (ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST)) || ETL_CPP14_NOT_SUPPORTED + // If we're not using the STL and we are not unit testing or C++14 is not supported, then use the ETL's definitions under the etl namespace + #define ETL_OR_STD14 etl + #define ETL_USING_STD14_NAMESPACE 0 + #define ETL_USING_ETL14_NAMESPACE 1 +#else + // We will use the STL's definitions under the std namespace + #define ETL_OR_STD14 std + #define ETL_USING_STD14_NAMESPACE 1 + #define ETL_USING_ETL14_NAMESPACE 0 +#endif + +#if (ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST)) || ETL_CPP17_NOT_SUPPORTED + // If we're not using the STL and we are not unit testing or C++17 is not supported, then use the ETL's definitions under the etl namespace + #define ETL_OR_STD17 etl + #define ETL_USING_STD17_NAMESPACE 0 + #define ETL_USING_ETL17_NAMESPACE 1 +#else + // We will use the STL's definitions under the std namespace + #define ETL_OR_STD17 std + #define ETL_USING_STD17_NAMESPACE 1 + #define ETL_USING_ETL17_NAMESPACE 0 +#endif + #endif From b609548f389eea67c0423186b7e64cca8b9a8a60 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 23 Apr 2023 18:58:30 +0100 Subject: [PATCH 2/6] Added ETL_OR_STD17 macro for the namespace for size() --- test/test_algorithm.cpp | 4 +- test/test_byte_stream.cpp | 10 +-- test/test_char_traits.cpp | 80 ++++++++++---------- test/test_circular_iterator.cpp | 12 +-- test/test_container.cpp | 4 +- test/test_fsm.cpp | 6 +- test/test_hfsm.cpp | 16 ++-- test/test_integral_limits.cpp | 2 +- test/test_murmur3.cpp | 6 +- test/test_poly_span_dynamic_extent.cpp | 16 ++-- test/test_poly_span_fixed_extent.cpp | 16 ++-- test/test_smallest.cpp | 3 +- test/test_span_dynamic_extent.cpp | 22 +++--- test/test_span_fixed_extent.cpp | 22 +++--- test/test_string_char_external_buffer.cpp | 12 +-- test/test_string_u16_external_buffer.cpp | 12 +-- test/test_string_u32_external_buffer.cpp | 12 +-- test/test_string_wchar_t_external_buffer.cpp | 12 +-- test/test_task_scheduler.cpp | 10 +-- 19 files changed, 139 insertions(+), 138 deletions(-) diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index d68e6b48..8828cb96 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -1601,7 +1601,7 @@ namespace etl::transform_s(std::begin(input), std::end(input), std::begin(output), - std::begin(output) + (ETL_OR_STD::size(output) / 2), + std::begin(output) + (ETL_OR_STD17::size(output) / 2), std::bind(std::multiplies(), std::placeholders::_1, 2)); bool is_same = std::equal(std::begin(output), std::end(output), std::begin(compare)); @@ -1610,7 +1610,7 @@ namespace std::fill(std::begin(output), std::end(output), 0); etl::transform_s(std::begin(input), - std::begin(input) + (ETL_OR_STD::size(input) / 2), + std::begin(input) + (ETL_OR_STD17::size(input) / 2), std::begin(output), std::end(output), std::bind(std::multiplies(), std::placeholders::_1, 2)); diff --git a/test/test_byte_stream.cpp b/test/test_byte_stream.cpp index 3f8e8296..2587719c 100644 --- a/test/test_byte_stream.cpp +++ b/test/test_byte_stream.cpp @@ -109,7 +109,7 @@ namespace { char storage[7]; - etl::byte_stream_writer writer(storage, ETL_OR_STD::size(storage), etl::endian::big); + etl::byte_stream_writer writer(storage, ETL_OR_STD17::size(storage), etl::endian::big); etl::byte_stream_reader reader(storage, writer.size_bytes(), etl::endian::big); // Capacity is zero. CHECK(writer.empty()); @@ -120,7 +120,7 @@ namespace CHECK_EQUAL(0U, writer.size_bytes()); CHECK_EQUAL(0U, reader.size_bytes()); - CHECK_EQUAL(ETL_OR_STD::size(storage), writer.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(storage), writer.capacity()); CHECK_EQUAL(0U, reader.available()); @@ -136,9 +136,9 @@ namespace { char storage[8]; - etl::byte_stream_writer writer(storage, ETL_OR_STD::size(storage), etl::endian::big); + etl::byte_stream_writer writer(storage, ETL_OR_STD17::size(storage), etl::endian::big); - etl::span storage_span(storage, storage + ETL_OR_STD::size(storage)); + etl::span storage_span(storage, storage + ETL_OR_STD17::size(storage)); etl::span writer_span = writer.data(); CHECK(writer_span.begin() == storage_span.begin()); CHECK(writer_span.end() == storage_span.end()); @@ -150,7 +150,7 @@ namespace etl::span free_span = writer.free_data(); CHECK_EQUAL(sizeof(uint8_t) + sizeof(uint16_t), (std::distance(used_span.begin(), used_span.end()))); - CHECK_EQUAL(ETL_OR_STD::size(storage) - sizeof(uint8_t) - sizeof(uint16_t), (std::distance(free_span.begin(), free_span.end()))); + CHECK_EQUAL(ETL_OR_STD17::size(storage) - sizeof(uint8_t) - sizeof(uint16_t), (std::distance(free_span.begin(), free_span.end()))); CHECK(writer.write(uint32_t(0x12345678U))); // 4 more written. CHECK_FALSE(writer.write(uint32_t(0x12345678U))); // Can't write 4 more. diff --git a/test/test_char_traits.cpp b/test/test_char_traits.cpp index 1963c767..483faa56 100644 --- a/test/test_char_traits.cpp +++ b/test/test_char_traits.cpp @@ -74,7 +74,7 @@ namespace char_type r = 'A'; char_type c = 'B'; char_type src[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - char_type dst[ETL_OR_STD::size(src)]; + char_type dst[ETL_OR_STD17::size(src)]; char_type filled[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; const char_type* p_src; char_type* p_dst; @@ -96,18 +96,18 @@ namespace CHECK_EQUAL(-1, char_traits::compare("ABCDEE", "ABCDEF", 6U)); CHECK_EQUAL(1, char_traits::compare("ABCDEF", "ABCDEE", 6U)); - p_dst = char_traits::assign(dst, ETL_OR_STD::size(dst), 9); - CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD::size(filled)); + p_dst = char_traits::assign(dst, ETL_OR_STD17::size(dst), 9); + CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD17::size(filled)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::copy(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::copy(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::move(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::move(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - p_src = char_traits::find(src, ETL_OR_STD::size(src), 4); + p_src = char_traits::find(src, ETL_OR_STD17::size(src), 4); CHECK_EQUAL(src[4], *p_src); CHECK_EQUAL(127, char_traits::to_char_type(int_type(127))); @@ -130,7 +130,7 @@ namespace char_type r = L'A'; char_type c = L'B'; char_type src[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - char_type dst[ETL_OR_STD::size(src)]; + char_type dst[ETL_OR_STD17::size(src)]; char_type filled[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; const char_type* p_src; char_type* p_dst; @@ -152,18 +152,18 @@ namespace CHECK_EQUAL(-1, char_traits::compare(L"ABCDEE", L"ABCDEF", 6U)); CHECK_EQUAL(1, char_traits::compare(L"ABCDEF", L"ABCDEE", 6U)); - p_dst = char_traits::assign(dst, ETL_OR_STD::size(dst), 9); - CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD::size(filled)); + p_dst = char_traits::assign(dst, ETL_OR_STD17::size(dst), 9); + CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD17::size(filled)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::copy(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::copy(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::move(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::move(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - p_src = char_traits::find(src, ETL_OR_STD::size(src), 4); + p_src = char_traits::find(src, ETL_OR_STD17::size(src), 4); CHECK_EQUAL(src[4], *p_src); CHECK_TRUE(127 == char_traits::to_char_type(int_type(127))); @@ -186,7 +186,7 @@ namespace char_type r = u'A'; char_type c = u'B'; char_type src[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - char_type dst[ETL_OR_STD::size(src)]; + char_type dst[ETL_OR_STD17::size(src)]; char_type filled[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; const char_type* p_src; char_type* p_dst; @@ -208,18 +208,18 @@ namespace CHECK_EQUAL(-1, char_traits::compare(u"ABCDEE", u"ABCDEF", 6U)); CHECK_EQUAL(1, char_traits::compare(u"ABCDEF", u"ABCDEE", 6U)); - p_dst = char_traits::assign(dst, ETL_OR_STD::size(dst), 9); - CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD::size(filled)); + p_dst = char_traits::assign(dst, ETL_OR_STD17::size(dst), 9); + CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD17::size(filled)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::copy(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::copy(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::move(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::move(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - p_src = char_traits::find(src, ETL_OR_STD::size(src), 4); + p_src = char_traits::find(src, ETL_OR_STD17::size(src), 4); CHECK_EQUAL(src[4], *p_src); CHECK_EQUAL(127, char_type(127)); @@ -241,7 +241,7 @@ namespace char_type r = U'A'; char_type c = U'B'; char_type src[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - char_type dst[ETL_OR_STD::size(src)]; + char_type dst[ETL_OR_STD17::size(src)]; char_type filled[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; const char_type* p_src; char_type* p_dst; @@ -263,18 +263,18 @@ namespace CHECK_EQUAL(-1, char_traits::compare(U"ABCDEE", U"ABCDEF", 6U)); CHECK_EQUAL(1, char_traits::compare(U"ABCDEF", U"ABCDEE", 6U)); - p_dst = char_traits::assign(dst, ETL_OR_STD::size(dst), 9); - CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD::size(filled)); + p_dst = char_traits::assign(dst, ETL_OR_STD17::size(dst), 9); + CHECK_ARRAY_EQUAL(filled, p_dst, ETL_OR_STD17::size(filled)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::copy(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::copy(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - std::fill_n(dst, ETL_OR_STD::size(dst), 0); - p_dst = char_traits::move(dst, src, ETL_OR_STD::size(src)); - CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD::size(src)); + std::fill_n(dst, ETL_OR_STD17::size(dst), 0); + p_dst = char_traits::move(dst, src, ETL_OR_STD17::size(src)); + CHECK_ARRAY_EQUAL(src, p_dst, ETL_OR_STD17::size(src)); - p_src = char_traits::find(src, ETL_OR_STD::size(src), 4); + p_src = char_traits::find(src, ETL_OR_STD17::size(src), 4); CHECK_EQUAL(src[4], *p_src); CHECK_EQUAL(127, char_traits::to_int_type(char_type(127))); diff --git a/test/test_circular_iterator.cpp b/test/test_circular_iterator.cpp index 2888d3a9..fdfd64d4 100644 --- a/test/test_circular_iterator.cpp +++ b/test/test_circular_iterator.cpp @@ -63,8 +63,8 @@ namespace CHECK(std::begin(data) == ci.begin()); CHECK(std::end(data) == ci.end()); CHECK(std::begin(data) == ci.current()); - CHECK_EQUAL(ETL_OR_STD::size(data), size_t(std::distance(ci.begin(), ci.end()))); - CHECK_EQUAL(ETL_OR_STD::size(data), ci.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), size_t(std::distance(ci.begin(), ci.end()))); + CHECK_EQUAL(ETL_OR_STD17::size(data), ci.size()); } //************************************************************************* @@ -80,8 +80,8 @@ namespace CHECK(std::begin(data) == ci.begin()); CHECK(std::end(data) == ci.end()); CHECK(start == ci.current()); - CHECK_EQUAL(ETL_OR_STD::size(data), size_t(std::distance(ci.begin(), ci.end()))); - CHECK_EQUAL(ETL_OR_STD::size(data), ci.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), size_t(std::distance(ci.begin(), ci.end()))); + CHECK_EQUAL(ETL_OR_STD17::size(data), ci.size()); } //************************************************************************* @@ -645,7 +645,7 @@ namespace for (int i = 0; i < 20; i += step) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(data)], *ci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(data)], *ci); ci -= step; } } @@ -663,7 +663,7 @@ namespace for (int i = 0; i < 20; i += step) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(data)], *ci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(data)], *ci); ci = ci - step; } } diff --git a/test/test_container.cpp b/test/test_container.cpp index bb28bb8c..d576879a 100644 --- a/test/test_container.cpp +++ b/test/test_container.cpp @@ -129,7 +129,7 @@ namespace const size_t SIZE = 10UL; std::list data(SIZE); - size_t runtime_size = ETL_OR_STD::size(data); + size_t runtime_size = ETL_OR_STD17::size(data); CHECK_EQUAL(SIZE, runtime_size); } @@ -139,7 +139,7 @@ namespace const size_t SIZE = 10UL; int data[SIZE]; - size_t runtime_size = ETL_OR_STD::size(data); + size_t runtime_size = ETL_OR_STD17::size(data); CHECK_EQUAL(SIZE, runtime_size); size_t compiletime_size = sizeof(etl::array_size(data)); diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index a057a055..848d9632 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -341,7 +341,7 @@ namespace CHECK(motorControl.is_producer()); CHECK(motorControl.is_consumer()); - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -480,7 +480,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -529,7 +529,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); diff --git a/test/test_hfsm.cpp b/test/test_hfsm.cpp index d7361c08..584c3f48 100644 --- a/test/test_hfsm.cpp +++ b/test/test_hfsm.cpp @@ -474,9 +474,9 @@ namespace CHECK(motorControl.is_producer()); CHECK(motorControl.is_consumer()); - running.set_child_states(childStates, ETL_OR_STD::size(childStates)); + running.set_child_states(childStates, ETL_OR_STD17::size(childStates)); - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -647,7 +647,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -700,7 +700,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -754,7 +754,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -809,7 +809,7 @@ namespace { etl::null_message_router nmr; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -902,7 +902,7 @@ namespace { MotorControl mc; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); @@ -941,7 +941,7 @@ namespace { MotorControl mc; - motorControl.Initialise(stateList, ETL_OR_STD::size(stateList)); + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); motorControl.reset(); motorControl.ClearStatistics(); diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index 0c97e940..9fcba6d8 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -41,7 +41,7 @@ namespace //************************************************************************* TEST(test_min) { - CHECK_EQUAL(std::numeric_limits::min(), (char)etl::integral_limits::min); + CHECK_EQUAL(std::numeric_limits::min(), etl::integral_limits::min); CHECK_EQUAL(std::numeric_limits::min(), (signed char)etl::integral_limits::min); CHECK_EQUAL(std::numeric_limits::min(), (unsigned char)etl::integral_limits::min); CHECK_EQUAL(std::numeric_limits::min(), (short)etl::integral_limits::min); diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index e5217d5a..23c1b469 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -44,7 +44,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_constructor) { - std::aligned_storage_t> storage[10]; + std::aligned_storage_t::value> storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -61,7 +61,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_values) { - std::aligned_storage_t> storage[10]; + std::aligned_storage_t::value> storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -85,7 +85,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_range) { - std::aligned_storage_t> storage[10]; + std::aligned_storage_t::value> storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; diff --git a/test/test_poly_span_dynamic_extent.cpp b/test/test_poly_span_dynamic_extent.cpp index 2378f564..b617ec2b 100644 --- a/test/test_poly_span_dynamic_extent.cpp +++ b/test/test_poly_span_dynamic_extent.cpp @@ -158,7 +158,7 @@ namespace etl::poly_span s(data); CHECK_EQUAL(sizeof(Derived), s.size_of_element()); CHECK(!s.empty()); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK_EQUAL(s.size() * sizeof(Derived), s.size_bytes()); CHECK_EQUAL(data[0].value(), s[0].value()); CHECK_EQUAL(data[1].value(), s[1].value()); @@ -173,7 +173,7 @@ namespace etl::poly_span s(data); CHECK_EQUAL(sizeof(Derived), s.size_of_element()); CHECK(!s.empty()); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK_EQUAL(s.size() * sizeof(Derived), s.size_bytes()); CHECK_EQUAL(data[0].value(), s[0].value()); CHECK_EQUAL(data[1].value(), s[1].value()); @@ -491,8 +491,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -504,8 +504,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } #endif @@ -517,8 +517,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } diff --git a/test/test_poly_span_fixed_extent.cpp b/test/test_poly_span_fixed_extent.cpp index 3c51ddb3..b6cb5976 100644 --- a/test/test_poly_span_fixed_extent.cpp +++ b/test/test_poly_span_fixed_extent.cpp @@ -158,7 +158,7 @@ namespace etl::poly_span s(data); CHECK_EQUAL(sizeof(Derived), s.size_of_element()); CHECK(!s.empty()); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK_EQUAL(s.size() * sizeof(Derived), s.size_bytes()); CHECK_EQUAL(data[0].value(), s[0].value()); CHECK_EQUAL(data[1].value(), s[1].value()); @@ -173,7 +173,7 @@ namespace etl::poly_span s(data); CHECK_EQUAL(sizeof(Derived), s.size_of_element()); CHECK(!s.empty()); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK_EQUAL(s.size() * sizeof(Derived), s.size_bytes()); CHECK_EQUAL(data[0].value(), s[0].value()); CHECK_EQUAL(data[1].value(), s[1].value()); @@ -510,8 +510,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -523,8 +523,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } #endif @@ -536,8 +536,8 @@ namespace etl::poly_span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } diff --git a/test/test_smallest.cpp b/test/test_smallest.cpp index 6b38aae9..e7aaa290 100644 --- a/test/test_smallest.cpp +++ b/test/test_smallest.cpp @@ -102,7 +102,6 @@ namespace //************************************************************************* TEST(test_non_pod_vt) { - size_t size; bool type; struct S1 { char a; char b; char c; }; @@ -110,6 +109,8 @@ namespace struct S3 { int a; short b; char c; }; #if ETL_USING_CPP17 + size_t size; + size = etl::smallest_type_v; CHECK_EQUAL(sizeof(S1), size); #endif diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index 48fc6566..f958bd1e 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -638,8 +638,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -651,8 +651,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } #endif @@ -664,8 +664,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -805,7 +805,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } @@ -838,7 +838,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *++sci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *++sci); } } @@ -855,7 +855,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *++sci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *++sci); } } @@ -871,7 +871,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } @@ -888,7 +888,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } diff --git a/test/test_span_fixed_extent.cpp b/test/test_span_fixed_extent.cpp index 185f85af..1c650ce7 100644 --- a/test/test_span_fixed_extent.cpp +++ b/test/test_span_fixed_extent.cpp @@ -628,8 +628,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -641,8 +641,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } #endif @@ -654,8 +654,8 @@ namespace etl::span s = data; - CHECK_EQUAL(ETL_OR_STD::size(data), s.extent); - CHECK_EQUAL(ETL_OR_STD::size(data), s.size()); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.extent); + CHECK_EQUAL(ETL_OR_STD17::size(data), s.size()); CHECK((std::is_same_v>)); } @@ -795,7 +795,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } @@ -828,7 +828,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *++sci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *++sci); } } @@ -845,7 +845,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *++sci); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *++sci); } } @@ -861,7 +861,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } @@ -878,7 +878,7 @@ namespace for (int i = 0; i < 20; ++i) { - CHECK_EQUAL(expected[i % ETL_OR_STD::size(expected)], *sci++); + CHECK_EQUAL(expected[i % ETL_OR_STD17::size(expected)], *sci++); } } diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index ec49a3de..0ae93d4a 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -152,12 +152,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) { - Text text(array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(0U, text.size()); CHECK(text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() == text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -167,12 +167,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) { - Text text(array_text, array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(text.size(), etl::strlen(array_text)); CHECK(!text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() != text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index b013f52c..f73d7f4f 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -167,12 +167,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) { - Text text(array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(0U, text.size()); CHECK(text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() == text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -182,12 +182,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) { - Text text(array_text, array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(text.size(), etl::strlen(array_text)); CHECK(!text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() != text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index 133f2231..7ab8d612 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -167,12 +167,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) { - Text text(array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(0U, text.size()); CHECK(text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() == text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -182,12 +182,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) { - Text text(array_text, array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(text.size(), etl::strlen(array_text)); CHECK(!text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() != text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index 7c092548..cd694a84 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -168,12 +168,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) { - Text text(array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(0U, text.size()); CHECK(text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() == text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -183,12 +183,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) { - Text text(array_text, array_text, ETL_OR_STD::size(array_text)); + Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); CHECK_EQUAL(text.size(), etl::strlen(array_text)); CHECK(!text.empty()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.capacity()); - CHECK_EQUAL(ETL_OR_STD::size(array_text) - 1, text.max_size()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); CHECK(text.begin() != text.end()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); diff --git a/test/test_task_scheduler.cpp b/test/test_task_scheduler.cpp index 76350e9b..5d33f669 100644 --- a/test/test_task_scheduler.cpp +++ b/test/test_task_scheduler.cpp @@ -181,7 +181,7 @@ namespace common.Clear(); - s.add_task_list(taskList, ETL_OR_STD::size(taskList)); + s.add_task_list(taskList, ETL_OR_STD17::size(taskList)); CHECK(task1.task_added); CHECK(task2.task_added); @@ -204,7 +204,7 @@ namespace s.set_idle_callback(common.idle_callback); s.set_watchdog_callback(common.watchdog_callback); - s.add_task_list(taskList, ETL_OR_STD::size(taskList)); + s.add_task_list(taskList, ETL_OR_STD17::size(taskList)); s.start(); // If 'start' returns then the idle callback was successfully called. WorkList_t expected = { "T3W1", "T2W1", "T1W1", "T3W2", "T2W2", "T1W2", "T3W3", "T2W3", "T1W3", "T2W4" }; @@ -229,7 +229,7 @@ namespace s.set_idle_callback(common.idle_callback); s.set_watchdog_callback(common.watchdog_callback); - s.add_task_list(taskList, ETL_OR_STD::size(taskList)); + s.add_task_list(taskList, ETL_OR_STD17::size(taskList)); s.start(); // If 'start' returns then the idle callback was successfully called. WorkList_t expected = { "T3W1", "T3W2", "T2W1", "T2W2", "T2W3", "T2W4", "T1W1", "T1W2", "T1W3", "T3W3" }; @@ -254,7 +254,7 @@ namespace s.set_idle_callback(common.idle_callback); s.set_watchdog_callback(common.watchdog_callback); - s.add_task_list(taskList, ETL_OR_STD::size(taskList)); + s.add_task_list(taskList, ETL_OR_STD17::size(taskList)); s.start(); // If 'start' returns then the idle callback was successfully called. WorkList_t expected = { "T3W1", "T3W2", "T2W1", "T2W2", "T3W3", "T2W3", "T2W4", "T1W1", "T1W2", "T1W3" }; @@ -279,7 +279,7 @@ namespace s.set_idle_callback(common.idle_callback); s.set_watchdog_callback(common.watchdog_callback); - s.add_task_list(taskList, ETL_OR_STD::size(taskList)); + s.add_task_list(taskList, ETL_OR_STD17::size(taskList)); s.start(); // If 'start' returns then the idle callback was successfully called. WorkList_t expected = { "T2W1", "T2W2", "T1W1", "T3W1", "T2W3", "T3W2", "T1W2", "T3W3", "T2W4", "T1W3" }; From 730be1b39d734c058797d0ca4c3fb04dced91700 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 23 Apr 2023 18:59:41 +0100 Subject: [PATCH 3/6] Added ETL_OR_STD17 macro as the namespace for size() Added definitions for all public statics --- include/etl/basic_string.h | 25 +- include/etl/binary.h | 34 +- include/etl/bip_buffer_spsc_atomic.h | 5 +- include/etl/buffer_descriptors.h | 9 + include/etl/circular_buffer.h | 3 + include/etl/combinations.h | 3 + include/etl/correlation.h | 23 +- include/etl/covariance.h | 23 +- include/etl/deque.h | 3 + include/etl/factorial.h | 3 + include/etl/fibonacci.h | 3 + .../etl/fixed_sized_memory_block_allocator.h | 9 + include/etl/flags.h | 9 + include/etl/flat_map.h | 3 + include/etl/flat_multimap.h | 5 +- include/etl/flat_multiset.h | 3 + include/etl/flat_set.h | 3 + include/etl/forward_list.h | 3 + include/etl/fsm.h | 15 +- include/etl/generators/fsm_generator.h | 24 +- include/etl/generators/smallest_generator.h | 12 + include/etl/generic_pool.h | 15 + include/etl/hfsm.h | 8 + include/etl/histogram.h | 6 + include/etl/indirect_vector.h | 3 + include/etl/integral_limits.h | 85 ++++- include/etl/iterator.h | 39 ++ include/etl/limits.h | 356 ++++++++++++++---- include/etl/list.h | 3 + include/etl/map.h | 3 + include/etl/math_constants.h | 60 ++- include/etl/mem_cast.h | 6 + include/etl/memory.h | 18 + include/etl/multimap.h | 3 + include/etl/multiset.h | 3 + include/etl/permutations.h | 6 + include/etl/poly_span.h | 6 + include/etl/power.h | 9 + include/etl/priority_queue.h | 3 + include/etl/private/bitset_legacy.h | 12 + include/etl/private/bitset_new.h | 137 ++++++- include/etl/private/crc_implementation.h | 30 ++ include/etl/private/crc_parameters.h | 15 + include/etl/pseudo_moving_average.h | 33 +- include/etl/queue.h | 3 + include/etl/queue_lockable.h | 6 + include/etl/queue_mpmc_mutex.h | 3 + include/etl/queue_spsc_atomic.h | 3 + include/etl/queue_spsc_isr.h | 3 + include/etl/queue_spsc_locked.h | 3 + include/etl/ratio.h | 6 + include/etl/reference_counted_message_pool.h | 26 ++ include/etl/reference_flat_map.h | 3 + include/etl/reference_flat_multimap.h | 3 + include/etl/reference_flat_multiset.h | 3 + include/etl/reference_flat_set.h | 3 + include/etl/set.h | 3 + include/etl/smallest.h | 14 +- include/etl/span.h | 3 + include/etl/stack.h | 3 + include/etl/standard_deviation.h | 20 +- include/etl/string.h | 3 + include/etl/to_arithmetic.h | 55 ++- include/etl/type_lookup.h | 4 +- include/etl/type_traits.h | 14 + include/etl/variance.h | 26 +- 66 files changed, 1130 insertions(+), 159 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 44892033..f26e7ee7 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -136,7 +136,27 @@ namespace etl ///\ingroup string /// The base class for all templated string types. //*************************************************************************** - class string_base + namespace private_basic_string + { + //************************************************************************* + template + class string_base_statics + { + public: + + 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; + }; + + template + ETL_CONSTANT uint_least8_t string_base_statics::IS_TRUNCATED; + + template + ETL_CONSTANT uint_least8_t string_base_statics::CLEAR_AFTER_USE; + } + + //*************************************************************************** + class string_base : public private_basic_string::string_base_statics<> { public: @@ -290,9 +310,6 @@ namespace etl { } - 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 5d5a6128..ad478015 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -96,8 +96,8 @@ namespace etl template <> struct max_value_for_nbits<0> { - typedef etl::smallest_uint_for_bits<0>::type value_type; - static ETL_CONSTANT value_type value = 0; + typedef etl::smallest_uint_for_bits<0>::type value_type; + static ETL_CONSTANT value_type value = 0; }; template @@ -544,6 +544,9 @@ namespace etl static ETL_CONSTANT uint8_t value = uint8_t((value2 >> 4U) | ((value2 & 0x0FU) << 4U)); }; + template + ETL_CONSTANT uint8_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -557,6 +560,9 @@ namespace etl static ETL_CONSTANT int8_t value = int8_t((value2 >> 4U) | ((value2 & 0x0FU) << 4U)); }; + + template + ETL_CONSTANT int8_t reverse_bits_const::value; #endif //*************************************************************************** @@ -591,6 +597,9 @@ namespace etl static ETL_CONSTANT uint16_t value = uint16_t((value3 >> 8U) | ((value3 & 0xFFU) << 8U)); }; + template + ETL_CONSTANT uint16_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -606,6 +615,9 @@ namespace etl static ETL_CONSTANT int16_t value = int16_t((value3 >> 8U) | ((value3 & 0xFFU) << 8U)); }; + template + ETL_CONSTANT int16_t reverse_bits_const::value; + //*************************************************************************** /// Reverse 32 bits. ///\ingroup binary @@ -640,6 +652,9 @@ namespace etl static ETL_CONSTANT uint32_t value = uint32_t((value4 >> 16U) | ((value4 & 0xFFFFU) << 16U)); }; + template + ETL_CONSTANT uint32_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -656,6 +671,9 @@ namespace etl static ETL_CONSTANT int32_t value = int32_t((value4 >> 16U) | ((value4 & 0xFFFFUL) << 16U)); }; + template + ETL_CONSTANT int32_t reverse_bits_const::value; + #if ETL_USING_64BIT_TYPES //*************************************************************************** /// Reverse 64 bits. @@ -693,6 +711,9 @@ namespace etl static ETL_CONSTANT uint64_t value = uint64_t((value5 >> 32U) | ((value5 & 0xFFFFFFFFULL) << 32U)); }; + template + ETL_CONSTANT uint64_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -709,6 +730,9 @@ namespace etl static ETL_CONSTANT int64_t value = int64_t((value5 >> 32U) | ((value5 & 0xFFFFFFFFULL) << 32U)); }; + + template + ETL_CONSTANT int64_t reverse_bits_const::value; #endif //*************************************************************************** @@ -2190,6 +2214,9 @@ namespace etl static ETL_CONSTANT T value = static_cast(etl::max_value_for_nbits::value); }; + template + ETL_CONSTANT T lsb_mask::value; + //*********************************** template ETL_CONSTEXPR14 T make_lsb_mask(size_t nbits) @@ -2209,6 +2236,9 @@ namespace etl static ETL_CONSTANT T value = static_cast(etl::reverse_bits_const::value>::value); }; + template + ETL_CONSTANT T msb_mask::value; + //*********************************** template ETL_CONSTEXPR T make_msb_mask(size_t nbits) diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 6b67ae4b..51d54612 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -526,11 +526,14 @@ namespace etl base_t::clear(); } - private: + private: /// The uninitialised buffer of T used in the bip_buffer_spsc. etl::uninitialized_buffer_of buffer; }; + + template + ETL_CONSTANT typename bip_buffer_spsc_atomic::size_type bip_buffer_spsc_atomic::RESERVED_SIZE; } #endif /* ETL_HAS_ATOMIC && ETL_USING_CPP11 */ diff --git a/include/etl/buffer_descriptors.h b/include/etl/buffer_descriptors.h index 1bd98443..b34e223b 100644 --- a/include/etl/buffer_descriptors.h +++ b/include/etl/buffer_descriptors.h @@ -290,6 +290,15 @@ namespace etl etl::array descriptor_items; etl::cyclic_value next; }; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::N_BUFFERS; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::BUFFER_SIZE; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::descriptor::MAX_SIZE; } #endif #endif diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index fec89f30..24a87865 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -1226,6 +1226,9 @@ namespace etl etl::uninitialized_buffer_of buffer; }; + template + ETL_CONSTANT typename icircular_buffer::size_type circular_buffer::MAX_SIZE; + //*************************************************************************** /// A fixed capacity circular buffer. /// External buffer. diff --git a/include/etl/combinations.h b/include/etl/combinations.h index 9fbb8654..dbb5c224 100644 --- a/include/etl/combinations.h +++ b/include/etl/combinations.h @@ -51,6 +51,9 @@ namespace etl static ETL_CONSTANT size_t value = etl::permutations::value / etl::factorial::value; }; + template + ETL_CONSTANT size_t combinations::value; + #if ETL_USING_CPP17 template inline constexpr size_t combinations_v = combinations::value; diff --git a/include/etl/correlation.h b/include/etl/correlation.h index a1408424..47bfec41 100644 --- a/include/etl/correlation.h +++ b/include/etl/correlation.h @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Correlation Type. //*************************************************************************** - struct correlation_type + namespace private_correlation + { + template + struct correlation_type_statics + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool correlation_type_statics::Sample; + + template + ETL_CONSTANT bool correlation_type_statics::Population; + } + + struct correlation_type : public private_correlation::correlation_type_statics<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** @@ -270,6 +284,9 @@ namespace etl mutable double correlation_value; mutable bool recalculate; }; + + template + ETL_CONSTANT int correlation::Adjustment; } #endif diff --git a/include/etl/covariance.h b/include/etl/covariance.h index e0ba59ee..8ecd8027 100644 --- a/include/etl/covariance.h +++ b/include/etl/covariance.h @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Covariance Type. //*************************************************************************** - struct covariance_type + namespace private_covariance + { + template + struct covariance_type_statics + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool covariance_type_statics::Sample; + + template + ETL_CONSTANT bool covariance_type_statics::Population; + } + + struct covariance_type : public private_covariance::covariance_type_statics<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** @@ -219,6 +233,9 @@ namespace etl mutable double covariance_value; mutable bool recalculate; }; + + template + ETL_CONSTANT int covariance::Adjustment; } #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index aa075ac7..3406ae00 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -2469,6 +2469,9 @@ namespace etl etl::uninitialized_buffer_of buffer; }; + template + ETL_CONSTANT size_t deque::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/factorial.h b/include/etl/factorial.h index 43446aa1..cfe421fb 100644 --- a/include/etl/factorial.h +++ b/include/etl/factorial.h @@ -61,6 +61,9 @@ namespace etl static ETL_CONSTANT size_t value = 1; }; + template + ETL_CONSTANT size_t factorial::value; + #if ETL_USING_CPP17 template inline constexpr size_t factorial_v = factorial::value; diff --git a/include/etl/fibonacci.h b/include/etl/fibonacci.h index 9105f8ad..fb4a0d62 100644 --- a/include/etl/fibonacci.h +++ b/include/etl/fibonacci.h @@ -70,6 +70,9 @@ namespace etl static ETL_CONSTANT size_t value = 0UL; }; + template + ETL_CONSTANT size_t fibonacci::value; + #if ETL_USING_CPP17 template inline constexpr size_t fibonacci_v = fibonacci::value; diff --git a/include/etl/fixed_sized_memory_block_allocator.h b/include/etl/fixed_sized_memory_block_allocator.h index e48a278a..ad4fac30 100644 --- a/include/etl/fixed_sized_memory_block_allocator.h +++ b/include/etl/fixed_sized_memory_block_allocator.h @@ -112,6 +112,15 @@ namespace etl /// The generic pool from which allocate memory blocks. etl::generic_pool pool; }; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Block_Size; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Alignment; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Size; } #endif diff --git a/include/etl/flags.h b/include/etl/flags.h index 5bdf2aaa..3b49dc6c 100644 --- a/include/etl/flags.h +++ b/include/etl/flags.h @@ -349,6 +349,15 @@ namespace etl value_type data; }; + template + ETL_CONSTANT typename flags::value_type flags::ALL_SET; + + template + ETL_CONSTANT typename flags::value_type flags::ALL_CLEAR; + + template + ETL_CONSTANT size_t flags::NBITS; + //*************************************************************************** /// operator == //*************************************************************************** diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 29bd2cd4..0f8ad3d5 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -1158,6 +1158,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_map::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index cd3686fb..01c55720 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -206,7 +206,7 @@ namespace etl //********************************************************************* const_reverse_iterator rend() const { - refmap_t::rend(); + return refmap_t::rend(); } //********************************************************************* @@ -1041,6 +1041,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_multimap::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 7d3fdce2..2f35babe 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -995,6 +995,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_multiset::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 05505df9..1a71cbb3 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -1082,6 +1082,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_set::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 8d1ac9d5..98da9b7e 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1748,6 +1748,9 @@ namespace etl etl::pool::data_node_t, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t forward_list::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 5c71795d..b8b48fee 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -169,10 +169,23 @@ namespace etl } }; + namespace private_fsm + { + template + class ifsm_state_helper + { + // Pass this whenever no state change is desired. + // The highest unsigned value of fsm_state_id_t. + static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; + // Pass this when this event also needs to be passed to the parent. + static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + }; + } + //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state + class ifsm_state : private_fsm::ifsm_state_helper<> { public: diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index c30c8b9c..b5bd4206 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -188,19 +188,26 @@ namespace etl } }; + namespace private_fsm + { + template + class ifsm_state_helper + { + // Pass this whenever no state change is desired. + // The highest unsigned value of fsm_state_id_t. + static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; + // Pass this when this event also needs to be passed to the parent. + static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + }; + } + //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state + class ifsm_state : private_fsm::ifsm_state_helper<> { public: - // Pass this whenever no state change is desired. - // The highest unsigned value of fsm_state_id_t. - static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; - // Pass this when this event also needs to be passed to the parent. - static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; - /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; @@ -325,6 +332,9 @@ namespace etl ifsm_state& operator =(const ifsm_state&); }; + ETL_CONSTANT fsm_state_id_t ifsm_state::No_State_Change; + ETL_CONSTANT fsm_state_id_t ifsm_state::Pass_To_Parent; + //*************************************************************************** /// The FSM class. //*************************************************************************** diff --git a/include/etl/generators/smallest_generator.h b/include/etl/generators/smallest_generator.h index 10f599e3..771d4111 100644 --- a/include/etl/generators/smallest_generator.h +++ b/include/etl/generators/smallest_generator.h @@ -333,6 +333,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_bits_t = typename smallest_uint_for_bits::type; @@ -359,6 +362,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_bits_t = typename smallest_int_for_bits::type; @@ -385,6 +391,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_value_t = typename smallest_uint_for_value::type; @@ -411,6 +420,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_value_t = typename smallest_int_for_value::type; diff --git a/include/etl/generic_pool.h b/include/etl/generic_pool.h index 5ef0635d..f464b7b2 100644 --- a/include/etl/generic_pool.h +++ b/include/etl/generic_pool.h @@ -194,6 +194,15 @@ namespace etl generic_pool& operator =(const generic_pool&) ETL_DELETE; }; + template + ETL_CONSTANT size_t generic_pool::SIZE; + + template + ETL_CONSTANT size_t generic_pool::ALIGNMENT; + + template + ETL_CONSTANT size_t generic_pool::TYPE_SIZE; + //************************************************************************* /// A templated abstract pool implementation that uses a fixed size pool. /// The storage for the pool is supplied externally. @@ -338,6 +347,12 @@ namespace etl generic_pool_ext(const generic_pool_ext&) ETL_DELETE; generic_pool_ext& operator=(const generic_pool_ext&) ETL_DELETE; }; + + template + ETL_CONSTANT size_t generic_pool_ext::ALIGNMENT; + + template + ETL_CONSTANT size_t generic_pool_ext::TYPE_SIZE; } #endif diff --git a/include/etl/hfsm.h b/include/etl/hfsm.h index 73eee88b..b49eaa19 100644 --- a/include/etl/hfsm.h +++ b/include/etl/hfsm.h @@ -67,6 +67,14 @@ namespace etl if (call_on_enter_state) { do_enters(ETL_NULLPTR, p_state, true); + + + //etl::fsm_state_id_t next_state = do_enters(ETL_NULLPTR, p_state, true); + + //if (ifsm_state::No_State_Change != next_state) + //{ + // p_state = state_list[next_state]; + //} } } } diff --git a/include/etl/histogram.h b/include/etl/histogram.h index 4cb03175..15d54222 100644 --- a/include/etl/histogram.h +++ b/include/etl/histogram.h @@ -126,6 +126,9 @@ namespace etl etl::array accumulator; }; + + template + ETL_CONSTANT size_t histogram_common::Max_Size; } //*************************************************************************** @@ -592,6 +595,9 @@ namespace etl etl::flat_map accumulator; }; + + template + ETL_CONSTANT size_t sparse_histogram::Max_Size; } #endif diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 78e592bf..7158a4a0 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -1424,6 +1424,9 @@ namespace etl etl::pool storage_pool; }; + template + ETL_CONSTANT size_t indirect_vector::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index a93f6c88..07949efb 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -59,36 +59,57 @@ namespace etl template <> struct integral_limits { + typedef void value_type; + 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; }; + ETL_CONSTANT int integral_limits::min; + ETL_CONSTANT int integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef signed char value_type; + 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; }; + ETL_CONSTANT signed char integral_limits::min; + ETL_CONSTANT signed char integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef unsigned char value_type; + 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; }; + ETL_CONSTANT unsigned char integral_limits::min; + ETL_CONSTANT unsigned char integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** @@ -99,11 +120,19 @@ namespace etl template <> struct integral_limits { + typedef char value_type; + static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); static ETL_CONSTANT int bits = CHAR_BIT; static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; + + ETL_CONSTANT char integral_limits::min; + ETL_CONSTANT char integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + #if defined(ETL_COMPILER_MICROSOFT) #pragma warning(pop) #endif @@ -114,72 +143,114 @@ namespace etl template <> struct integral_limits { + typedef short value_type; + 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; }; + ETL_CONSTANT short integral_limits::min; + ETL_CONSTANT short integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef unsigned short value_type; + 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; }; + ETL_CONSTANT unsigned short integral_limits::min; + ETL_CONSTANT unsigned short integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef int value_type; + 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; }; + ETL_CONSTANT int integral_limits::min; + ETL_CONSTANT int integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef unsigned int value_type; + 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; }; + ETL_CONSTANT unsigned int integral_limits::min; + ETL_CONSTANT unsigned int integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef long value_type; + 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; }; + ETL_CONSTANT long integral_limits::min; + ETL_CONSTANT long integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef unsigned long value_type; + 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; }; + ETL_CONSTANT unsigned long integral_limits::min; + ETL_CONSTANT unsigned long integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + #ifndef LLONG_MAX #define LLONG_MAX 9223372036854775807LL #endif @@ -198,25 +269,37 @@ namespace etl template <> struct integral_limits { + typedef long long value_type; + 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; }; + ETL_CONSTANT long long integral_limits::min; + ETL_CONSTANT long long integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> struct integral_limits { + typedef unsigned long long value_type; + 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; }; - static ETL_CONSTANT size_t npos = etl::integral_limits::max; + ETL_CONSTANT unsigned long long integral_limits::min; + ETL_CONSTANT unsigned long long integral_limits::max; + ETL_CONSTANT int integral_limits::bits; + ETL_CONSTANT bool integral_limits::is_signed; } #include "private/minmax_pop.h" diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 016eec10..83251179 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -806,24 +806,36 @@ namespace etl static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::input_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_input_iterator::value; + template struct is_output_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::output_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_output_iterator::value; + template struct is_forward_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::forward_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_forward_iterator::value; + template struct is_bidirectional_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::bidirectional_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_bidirectional_iterator::value; + // Deprecated template struct is_random_iterator @@ -831,12 +843,18 @@ namespace etl static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::random_access_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_random_iterator::value; + template struct is_random_access_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::random_access_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_random_access_iterator::value; + template struct is_input_iterator_concept { @@ -846,6 +864,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_input_iterator_concept::value; + template struct is_output_iterator_concept { @@ -855,6 +876,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_output_iterator_concept::value; + template struct is_forward_iterator_concept { @@ -863,6 +887,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_forward_iterator_concept::value; + template struct is_bidirectional_iterator_concept { @@ -870,6 +897,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_bidirectional_iterator_concept::value; + // Deprecated template struct is_random_iterator_concept @@ -877,12 +907,21 @@ namespace etl static ETL_CONSTANT bool value = etl::is_random_iterator::value; }; + // Deprecated + template + ETL_CONSTANT bool is_random_iterator_concept::value; + + // Deprecated template struct is_random_access_iterator_concept { static ETL_CONSTANT bool value = etl::is_random_access_iterator::value; }; + // Deprecated + template + ETL_CONSTANT bool is_random_access_iterator_concept::value; + #if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED //***************************************************************************** /// Get the 'begin' iterator. diff --git a/include/etl/limits.h b/include/etl/limits.h index eae016b0..1aced396 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -101,70 +101,170 @@ namespace etl { enum float_round_style { - round_indeterminate = -1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, round_toward_neg_infinity = 3, }; enum float_denorm_style { denorm_indeterminate = -1, - denorm_absent = 0, - denorm_present = 1 + denorm_absent = 0, + denorm_present = 1 }; - + template class etl_integral_limits { public: - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_integer = true; - static ETL_CONSTANT bool is_exact = true; - static ETL_CONSTANT int max_digits10 = 0; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT int min_exponent = 0; - static ETL_CONSTANT int min_exponent10 = 0; - static ETL_CONSTANT int max_exponent = 0; - static ETL_CONSTANT int max_exponent10 = 0; - static ETL_CONSTANT bool has_infinity = false; - static ETL_CONSTANT bool has_quiet_NaN = false; - static ETL_CONSTANT bool has_signaling_NaN = false; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_integer = true; + static ETL_CONSTANT bool is_exact = true; + static ETL_CONSTANT int max_digits10 = 0; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT int min_exponent = 0; + static ETL_CONSTANT int min_exponent10 = 0; + static ETL_CONSTANT int max_exponent = 0; + static ETL_CONSTANT int max_exponent10 = 0; + static ETL_CONSTANT bool has_infinity = false; + static ETL_CONSTANT bool has_quiet_NaN = false; + static ETL_CONSTANT bool has_signaling_NaN = false; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent; static ETL_CONSTANT float_round_style round_style = round_toward_zero; }; + template + ETL_CONSTANT bool etl_integral_limits::is_specialized; + + template + ETL_CONSTANT bool etl_integral_limits::is_integer; + + template + ETL_CONSTANT bool etl_integral_limits::is_exact; + + template + ETL_CONSTANT int etl_integral_limits::max_digits10; + + template + ETL_CONSTANT int etl_integral_limits::radix; + + template + ETL_CONSTANT int etl_integral_limits::min_exponent; + + template + ETL_CONSTANT int etl_integral_limits::min_exponent10; + + template + ETL_CONSTANT int etl_integral_limits::max_exponent; + + template + ETL_CONSTANT int etl_integral_limits::max_exponent10; + + template + ETL_CONSTANT bool etl_integral_limits::has_infinity; + + template + ETL_CONSTANT bool etl_integral_limits::has_quiet_NaN; + + template + ETL_CONSTANT bool etl_integral_limits::has_signaling_NaN; + + template + ETL_CONSTANT bool etl_integral_limits::has_denorm_loss; + + template + ETL_CONSTANT bool etl_integral_limits::is_iec559; + + template + ETL_CONSTANT bool etl_integral_limits::is_bounded; + + template + ETL_CONSTANT bool etl_integral_limits::traps; + + template + ETL_CONSTANT bool etl_integral_limits::tinyness_before; + + template + ETL_CONSTANT float_denorm_style etl_integral_limits::has_denorm; + + template + ETL_CONSTANT float_round_style etl_integral_limits::round_style; + + template class etl_floating_point_limits { public: - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_integer = false; - static ETL_CONSTANT bool is_exact = false; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT bool has_infinity = true; - static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_integer = false; + static ETL_CONSTANT bool is_exact = false; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT bool has_infinity = true; + static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool is_modulo = false; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate; static ETL_CONSTANT float_round_style round_style = round_indeterminate; static float round_error() { return float(0.5); } }; + template + ETL_CONSTANT bool etl_floating_point_limits::is_specialized; + + template + ETL_CONSTANT bool etl_floating_point_limits::is_integer; + + template + ETL_CONSTANT bool etl_floating_point_limits::is_exact; + + template + ETL_CONSTANT int etl_floating_point_limits::radix; + + template + ETL_CONSTANT bool etl_floating_point_limits::has_infinity; + + template + ETL_CONSTANT bool etl_floating_point_limits::has_quiet_NaN; + + template + ETL_CONSTANT bool etl_floating_point_limits::has_signaling_NaN; + + template + ETL_CONSTANT bool etl_floating_point_limits::has_denorm_loss; + + template + ETL_CONSTANT bool etl_floating_point_limits::is_iec559; + + template + ETL_CONSTANT bool etl_floating_point_limits::is_bounded; + + template + ETL_CONSTANT bool etl_floating_point_limits::traps; + + template + ETL_CONSTANT bool etl_floating_point_limits::tinyness_before; + + template + ETL_CONSTANT float_denorm_style etl_floating_point_limits::has_denorm; + + template + ETL_CONSTANT float_round_style etl_floating_point_limits::round_style; + //*************************************************************************** // Default template @@ -182,12 +282,12 @@ namespace etl //*************************************************************************** // bool template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: - static ETL_CONSTANT int digits = 1; - static ETL_CONSTANT int digits10 = 0; + static ETL_CONSTANT int digits = 1; + static ETL_CONSTANT int digits10 = 0; static ETL_CONSTANT bool is_signed = false; static ETL_CONSTANT bool is_modulo = false; @@ -202,15 +302,20 @@ namespace etl static ETL_CONSTEXPR bool signaling_NaN() { return false; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); static ETL_CONSTANT bool is_signed = etl::is_signed::value; static ETL_CONSTANT bool is_modulo = false; @@ -225,15 +330,20 @@ namespace etl static ETL_CONSTEXPR char signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // unsigned char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); static ETL_CONSTANT bool is_signed = false; static ETL_CONSTANT bool is_modulo = true; @@ -248,10 +358,15 @@ namespace etl static ETL_CONSTEXPR unsigned char signaling_NaN() { return 0U; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // signed char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -271,11 +386,16 @@ namespace etl static ETL_CONSTEXPR signed char signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + #if ETL_HAS_NATIVE_CHAR8_T //*************************************************************************** // char8_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -294,13 +414,18 @@ namespace etl static ETL_CONSTEXPR char8_t quiet_NaN() { return 0; } static ETL_CONSTEXPR char8_t signaling_NaN() { return 0; } }; + + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; #endif #if ETL_HAS_NATIVE_CHAR16_T //*************************************************************************** // char16_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -319,13 +444,18 @@ namespace etl static ETL_CONSTEXPR char16_t quiet_NaN() { return 0U; } static ETL_CONSTEXPR char16_t signaling_NaN() { return 0U; } }; + + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; #endif #if ETL_HAS_NATIVE_CHAR32_T //*************************************************************************** // char32_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -344,12 +474,17 @@ namespace etl static ETL_CONSTEXPR char32_t quiet_NaN() { return 0U; } static ETL_CONSTEXPR char32_t signaling_NaN() { return 0U; } }; + + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; #endif //*************************************************************************** // wchar_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -368,10 +503,15 @@ namespace etl static ETL_CONSTEXPR wchar_t signaling_NaN() { return wchar_t(0); } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // short template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -391,10 +531,15 @@ namespace etl static ETL_CONSTEXPR short signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // unsigned short template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -412,13 +557,17 @@ namespace etl static ETL_CONSTEXPR unsigned short infinity() { return 0U; } static ETL_CONSTEXPR unsigned short quiet_NaN() { return 0U; } static ETL_CONSTEXPR unsigned short signaling_NaN() { return 0U; } - }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // int template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -438,10 +587,15 @@ namespace etl static ETL_CONSTEXPR int signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // unsigned int template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -461,10 +615,15 @@ namespace etl static ETL_CONSTEXPR unsigned int signaling_NaN() { return 0U; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -484,10 +643,15 @@ namespace etl static ETL_CONSTEXPR long signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // unsigned long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -507,10 +671,15 @@ namespace etl static ETL_CONSTEXPR unsigned long signaling_NaN() { return 0U; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // long long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -530,10 +699,15 @@ namespace etl static ETL_CONSTEXPR long long signaling_NaN() { return 0; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // unsigned long long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public etl_integral_limits<> { public: @@ -553,10 +727,15 @@ namespace etl static ETL_CONSTEXPR unsigned long long signaling_NaN() { return 0U; } }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT bool numeric_limits::is_signed; + ETL_CONSTANT bool numeric_limits::is_modulo; + //*************************************************************************** // float template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public etl_floating_point_limits<> { public: @@ -569,20 +748,29 @@ namespace etl static float quiet_NaN() { return ETL_NANF; } static float signaling_NaN() { return ETL_NANF; } - static ETL_CONSTANT int digits = FLT_MANT_DIG; - static ETL_CONSTANT int digits10 = FLT_DIG; + static ETL_CONSTANT int digits = FLT_MANT_DIG; + static ETL_CONSTANT int digits10 = FLT_DIG; static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2; - static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; + static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; + static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP; }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT int numeric_limits::max_digits10; + + ETL_CONSTANT int numeric_limits::min_exponent; + ETL_CONSTANT int numeric_limits::min_exponent10; + ETL_CONSTANT int numeric_limits::max_exponent; + ETL_CONSTANT int numeric_limits::max_exponent10; + //*************************************************************************** // double template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public etl_floating_point_limits<> { public: @@ -595,20 +783,29 @@ namespace etl static double quiet_NaN() { return ETL_NAN; } static double signaling_NaN() { return ETL_NAN; } - static ETL_CONSTANT int digits = DBL_MANT_DIG; - static ETL_CONSTANT int digits10 = DBL_DIG; + static ETL_CONSTANT int digits = DBL_MANT_DIG; + static ETL_CONSTANT int digits10 = DBL_DIG; static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2; - static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; + static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; + static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP; }; + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT int numeric_limits::max_digits10; + + ETL_CONSTANT int numeric_limits::min_exponent; + ETL_CONSTANT int numeric_limits::min_exponent10; + ETL_CONSTANT int numeric_limits::max_exponent; + ETL_CONSTANT int numeric_limits::max_exponent10; + //*************************************************************************** // long double template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public etl_floating_point_limits<> { public: @@ -621,15 +818,24 @@ namespace etl static long double quiet_NaN() { return ETL_NANL; } static long double signaling_NaN() { return ETL_NANL; } - static ETL_CONSTANT int digits = LDBL_MANT_DIG; - static ETL_CONSTANT int digits10 = LDBL_DIG; + static ETL_CONSTANT int digits = LDBL_MANT_DIG; + static ETL_CONSTANT int digits10 = LDBL_DIG; static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2; - static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; + static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; + static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP; }; + + ETL_CONSTANT int numeric_limits::digits; + ETL_CONSTANT int numeric_limits::digits10; + ETL_CONSTANT int numeric_limits::max_digits10; + + ETL_CONSTANT int numeric_limits::min_exponent; + ETL_CONSTANT int numeric_limits::min_exponent10; + ETL_CONSTANT int numeric_limits::max_exponent; + ETL_CONSTANT int numeric_limits::max_exponent10; } #else diff --git a/include/etl/list.h b/include/etl/list.h index c5e78631..cf748ff7 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -2167,6 +2167,9 @@ namespace etl etl::pool::data_node_t, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t list::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/map.h b/include/etl/map.h index 3c0ba2b5..30773032 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -2718,6 +2718,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t map::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/math_constants.h b/include/etl/math_constants.h index 7dd33247..dd99f147 100644 --- a/include/etl/math_constants.h +++ b/include/etl/math_constants.h @@ -33,19 +33,57 @@ SOFTWARE. namespace etl { - namespace math + namespace private_math_constants { - ETL_CONSTANT double pi = 3.14159265358979; - ETL_CONSTANT double pi_reciprocal = 0.31830988618379; - ETL_CONSTANT double pi_squared = 9.86960440108936; - ETL_CONSTANT double e = 2.71828182845905; - ETL_CONSTANT double e_reciprocal = 0.36787944117144; - ETL_CONSTANT double e_squared = 7.38905609893065; - ETL_CONSTANT double root2 = 1.41421356237310; - ETL_CONSTANT double root2_reciprocal = 0.70710678118655; - ETL_CONSTANT double euler = 0.57721566490153; - ETL_CONSTANT double golden_ratio = 1.61803398874989; + template + struct math_helper + { + static ETL_CONSTANT double pi = 3.14159265358979; + static ETL_CONSTANT double pi_reciprocal = 0.31830988618379; + static ETL_CONSTANT double pi_squared = 9.86960440108936; + static ETL_CONSTANT double e = 2.71828182845905; + static ETL_CONSTANT double e_reciprocal = 0.36787944117144; + static ETL_CONSTANT double e_squared = 7.38905609893065; + static ETL_CONSTANT double root2 = 1.41421356237310; + static ETL_CONSTANT double root2_reciprocal = 0.70710678118655; + static ETL_CONSTANT double euler = 0.57721566490153; + static ETL_CONSTANT double golden_ratio = 1.61803398874989; + }; + + template + ETL_CONSTANT double math_helper::pi; + + template + ETL_CONSTANT double math_helper::pi_reciprocal; + + template + ETL_CONSTANT double math_helper::pi_squared; + + template + ETL_CONSTANT double math_helper::e; + + template + ETL_CONSTANT double math_helper::e_reciprocal; + + template + ETL_CONSTANT double math_helper::e_squared; + + template + ETL_CONSTANT double math_helper::root2; + + template + ETL_CONSTANT double math_helper::root2_reciprocal; + + template + ETL_CONSTANT double math_helper::euler; + + template + ETL_CONSTANT double math_helper::golden_ratio; } + + struct math : public private_math_constants::math_helper<> + { + }; } #endif diff --git a/include/etl/mem_cast.h b/include/etl/mem_cast.h index d611dab2..33b79021 100644 --- a/include/etl/mem_cast.h +++ b/include/etl/mem_cast.h @@ -315,6 +315,12 @@ namespace etl etl::uninitialized_buffer buffer; }; + template + ETL_CONSTANT size_t mem_cast::Size; + + template + ETL_CONSTANT size_t mem_cast::Alignment; + //***************************************************************************** /// mem_cast_ptr //***************************************************************************** diff --git a/include/etl/memory.h b/include/etl/memory.h index 4e39ca3a..38e9889c 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -2146,6 +2146,15 @@ namespace etl #endif }; + template + ETL_CONSTANT size_t uninitialized_buffer::Object_Size; + + template + ETL_CONSTANT size_t uninitialized_buffer::N_Objects; + + template + ETL_CONSTANT size_t uninitialized_buffer::Alignment; + //*************************************************************************** /// Declares an aligned buffer of VN_Objects as if they were type T. ///\ingroup alignment @@ -2235,6 +2244,15 @@ namespace etl #endif }; + template + ETL_CONSTANT size_t uninitialized_buffer_of::Object_Size; + + template + ETL_CONSTANT size_t uninitialized_buffer_of::N_Objects; + + template + ETL_CONSTANT size_t uninitialized_buffer_of::Alignment; + #if ETL_USING_CPP11 template using uninitialized_buffer_of_t = typename uninitialized_buffer_of::buffer; diff --git a/include/etl/multimap.h b/include/etl/multimap.h index cf4639a7..fb14bba1 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -2438,6 +2438,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t multimap::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 92d33796..5494792c 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -2420,6 +2420,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t multiset::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/permutations.h b/include/etl/permutations.h index 3b5b69c0..12fcbec7 100644 --- a/include/etl/permutations.h +++ b/include/etl/permutations.h @@ -49,6 +49,9 @@ namespace etl static ETL_CONSTANT size_t value = NV * permutations::value; }; + template + ETL_CONSTANT size_t permutations::value; + //*************************************************************************** /// Calculates permutations. /// Specialisation for KV == 0. @@ -59,6 +62,9 @@ namespace etl static ETL_CONSTANT size_t value = 1UL; }; + template + ETL_CONSTANT size_t permutations::value; + #if ETL_USING_CPP17 template inline constexpr size_t permutations_v = permutations::value; diff --git a/include/etl/poly_span.h b/include/etl/poly_span.h index 79d3f32d..1c960e7e 100644 --- a/include/etl/poly_span.h +++ b/include/etl/poly_span.h @@ -611,6 +611,9 @@ namespace etl size_t element_size; }; + template + ETL_CONSTANT size_t poly_span::extent; + //*************************************************************************** /// Poly Span - Dynamic Extent //*************************************************************************** @@ -984,6 +987,9 @@ protected: size_t span_extent; }; + template + ETL_CONSTANT size_t poly_span::extent; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/power.h b/include/etl/power.h index 7816dd88..9ca4f0f0 100644 --- a/include/etl/power.h +++ b/include/etl/power.h @@ -63,6 +63,9 @@ namespace etl static ETL_CONSTANT private_power::type value = NV * power::value; }; + template + ETL_CONSTANT private_power::type power::value; + //*************************************************************************** /// Calculates powers. ///\note Only supports positive N. @@ -74,6 +77,9 @@ namespace etl static ETL_CONSTANT private_power::type value = 1; }; + template + ETL_CONSTANT private_power::type power::value; + #if ETL_USING_CPP17 template inline constexpr size_t power_v = power::value; @@ -203,6 +209,9 @@ namespace etl static ETL_CONSTANT bool value = false; }; + template + ETL_CONSTANT bool is_power_of_2::value; + #if ETL_USING_CPP17 template inline constexpr size_t is_power_of_2_v = is_power_of_2::value; diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 46be2901..d4222090 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -526,6 +526,9 @@ namespace etl } #endif }; + + template + ETL_CONSTANT typename priority_queue::size_type priority_queue::MAX_SIZE; } #endif diff --git a/include/etl/private/bitset_legacy.h b/include/etl/private/bitset_legacy.h index 775012b7..5d785152 100644 --- a/include/etl/private/bitset_legacy.h +++ b/include/etl/private/bitset_legacy.h @@ -1064,6 +1064,12 @@ namespace etl #endif }; + ETL_CONSTANT ibitset::element_type ibitset::ALL_SET; + + ETL_CONSTANT ibitset::element_type ibitset::ALL_CLEAR; + + ETL_CONSTANT size_t ibitset::Bits_Per_Element; + //************************************************************************* /// The class emulates an array of bool elements, but optimized for space allocation. /// Will accommodate any number of bits. @@ -1429,6 +1435,12 @@ namespace etl element_type data[Array_Size > 0U ? Array_Size : 1U]; }; + template + ETL_CONSTANT size_t bitset::ALLOCATED_BITS; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + //*************************************************************************** /// operator & ///\ingroup bitset diff --git a/include/etl/private/bitset_new.h b/include/etl/private/bitset_new.h index d636ce60..9352d2b9 100644 --- a/include/etl/private/bitset_new.h +++ b/include/etl/private/bitset_new.h @@ -76,11 +76,15 @@ SOFTWARE. namespace etl { + template struct bitset_constants { static ETL_CONSTANT size_t npos = etl::integral_limits::max; }; + template + ETL_CONSTANT size_t bitset_constants::npos; + //*************************************************************************** /// Exception base for bitset ///\ingroup bitset @@ -114,7 +118,7 @@ namespace etl ///\ingroup bitset //************************************************************************* template - class bitset_impl : public bitset_constants + class bitset_impl : public bitset_constants<> { public: @@ -795,6 +799,15 @@ namespace etl } }; + template + ETL_CONSTANT size_t bitset_impl::Bits_Per_Element; + + template + ETL_CONSTANT typename bitset_impl::element_type bitset_impl::All_Set_Element; + + template + ETL_CONSTANT typename bitset_impl::element_type bitset_impl::All_Clear_Element; + //*************************************************************************** template - class bitset<0U, void, true> : public bitset_constants + class bitset<0U, void, true> : public bitset_constants<> { }; @@ -814,7 +827,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset<0U, void, false> : public bitset_constants + class bitset<0U, void, false> : public bitset_constants<> { }; @@ -823,7 +836,7 @@ namespace etl /// same size as the number of active bits. //*************************************************************************** template - class bitset : public bitset_constants + class bitset : public bitset_constants<> { public: @@ -879,6 +892,15 @@ namespace etl return *this; } + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Flip the bit. //******************************* @@ -1663,11 +1685,32 @@ namespace etl element_type buffer; }; + template + ETL_CONSTANT size_t bitset::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Set_Element; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset::element_type bitset::Top_Mask; + //************************************************************************* /// The specialisation that uses an array of the default element type. //************************************************************************* template - class bitset : public bitset_constants + class bitset : public bitset_constants<> { private: @@ -1734,6 +1777,15 @@ namespace etl return *this; } + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Flip the bit. //******************************* @@ -2312,6 +2364,27 @@ namespace etl element_type buffer[Number_Of_Elements > 0U ? Number_Of_Elements : 1U]; }; + template + ETL_CONSTANT size_t bitset::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Set_Element; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset::element_type bitset::Top_Mask; + //*************************************************************************** /// operator & ///\ingroup bitset @@ -2375,8 +2448,8 @@ namespace etl { //*************************************************************************** template ::bits == Active_Bits> + typename TElement = void, + bool IsSingleElement = etl::integral_limits::bits == Active_Bits> class bitset_ext; //*************************************************************************** @@ -2384,7 +2457,7 @@ namespace etl /// Just defines 'npos'. //*************************************************************************** template <> - class bitset_ext<0U, void, true> : public bitset_constants + class bitset_ext<0U, void, true> : public bitset_constants<> { }; @@ -2392,7 +2465,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset_ext<0U, void, false> : public bitset_constants + class bitset_ext<0U, void, false> : public bitset_constants<> { }; @@ -2401,7 +2474,7 @@ namespace etl /// same size as the number of active bits. //*************************************************************************** template - class bitset_ext : public bitset_constants + class bitset_ext : public bitset_constants<> { public: @@ -3240,11 +3313,32 @@ namespace etl element_type* pbuffer; }; + template + ETL_CONSTANT size_t bitset_ext::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset_ext::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset_ext::Allocated_Bits; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Set_Element; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset_ext::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::Top_Mask; + //************************************************************************* /// The specialisation that uses an array of the default element type. //************************************************************************* template - class bitset_ext : public bitset_constants + class bitset_ext : public bitset_constants<> { private: @@ -3891,6 +3985,27 @@ namespace etl element_type* pbuffer; }; + template + ETL_CONSTANT size_t bitset_ext::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset_ext::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset_ext::Allocated_Bits; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Set_Element; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset_ext::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::Top_Mask; + //*************************************************************************** /// operator != ///\ingroup bitset diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index 8e450544..d94f0f18 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -66,6 +66,9 @@ namespace etl : TAccumulator(Do_Poly ? (Entry << 1U) ^ Polynomial : (Entry << 1U)); }; + template + ETL_CONSTANT TAccumulator crc_partial_table_entry::value; + //***************************************************************************** /// CRC Table Entry //***************************************************************************** @@ -89,6 +92,15 @@ namespace etl crc_partial_table_entry::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //********************************* // Chunk bit size of 4. template @@ -105,6 +117,15 @@ namespace etl crc_partial_table_entry::value>::value>::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //********************************* // Chunk bit size of 8. template @@ -125,6 +146,15 @@ namespace etl crc_partial_table_entry::value>::value>::value>::value>::value>::value>::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //***************************************************************************** /// CRC Update Chunk //***************************************************************************** diff --git a/include/etl/private/crc_parameters.h b/include/etl/private/crc_parameters.h index 8ffb9242..72cd1ef5 100644 --- a/include/etl/private/crc_parameters.h +++ b/include/etl/private/crc_parameters.h @@ -53,6 +53,21 @@ namespace etl static ETL_CONSTANT size_t Accumulator_Bits = etl::integral_limits::bits; }; + template + ETL_CONSTANT TAccumulator crc_parameters::Polynomial; + + template + ETL_CONSTANT TAccumulator crc_parameters::Initial; + + template + ETL_CONSTANT TAccumulator crc_parameters::Xor_Out; + + template + ETL_CONSTANT bool crc_parameters::Reflect; + + template + ETL_CONSTANT size_t crc_parameters::Accumulator_Bits; + // 8 bit. typedef crc_parameters crc8_ccitt_parameters; typedef crc_parameters crc8_rohc_parameters; diff --git a/include/etl/pseudo_moving_average.h b/include/etl/pseudo_moving_average.h index 73c3d7c5..62a84643 100644 --- a/include/etl/pseudo_moving_average.h +++ b/include/etl/pseudo_moving_average.h @@ -48,8 +48,8 @@ namespace etl public: //*********************************** - explicit add_insert_iterator(TCMA& cma) ETL_NOEXCEPT - : p_cma(&cma) + explicit add_insert_iterator(TCMA& pma) ETL_NOEXCEPT + : p_pma(&pma) { } @@ -74,18 +74,18 @@ namespace etl //*********************************** add_insert_iterator& operator =(typename TCMA::value_type value) { - p_cma->add(value); + p_pma->add(value); return *this; } private: - TCMA* p_cma; + TCMA* p_pma; }; } //*************************************************************************** - /// Cumulative Moving Average + /// Pseudo Moving Average /// \tparam T The sample value type. /// \tparam SAMPLE_SIZE The number of samples to average over. /// \tparam SCALING The scaling factor applied to samples. Default = 1. @@ -98,7 +98,7 @@ namespace etl class pseudo_moving_average; //*************************************************************************** - /// Cumulative Moving Average + /// Pseudo Moving Average /// For integral types. /// \tparam T The sample value type. /// \tparam SAMPLE_SIZE The number of samples to average over. @@ -177,8 +177,14 @@ namespace etl T average; ///< The current pseudo moving average. }; + template + ETL_CONSTANT size_t pseudo_moving_average::SAMPLE_SIZE; + + template + ETL_CONSTANT size_t pseudo_moving_average::SCALING; + //*************************************************************************** -/// Cumulative Moving Average +/// Pseudo Moving Average /// For integral types. /// \tparam T The sample value type. /// \tparam SCALING The scaling factor applied to samples. Default = 1. @@ -263,8 +269,11 @@ namespace etl sample_t samples; ///< The number of samples to average over. }; + template + ETL_CONSTANT size_t pseudo_moving_average::SCALING; + //*************************************************************************** - /// Cumulative Moving Average + /// Pseudo Moving Average /// For floating point types. /// \tparam T The sample value type. /// \tparam SAMPLE_SIZE The number of samples to average over. @@ -333,11 +342,13 @@ namespace etl T average; ///< The current pseudo moving average. }; + template + ETL_CONSTANT size_t pseudo_moving_average::SAMPLE_SIZE; + //*************************************************************************** - /// Cumulative Moving Average + /// Pseudo Moving Average /// For floating point types. - /// \tparam T The sample value type. - /// \tparam SAMPLE_SIZE The number of samples to average over. + /// \tparam T The sample value type. //*************************************************************************** template class pseudo_moving_average diff --git a/include/etl/queue.h b/include/etl/queue.h index 1dcd7685..72b3a83e 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -660,6 +660,9 @@ namespace etl /// The uninitialised buffer of T used in the queue. container_type buffer[SIZE]; }; + + template + ETL_CONSTANT typename queue::size_type queue::MAX_SIZE; } #endif diff --git a/include/etl/queue_lockable.h b/include/etl/queue_lockable.h index f3e525c5..f8a325b4 100644 --- a/include/etl/queue_lockable.h +++ b/include/etl/queue_lockable.h @@ -837,6 +837,12 @@ namespace etl /// The uninitialised buffer of T used in the queue_lockable. etl::uninitialized_buffer_of buffer; }; + + template + ETL_CONSTANT typename queue_lockable::size_type queue_lockable::Max_Size; + + template + ETL_CONSTANT typename queue_lockable::size_type queue_lockable::Memory_Model; } #endif diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 318506ed..794c7f01 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -676,6 +676,9 @@ namespace etl /// The uninitialised buffer of T used in the queue_mpmc_mutex. typename etl::aligned_storage::value>::type buffer[MAX_SIZE]; }; + + template + ETL_CONSTANT typename queue_mpmc_mutex::size_type queue_mpmc_mutex::MAX_SIZE; } #endif diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index 84febb7b..e27bf41c 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -541,6 +541,9 @@ namespace etl /// The uninitialised buffer of T used in the queue_spsc. typename etl::aligned_storage::value>::type buffer[RESERVED_SIZE]; }; + + template + ETL_CONSTANT typename queue_spsc_atomic::size_type queue_spsc_atomic::MAX_SIZE; } #endif diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 5a2b04aa..eeb7d155 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -797,6 +797,9 @@ namespace etl /// The uninitialised buffer of T used in the queue_spsc_isr. typename etl::aligned_storage::value>::type buffer[MAX_SIZE]; }; + + template + ETL_CONSTANT typename queue_spsc_isr::size_type queue_spsc_isr::MAX_SIZE; } #endif diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index ad3e1a72..3495b2f4 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -860,6 +860,9 @@ namespace etl /// The uninitialised buffer of T used in the queue_lockable. etl::uninitialized_buffer_of buffer; }; + + template + ETL_CONSTANT typename queue_spsc_locked::size_type queue_spsc_locked::MAX_SIZE; } #endif diff --git a/include/etl/ratio.h b/include/etl/ratio.h index b5483606..aa11939c 100644 --- a/include/etl/ratio.h +++ b/include/etl/ratio.h @@ -48,6 +48,12 @@ namespace etl static ETL_CONSTANT intmax_t den = DEN; }; + template + ETL_CONSTANT intmax_t ratio::num; + + template + ETL_CONSTANT intmax_t ratio::den; + #if INT_MAX > INT32_MAX typedef ratio<1, 1000000000000000000000000> yocto; typedef ratio<1, 1000000000000000000000> zepto; diff --git a/include/etl/reference_counted_message_pool.h b/include/etl/reference_counted_message_pool.h index ff773e5f..d678f9fe 100644 --- a/include/etl/reference_counted_message_pool.h +++ b/include/etl/reference_counted_message_pool.h @@ -214,6 +214,7 @@ namespace etl // The maximum alignment. static constexpr size_t max_alignment = etl::alignment_of>::value; }; + #else template @@ -247,6 +248,7 @@ namespace etl etl::reference_counted_message, etl::reference_counted_message >::alignment; }; + #endif private: @@ -259,6 +261,30 @@ namespace etl reference_counted_message_pool& operator =(const reference_counted_message_pool&) ETL_DELETE; }; +#if ETL_USING_CPP11 + + template + template + constexpr size_t reference_counted_message_pool::pool_message_parameters::max_size; + + template + template + constexpr size_t reference_counted_message_pool::pool_message_parameters::max_alignment; + +#else + + template + template + const size_t reference_counted_message_pool::pool_message_parameters::max_size; + + template + template + const size_t reference_counted_message_pool::pool_message_parameters::max_alignment; + +#endif + #if ETL_USING_CPP11 && ETL_HAS_ATOMIC using atomic_counted_message_pool = reference_counted_message_pool; #endif diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 0b0d070a..fe162a2e 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -1175,6 +1175,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t reference_flat_map< TKey, TValue, MAX_SIZE_, TCompare>::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index b12b4a07..605a9b3a 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -1041,6 +1041,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t reference_flat_multimap< TKey, TValue, MAX_SIZE_, TCompare>::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index e1501d53..5d1931ad 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -991,6 +991,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t reference_flat_multiset::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 69a2ced7..3f30ae26 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -981,6 +981,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t reference_flat_set::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/set.h b/include/etl/set.h index d21c14b8..9e2b5c4c 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -2625,6 +2625,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t set::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/smallest.h b/include/etl/smallest.h index c2c981a6..290fdcc4 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -303,6 +303,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_bits_t = typename smallest_uint_for_bits::type; @@ -329,6 +332,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_bits_t = typename smallest_int_for_bits::type; @@ -355,6 +361,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_value_t = typename smallest_uint_for_value::type; @@ -366,7 +375,7 @@ namespace etl /// Defines 'type' which is the type of the smallest signed integer. ///\ingroup smallest //*************************************************************************** - template + template struct smallest_int_for_value { private: @@ -381,6 +390,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_value_t = typename smallest_int_for_value::type; diff --git a/include/etl/span.h b/include/etl/span.h index 531e68dc..fac02f10 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -849,6 +849,9 @@ namespace etl pointer pend; }; + template + ETL_CONSTANT size_t span::extent; + //************************************************************************* /// Compare two spans for equality. //************************************************************************* diff --git a/include/etl/stack.h b/include/etl/stack.h index 54006192..cea00443 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -601,6 +601,9 @@ namespace etl /// The uninitialised buffer of T used in the stack. container_type buffer[SIZE]; }; + + template + ETL_CONSTANT size_t stack::MAX_SIZE; } #endif diff --git a/include/etl/standard_deviation.h b/include/etl/standard_deviation.h index 0fbb774f..14076d15 100644 --- a/include/etl/standard_deviation.h +++ b/include/etl/standard_deviation.h @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Standard Deviation Type. //*************************************************************************** - struct standard_deviation_type + namespace private_standard_deviation + { + template + struct standard_deviation_type_helper + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool standard_deviation_type_helper::Sample; + + template + ETL_CONSTANT bool standard_deviation_type_helper::Population; + } + + struct standard_deviation_type : public private_standard_deviation::standard_deviation_type_helper<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** diff --git a/include/etl/string.h b/include/etl/string.h index a84c4d3a..7134b635 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -259,6 +259,9 @@ namespace etl value_type buffer[MAX_SIZE + 1]; }; + template + ETL_CONSTANT size_t string::MAX_SIZE; + //*************************************************************************** /// A string implementation that uses a fixed size external buffer. ///\ingroup string diff --git a/include/etl/to_arithmetic.h b/include/etl/to_arithmetic.h index da0f5052..024bd8f9 100644 --- a/include/etl/to_arithmetic.h +++ b/include/etl/to_arithmetic.h @@ -193,11 +193,34 @@ namespace etl namespace private_to_arithmetic { - static ETL_CONSTANT char Positive_Char = '+'; - static ETL_CONSTANT char Negative_Char = '-'; - static ETL_CONSTANT char Radix_Point1_Char = '.'; - static ETL_CONSTANT char Radix_Point2_Char = ','; - static ETL_CONSTANT char Exponential_Char = 'e'; + template + struct char_statics + { + static ETL_CONSTANT char Positive_Char = '+'; + static ETL_CONSTANT char Negative_Char = '-'; + static ETL_CONSTANT char Radix_Point1_Char = '.'; + static ETL_CONSTANT char Radix_Point2_Char = ','; + static ETL_CONSTANT char Exponential_Char = 'e'; + }; + + template + ETL_CONSTANT char char_statics::Positive_Char; + + template + ETL_CONSTANT char char_statics::Negative_Char; + + template + ETL_CONSTANT char char_statics::Radix_Point1_Char; + + template + ETL_CONSTANT char char_statics::Radix_Point2_Char; + + template + ETL_CONSTANT char char_statics::Exponential_Char; + + struct char_constant : char_statics<> + { + }; //******************************************* ETL_NODISCARD @@ -312,8 +335,8 @@ namespace etl { // Check for prefix. const char c = convert(view[0]); - const bool has_positive_prefix = (c == Positive_Char); - const bool has_negative_prefix = (c == Negative_Char); + const bool has_positive_prefix = (c == char_constant::Positive_Char); + const bool has_negative_prefix = (c == char_constant::Negative_Char); // Step over the prefix, if present. if (has_positive_prefix || has_negative_prefix) @@ -465,19 +488,19 @@ namespace etl //*************************** case Parsing_Integral: { - if (expecting_sign && ((c == Positive_Char) || (c == Negative_Char))) + if (expecting_sign && ((c == char_constant::Positive_Char) || (c == char_constant::Negative_Char))) { - is_negative_mantissa = (c == Negative_Char); + is_negative_mantissa = (c == char_constant::Negative_Char); expecting_sign = false; } // Radix point? - else if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char)) + else if ((c == char_constant::Radix_Point1_Char) || (c == char_constant::Radix_Point2_Char)) { expecting_sign = false; state = Parsing_Fractional; } // Exponential? - else if (c == Exponential_Char) + else if (c == char_constant::Exponential_Char) { expecting_sign = true; state = Parsing_Exponential; @@ -502,13 +525,13 @@ namespace etl case Parsing_Fractional: { // Radix point? - if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char)) + if ((c == char_constant::Radix_Point1_Char) || (c == char_constant::Radix_Point2_Char)) { conversion_status = to_arithmetic_status::Invalid_Format; is_success = false; } // Exponential? - else if (c == Exponential_Char) + else if (c == char_constant::Exponential_Char) { expecting_sign = true; state = Parsing_Exponential; @@ -532,13 +555,13 @@ namespace etl //*************************** case Parsing_Exponential: { - if (expecting_sign && ((c == Positive_Char) || (c == Negative_Char))) + if (expecting_sign && ((c == char_constant::Positive_Char) || (c == char_constant::Negative_Char))) { - is_negative_exponent = (c == Negative_Char); + is_negative_exponent = (c == char_constant::Negative_Char); expecting_sign = false; } // Radix point? - else if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char) || (c == Exponential_Char)) + else if ((c == char_constant::Radix_Point1_Char) || (c == char_constant::Radix_Point2_Char) || (c == char_constant::Exponential_Char)) { conversion_status = to_arithmetic_status::Invalid_Format; is_success = false; diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index 55337455..31803095 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -125,14 +125,14 @@ namespace etl template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : id_from_type_helper::value; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : id_from_type_helper::value; }; // Specialisation for 1 type pair. template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : UNKNOWN; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : UNKNOWN; }; public: diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index cf50a3e1..0236b29e 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1739,6 +1739,9 @@ namespace etl static ETL_CONSTANT bool value = __is_assignable(T1, T2); }; + template + ETL_CONSTANT bool is_assignable::value; + #if ETL_USING_CPP11 //********************************************* // is_constructible @@ -1747,6 +1750,9 @@ namespace etl { static ETL_CONSTANT bool value = __is_constructible(T, TArgs...); }; + + template + ETL_CONSTANT bool is_constructible::value; #else //********************************************* // is_constructible @@ -1763,6 +1769,9 @@ namespace etl { static ETL_CONSTANT bool value = __is_constructible(T); }; + + template + ETL_CONSTANT bool is_constructible::value; #endif //********************************************* @@ -1791,6 +1800,8 @@ namespace etl static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...); #endif }; + template + ETL_CONSTANT bool is_trivially_constructible::value; #else //********************************************* // is_trivially_constructible @@ -1817,6 +1828,9 @@ namespace etl }; #endif + template + ETL_CONSTANT bool is_trivially_constructible::value; + //********************************************* // is_trivially_copy_constructible template diff --git a/include/etl/variance.h b/include/etl/variance.h index f9b6986f..85726917 100644 --- a/include/etl/variance.h +++ b/include/etl/variance.h @@ -43,7 +43,7 @@ namespace etl namespace private_variance { //*************************************************************************** - /// Types for generic correlation. + /// Types for generic variance. //*************************************************************************** template struct variance_traits @@ -52,7 +52,7 @@ namespace etl }; //*************************************************************************** - /// Types for float correlation. + /// Types for float variance. //*************************************************************************** template struct variance_traits @@ -61,7 +61,7 @@ namespace etl }; //*************************************************************************** - /// Types for double correlation. + /// Types for double variance. //*************************************************************************** template struct variance_traits @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Variance Type. //*************************************************************************** - struct variance_type + namespace private_variance + { + template + struct variance_type_helper + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool variance_type_helper::Sample; + + template + ETL_CONSTANT bool variance_type_helper::Population; + } + + struct variance_type : public private_variance::variance_type_helper<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** From 6e686d47993197313c16a7a46e3fedc2189d4fa2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 Apr 2023 10:00:10 +0100 Subject: [PATCH 4/6] Message packet unused parameter fix --- include/etl/message_packet.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index cf5e4442..d5130974 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -387,7 +387,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -680,7 +680,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -971,7 +971,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1260,7 +1260,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1546,7 +1546,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1827,7 +1827,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2106,7 +2106,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2383,7 +2383,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2657,7 +2657,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2926,7 +2926,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3193,7 +3193,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3458,7 +3458,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3720,7 +3720,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3977,7 +3977,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -4232,7 +4232,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -4485,7 +4485,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. From aa1d7f0f7f2c4511cbe0f89efdab15b699d77d77 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 Apr 2023 09:28:37 +0100 Subject: [PATCH 5/6] Conversion of static to C++14 compatinility --- .gitignore | 4 + include/etl/basic_string.h | 23 +- include/etl/fsm.h | 16 +- include/etl/functional.h | 5 + include/etl/generators/fsm_generator.h | 11 +- .../etl/generators/message_packet_generator.h | 4 +- .../etl/generators/type_lookup_generator.h | 4 +- .../etl/generators/type_traits_generator.h | 56 +- include/etl/integral_limits.h | 598 +++++++--- include/etl/limits.h | 1008 +++++++++++------ include/etl/parameter_pack.h | 10 + include/etl/private/bitset_legacy.h | 9 + include/etl/private/bitset_new.h | 66 +- include/etl/private/variant_variadic.h | 6 +- include/etl/smallest.h | 8 +- include/etl/span.h | 3 + include/etl/sqrt.h | 5 + include/etl/type_traits.h | 91 +- include/etl/unaligned_type.h | 9 + test/UnitTest++/Checks.h | 12 +- test/etl_initializer_list/CMakeLists.txt | 23 +- test/runtests-O1.sh | 238 ---- test/runtests-O2.sh | 238 ---- test/runtests-O3.sh | 238 ---- test/runtests-c++14.sh | 348 ------ test/runtests.sh | 464 ++++---- test/test_numeric.cpp | 1 + test/test_to_arithmetic.cpp | 1 + test/test_to_arithmetic_u16.cpp | 1 + test/test_to_arithmetic_u32.cpp | 1 + test/test_to_arithmetic_wchar_t.cpp | 1 + test/vs2022/cpp.hint | 19 +- test/vs2022/etl.vcxproj | 4 - test/vs2022/etl.vcxproj.filters | 14 +- 34 files changed, 1532 insertions(+), 2007 deletions(-) delete mode 100644 test/runtests-O1.sh delete mode 100644 test/runtests-O2.sh delete mode 100644 test/runtests-O3.sh delete mode 100644 test/runtests-c++14.sh diff --git a/.gitignore b/.gitignore index 5c8a2e4c..4f2b0c76 100644 --- a/.gitignore +++ b/.gitignore @@ -379,3 +379,7 @@ test/vs2022/Debug MSVC - No STL - Force Built-ins test/temp test/vs2022/Debug MSVC C++14 test/vs2022/Debug MSVC C++20 - No STL +build-test-Desktop_x86_windows_msvc2019_pe_64bit-Debug +test/vs2022/Debug MSVC C++14 - No STL +test/log.txt +test/etl_error_handler/log.txt diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index f26e7ee7..7d305853 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -144,8 +144,19 @@ namespace etl { public: + typedef size_t size_type; + 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; + +#if ETL_USING_CPP11 + static constexpr size_type npos = etl::integral_limits::max; +#else + enum + { + npos = etl::integral_limits::max + }; +#endif }; template @@ -153,6 +164,9 @@ namespace etl template ETL_CONSTANT uint_least8_t string_base_statics::CLEAR_AFTER_USE; + + template + ETL_CONSTANT typename string_base_statics::size_type string_base_statics::npos; } //*************************************************************************** @@ -162,15 +176,6 @@ namespace etl typedef size_t size_type; -#if ETL_USING_CPP11 - static constexpr size_type npos = etl::integral_limits::max; -#else - enum - { - npos = etl::integral_limits::max - }; -#endif - //************************************************************************* /// Gets the current size of the string. ///\return The current size of the string. diff --git a/include/etl/fsm.h b/include/etl/fsm.h index b8b48fee..0f2eb368 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -174,27 +174,29 @@ namespace etl template class ifsm_state_helper { + public: + // Pass this whenever no state change is desired. // The highest unsigned value of fsm_state_id_t. static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; // Pass this when this event also needs to be passed to the parent. static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; }; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::No_State_Change; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; } //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state : private_fsm::ifsm_state_helper<> + class ifsm_state : public private_fsm::ifsm_state_helper<> { public: - // Pass this whenever no state change is desired. - // The highest unsigned value of fsm_state_id_t. - static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; - // Pass this when this event also needs to be passed to the parent. - static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; - /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; diff --git a/include/etl/functional.h b/include/etl/functional.h index 0a4bde46..e6a72ad8 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -57,6 +57,11 @@ namespace etl { } + ETL_CONSTEXPR20 reference_wrapper(const reference_wrapper& rhs) ETL_NOEXCEPT + : t(rhs.t) + { + } + ETL_CONSTEXPR20 reference_wrapper& operator = (const reference_wrapper& rhs) ETL_NOEXCEPT { t = rhs.t; diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index b5bd4206..6d5e945a 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -193,18 +193,27 @@ namespace etl template class ifsm_state_helper { + public: + // Pass this whenever no state change is desired. // The highest unsigned value of fsm_state_id_t. static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; + // Pass this when this event also needs to be passed to the parent. static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; }; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::No_State_Change; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; } //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state : private_fsm::ifsm_state_helper<> + class ifsm_state : public private_fsm::ifsm_state_helper<> { public: diff --git a/include/etl/generators/message_packet_generator.h b/include/etl/generators/message_packet_generator.h index 6ada9acd..8a9bf0e0 100644 --- a/include/etl/generators/message_packet_generator.h +++ b/include/etl/generators/message_packet_generator.h @@ -483,7 +483,7 @@ namespace etl for n in range(1, int(Handlers)): cog.out("T%s, " % n) cog.outl("T%s>::value, int>::type>" % int(Handlers)) - cog.outl(" explicit message_packet(TMessage&& msg)") + cog.outl(" explicit message_packet(TMessage&& /*msg*/)") cog.outl(" : valid(true)") cog.outl(" {") generate_static_assert_cpp11(int(Handlers)) @@ -767,7 +767,7 @@ namespace etl for t in range(1, n): cog.out("T%s, " % t) cog.outl("T%s>::value, int>::type>" % n) - cog.outl(" explicit message_packet(TMessage&& msg)") + cog.outl(" explicit message_packet(TMessage&& /*msg*/)") cog.outl(" : valid(true)") cog.outl(" {") generate_static_assert_cpp11(n) diff --git a/include/etl/generators/type_lookup_generator.h b/include/etl/generators/type_lookup_generator.h index 2563729a..bcc10e2d 100644 --- a/include/etl/generators/type_lookup_generator.h +++ b/include/etl/generators/type_lookup_generator.h @@ -137,14 +137,14 @@ namespace etl template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : id_from_type_helper::value; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : id_from_type_helper::value; }; // Specialisation for 1 type pair. template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : UNKNOWN; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : UNKNOWN; }; public: diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 83939a93..1518d94d 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1622,99 +1622,71 @@ namespace etl //********************************************* // is_assignable template - struct is_assignable : public std::is_assignable - { - }; + using is_assignable = std::is_assignable; //********************************************* // is_constructible template - struct is_constructible : public std::is_constructible - { - }; + using is_constructible = std::is_constructible; //********************************************* // is_copy_constructible template - struct is_copy_constructible : public std::is_copy_constructible - { - }; + using is_copy_constructible = std::is_copy_constructible; //********************************************* // is_move_constructible template - struct is_move_constructible : public std::is_move_constructible - { - }; + using is_move_constructible = std::is_move_constructible; //********************************************* // is_trivially_constructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_constructible : public std::is_trivially_constructible - { - }; + using is_trivially_constructible = std::is_trivially_constructible; #else template - struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_constructible = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_copy_constructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_copy_constructible : public std::is_trivially_copy_constructible - { - }; + using is_trivially_copy_constructible = std::is_trivially_copy_constructible; #else template - struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copy_constructible = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_destructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_destructible : public std::is_trivially_destructible - { - }; + using is_trivially_destructible = std::is_trivially_destructible; #else template - struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_destructible = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_copy_assignable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_copy_assignable : public std::is_trivially_copy_assignable - { - }; + using is_trivially_copy_assignable = std::is_trivially_copy_assignable; #else template - struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copy_assignable = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_copyable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_copyable : public std::is_trivially_copyable - { - }; + using is_trivially_copyable = std::is_trivially_copyable; #else template - struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copyable = etl::bool_constant::value || etl::is_pointer::value>; #endif #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index 07949efb..f7b7c68c 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -45,8 +45,422 @@ SOFTWARE. ///\ingroup utilities //***************************************************************************** +#ifndef LLONG_MAX + #define LLONG_MAX 9223372036854775807LL +#endif + +#ifndef LLONG_MIN + #define LLONG_MIN (-LLONG_MAX - 1LL) +#endif + +#ifndef ULLONG_MAX + #define ULLONG_MAX 18446744073709551615ULL +#endif + namespace etl { + namespace private_integral_limits + { + //***************************************************************************** + /// The technique of using templated base classes to declare and define the statics + /// is to get around the limits of the One Definition Rule (ODR) that occurs when + /// the top level integral_limits classes are specialised. This issue currently seems + /// to only be apparent for GCC/C++14. + /// In C++17 and above this is not necessary, as the inline keyword may be used. + /// At the time of writing, the ETL is generally aimed to be compatible with C++98 and above. + //***************************************************************************** + + //********************************* + // signed char + template + struct statics_signed_char + { + typedef signed char value_type; + + 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; + }; + + template + ETL_CONSTANT signed char statics_signed_char::min; + + template + ETL_CONSTANT signed char statics_signed_char::max; + + template + ETL_CONSTANT int statics_signed_char::bits; + + template + ETL_CONSTANT bool statics_signed_char::is_signed; + + //*********************************** + // unsigned char + template + struct statics_unsigned_char + { + typedef unsigned char value_type; + + 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; + }; + + template + ETL_CONSTANT unsigned char statics_unsigned_char::min; + + template + ETL_CONSTANT unsigned char statics_unsigned_char::max; + + template + ETL_CONSTANT int statics_unsigned_char::bits; + + template + ETL_CONSTANT bool statics_unsigned_char::is_signed; + + //*********************************** + // char + template + struct statics_char + { + typedef char value_type; + + static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT char statics_char::min; + + template + ETL_CONSTANT char statics_char::max; + + template + ETL_CONSTANT int statics_char::bits; + + template + ETL_CONSTANT bool statics_char::is_signed; + + //*********************************** + // wchar_t + template + struct statics_wchar_t + { + typedef wchar_t value_type; + + static ETL_CONSTANT wchar_t min = WCHAR_MIN; + static ETL_CONSTANT wchar_t max = WCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * sizeof(wchar_t); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT wchar_t statics_wchar_t::min; + + template + ETL_CONSTANT wchar_t statics_wchar_t::max; + + template + ETL_CONSTANT int statics_wchar_t::bits; + + template + ETL_CONSTANT bool statics_wchar_t::is_signed; + + //*********************************** + // short +#if defined(ETL_COMPILER_MICROSOFT) + #pragma warning(push) + #pragma warning(disable : 4309) +#endif + + template + struct statics_short + { + typedef short value_type; + + 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; + }; + + template + ETL_CONSTANT short statics_short::min; + + template + ETL_CONSTANT short statics_short::max; + + template + ETL_CONSTANT int statics_short::bits; + + template + ETL_CONSTANT bool statics_short::is_signed; + +#if defined(ETL_COMPILER_MICROSOFT) + #pragma warning(pop) +#endif + + //*********************************** + // unsigned short + template + struct statics_unsigned_short + { + typedef unsigned short value_type; + + 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; + }; + + template + ETL_CONSTANT unsigned short statics_unsigned_short::min; + + template + ETL_CONSTANT unsigned short statics_unsigned_short::max; + + template + ETL_CONSTANT int statics_unsigned_short::bits; + + template + ETL_CONSTANT bool statics_unsigned_short::is_signed; + + //*********************************** + // int + template + struct statics_int + { + typedef int value_type; + + 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; + }; + + template + ETL_CONSTANT int statics_int::min; + + template + ETL_CONSTANT int statics_int::max; + + template + ETL_CONSTANT int statics_int::bits; + + template + ETL_CONSTANT bool statics_int::is_signed; + + //*********************************** + // unsigned int + template + struct statics_unsigned_int + { + typedef unsigned int value_type; + + 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; + }; + + template + ETL_CONSTANT unsigned int statics_unsigned_int::min; + + template + ETL_CONSTANT unsigned int statics_unsigned_int::max; + + template + ETL_CONSTANT int statics_unsigned_int::bits; + + template + ETL_CONSTANT bool statics_unsigned_int::is_signed; + + //*********************************** + // long + template + struct statics_long + { + typedef long value_type; + + 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; + }; + + template + ETL_CONSTANT long statics_long::min; + + template + ETL_CONSTANT long statics_long::max; + + template + ETL_CONSTANT int statics_long::bits; + + template + ETL_CONSTANT bool statics_long::is_signed; + + //*********************************** + // unsigned long + template + struct statics_unsigned_long + { + typedef unsigned long value_type; + + 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; + }; + + template + ETL_CONSTANT unsigned long statics_unsigned_long::min; + + template + ETL_CONSTANT unsigned long statics_unsigned_long::max; + + template + ETL_CONSTANT int statics_unsigned_long::bits; + + template + ETL_CONSTANT bool statics_unsigned_long::is_signed; + + //*********************************** + // long long + template + struct statics_long_long + { + typedef long long value_type; + + 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; + }; + + template + ETL_CONSTANT long long statics_long_long::min; + + template + ETL_CONSTANT long long statics_long_long::max; + + template + ETL_CONSTANT int statics_long_long::bits; + + template + ETL_CONSTANT bool statics_long_long::is_signed; + + //*********************************** + // unsigned long long + template + struct statics_unsigned_long_long + { + typedef unsigned long value_type; + + 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; + }; + + template + ETL_CONSTANT unsigned long long statics_unsigned_long_long::min; + + template + ETL_CONSTANT unsigned long long statics_unsigned_long_long::max; + + template + ETL_CONSTANT int statics_unsigned_long_long::bits; + + template + ETL_CONSTANT bool statics_unsigned_long_long::is_signed; + +#if ETL_HAS_NATIVE_CHAR8_T + //*********************************** + // char8_t + template + struct statics_char8_t + { + typedef char8_t value_type; + + static ETL_CONSTANT char8_t min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char8_t max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT char8_t statics_char8_t::min; + + template + ETL_CONSTANT char8_t statics_char8_t::max; + + template + ETL_CONSTANT int statics_char8_t::bits; + + template + ETL_CONSTANT bool statics_char8_t::is_signed; +#endif + +#if ETL_HAS_NATIVE_CHAR16_T + //*********************************** + // char16_t + template + struct statics_char16_t + { + typedef char16_t value_type; + + static ETL_CONSTANT char16_t min = 0; + static ETL_CONSTANT char16_t max = 0xFFFFU; + static ETL_CONSTANT int bits = 16; + static ETL_CONSTANT bool is_signed = false; + }; + + template + ETL_CONSTANT char16_t statics_char16_t::min; + + template + ETL_CONSTANT char16_t statics_char16_t::max; + + template + ETL_CONSTANT int statics_char16_t::bits; + + template + ETL_CONSTANT bool statics_char16_t::is_signed; +#endif + +#if ETL_HAS_NATIVE_CHAR32_T + //*********************************** + // char32_t + template + struct statics_char32_t + { + typedef char32_t value_type; + + static ETL_CONSTANT char32_t min = 0; + static ETL_CONSTANT char32_t max = 0xFFFFFFFFU; + static ETL_CONSTANT int bits = 32; + static ETL_CONSTANT bool is_signed = false; + }; + + template + ETL_CONSTANT char32_t statics_char32_t::min; + + template + ETL_CONSTANT char32_t statics_char32_t::max; + + template + ETL_CONSTANT int statics_char32_t::bits; + + template + ETL_CONSTANT bool statics_char32_t::is_signed; +#endif + } + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** @@ -57,249 +471,91 @@ namespace etl ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_signed_char<> { - typedef void value_type; - - 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; }; - ETL_CONSTANT int integral_limits::min; - ETL_CONSTANT int integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_char<> { - typedef signed char value_type; - - 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; }; - ETL_CONSTANT signed char integral_limits::min; - ETL_CONSTANT signed char integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** + template <> - struct integral_limits - { - typedef unsigned char value_type; - - 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; - }; - - ETL_CONSTANT unsigned char integral_limits::min; - ETL_CONSTANT unsigned char integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - - //*************************************************************************** - ///\ingroup integral_limits - //*************************************************************************** -#if defined(ETL_COMPILER_MICROSOFT) - #pragma warning(push) - #pragma warning(disable : 4309) -#endif - template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_char<> { typedef char value_type; - - static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; - static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); - static ETL_CONSTANT int bits = CHAR_BIT; - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; - ETL_CONSTANT char integral_limits::min; - ETL_CONSTANT char integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - -#if defined(ETL_COMPILER_MICROSOFT) - #pragma warning(pop) -#endif - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_short<> { - typedef short value_type; - - 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; }; - ETL_CONSTANT short integral_limits::min; - ETL_CONSTANT short integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_short<> { - typedef unsigned short value_type; - - 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; }; - ETL_CONSTANT unsigned short integral_limits::min; - ETL_CONSTANT unsigned short integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_int<> { - typedef int value_type; - - 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; }; - ETL_CONSTANT int integral_limits::min; - ETL_CONSTANT int integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_int<> { - typedef unsigned int value_type; - - 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; }; - ETL_CONSTANT unsigned int integral_limits::min; - ETL_CONSTANT unsigned int integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_long<> { - typedef long value_type; - - 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; }; - ETL_CONSTANT long integral_limits::min; - ETL_CONSTANT long integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_long<> { - typedef unsigned long value_type; - - 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; }; - ETL_CONSTANT unsigned long integral_limits::min; - ETL_CONSTANT unsigned long integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - -#ifndef LLONG_MAX -#define LLONG_MAX 9223372036854775807LL -#endif - -#ifndef LLONG_MIN -#define LLONG_MIN (-LLONG_MAX - 1LL) -#endif - -#ifndef ULLONG_MAX -#define ULLONG_MAX 18446744073709551615ULL -#endif - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits - { - typedef long long value_type; - - 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; + struct integral_limits : public private_integral_limits::statics_long_long<> + { }; - ETL_CONSTANT long long integral_limits::min; - ETL_CONSTANT long long integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; - //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_long_long<> { - typedef unsigned long long value_type; - - 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; }; - - ETL_CONSTANT unsigned long long integral_limits::min; - ETL_CONSTANT unsigned long long integral_limits::max; - ETL_CONSTANT int integral_limits::bits; - ETL_CONSTANT bool integral_limits::is_signed; } #include "private/minmax_pop.h" diff --git a/include/etl/limits.h b/include/etl/limits.h index 1aced396..ae54da04 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -115,155 +115,644 @@ namespace etl denorm_present = 1 }; - template - class etl_integral_limits + namespace private_limits { - public: + //********************************* + // Integral limits common + template + class integral_limits_common + { + public: - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_integer = true; - static ETL_CONSTANT bool is_exact = true; - static ETL_CONSTANT int max_digits10 = 0; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT int min_exponent = 0; - static ETL_CONSTANT int min_exponent10 = 0; - static ETL_CONSTANT int max_exponent = 0; - static ETL_CONSTANT int max_exponent10 = 0; - static ETL_CONSTANT bool has_infinity = false; - static ETL_CONSTANT bool has_quiet_NaN = false; - static ETL_CONSTANT bool has_signaling_NaN = false; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; - static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent; - static ETL_CONSTANT float_round_style round_style = round_toward_zero; - }; + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_integer = true; + static ETL_CONSTANT bool is_exact = true; + static ETL_CONSTANT int max_digits10 = 0; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT int min_exponent = 0; + static ETL_CONSTANT int min_exponent10 = 0; + static ETL_CONSTANT int max_exponent = 0; + static ETL_CONSTANT int max_exponent10 = 0; + static ETL_CONSTANT bool has_infinity = false; + static ETL_CONSTANT bool has_quiet_NaN = false; + static ETL_CONSTANT bool has_signaling_NaN = false; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent; + static ETL_CONSTANT float_round_style round_style = round_toward_zero; + }; - template - ETL_CONSTANT bool etl_integral_limits::is_specialized; + template + ETL_CONSTANT bool integral_limits_common::is_specialized; - template - ETL_CONSTANT bool etl_integral_limits::is_integer; + template + ETL_CONSTANT bool integral_limits_common::is_integer; - template - ETL_CONSTANT bool etl_integral_limits::is_exact; + template + ETL_CONSTANT bool integral_limits_common::is_exact; - template - ETL_CONSTANT int etl_integral_limits::max_digits10; + template + ETL_CONSTANT int integral_limits_common::max_digits10; - template - ETL_CONSTANT int etl_integral_limits::radix; + template + ETL_CONSTANT int integral_limits_common::radix; - template - ETL_CONSTANT int etl_integral_limits::min_exponent; + template + ETL_CONSTANT int integral_limits_common::min_exponent; - template - ETL_CONSTANT int etl_integral_limits::min_exponent10; + template + ETL_CONSTANT int integral_limits_common::min_exponent10; - template - ETL_CONSTANT int etl_integral_limits::max_exponent; + template + ETL_CONSTANT int integral_limits_common::max_exponent; - template - ETL_CONSTANT int etl_integral_limits::max_exponent10; + template + ETL_CONSTANT int integral_limits_common::max_exponent10; - template - ETL_CONSTANT bool etl_integral_limits::has_infinity; + template + ETL_CONSTANT bool integral_limits_common::has_infinity; - template - ETL_CONSTANT bool etl_integral_limits::has_quiet_NaN; + template + ETL_CONSTANT bool integral_limits_common::has_quiet_NaN; - template - ETL_CONSTANT bool etl_integral_limits::has_signaling_NaN; + template + ETL_CONSTANT bool integral_limits_common::has_signaling_NaN; - template - ETL_CONSTANT bool etl_integral_limits::has_denorm_loss; - - template - ETL_CONSTANT bool etl_integral_limits::is_iec559; - - template - ETL_CONSTANT bool etl_integral_limits::is_bounded; - - template - ETL_CONSTANT bool etl_integral_limits::traps; - - template - ETL_CONSTANT bool etl_integral_limits::tinyness_before; + template + ETL_CONSTANT bool integral_limits_common::has_denorm_loss; - template - ETL_CONSTANT float_denorm_style etl_integral_limits::has_denorm; - - template - ETL_CONSTANT float_round_style etl_integral_limits::round_style; + template + ETL_CONSTANT bool integral_limits_common::is_iec559; - template - class etl_floating_point_limits - { - public: + template + ETL_CONSTANT bool integral_limits_common::is_bounded; - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_integer = false; - static ETL_CONSTANT bool is_exact = false; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT bool has_infinity = true; - static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; - static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; - static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate; - static ETL_CONSTANT float_round_style round_style = round_indeterminate; + template + ETL_CONSTANT bool integral_limits_common::traps; - static float round_error() { return float(0.5); } - }; + template + ETL_CONSTANT bool integral_limits_common::tinyness_before; - template - ETL_CONSTANT bool etl_floating_point_limits::is_specialized; + template + ETL_CONSTANT float_denorm_style integral_limits_common::has_denorm; - template - ETL_CONSTANT bool etl_floating_point_limits::is_integer; + template + ETL_CONSTANT float_round_style integral_limits_common::round_style; - template - ETL_CONSTANT bool etl_floating_point_limits::is_exact; + //********************************* + // bool + template + struct integral_limits_bool + { + static ETL_CONSTANT int digits = 1; + static ETL_CONSTANT int digits10 = 0; + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = false; + }; - template - ETL_CONSTANT int etl_floating_point_limits::radix; + template + ETL_CONSTANT int integral_limits_bool::digits; - template - ETL_CONSTANT bool etl_floating_point_limits::has_infinity; + template + ETL_CONSTANT int integral_limits_bool::digits10; - template - ETL_CONSTANT bool etl_floating_point_limits::has_quiet_NaN; + template + ETL_CONSTANT bool integral_limits_bool::is_signed; - template - ETL_CONSTANT bool etl_floating_point_limits::has_signaling_NaN; + template + ETL_CONSTANT bool integral_limits_bool::is_modulo; - template - ETL_CONSTANT bool etl_floating_point_limits::has_denorm_loss; + //********************************* + // char + template + struct integral_limits_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; + }; - template - ETL_CONSTANT bool etl_floating_point_limits::is_iec559; + template + ETL_CONSTANT int integral_limits_char::digits; - template - ETL_CONSTANT bool etl_floating_point_limits::is_bounded; - - template - ETL_CONSTANT bool etl_floating_point_limits::traps; - - template - ETL_CONSTANT bool etl_floating_point_limits::tinyness_before; - - template - ETL_CONSTANT float_denorm_style etl_floating_point_limits::has_denorm; - - template - ETL_CONSTANT float_round_style etl_floating_point_limits::round_style; + template + ETL_CONSTANT int integral_limits_char::digits10; + + template + ETL_CONSTANT bool integral_limits_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_char::is_modulo; + + //********************************* + // unsigned char + template + struct integral_limits_unsigned_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_char::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_char::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_char::is_modulo; + + //********************************* + // signed char + template + struct integral_limits_signed_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_signed_char::digits; + + template + ETL_CONSTANT int integral_limits_signed_char::digits10; + + template + ETL_CONSTANT bool integral_limits_signed_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_signed_char::is_modulo; + +#if ETL_HAS_NATIVE_CHAR8_T + //********************************* + // char8_t + template + struct integral_limits_char8_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char8_t)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_char8_t::digits; + + template + ETL_CONSTANT int integral_limits_char8_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char8_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char8_t::is_modulo; +#endif + +#if ETL_HAS_NATIVE_CHAR16_T + //********************************* + // char16_t + template + struct integral_limits_char16_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_char16_t::digits; + + template + ETL_CONSTANT int integral_limits_char16_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char16_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char16_t::is_modulo; +#endif + +#if ETL_HAS_NATIVE_CHAR32_T + //********************************* + // char32_t + template + struct integral_limits_char32_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_char32_t::digits; + + template + ETL_CONSTANT int integral_limits_char32_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char32_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char32_t::is_modulo; +#endif + + //********************************* + // wchar_t + template + struct integral_limits_wchar_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; + }; + + template + ETL_CONSTANT int integral_limits_wchar_t::digits; + + template + ETL_CONSTANT int integral_limits_wchar_t::digits10; + + template + ETL_CONSTANT bool integral_limits_wchar_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_wchar_t::is_modulo; + + //********************************* + // short + template + struct integral_limits_short + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_short::digits; + + template + ETL_CONSTANT int integral_limits_short::digits10; + + template + ETL_CONSTANT bool integral_limits_short::is_signed; + + template + ETL_CONSTANT bool integral_limits_short::is_modulo; + + //********************************* + // unsigned short + template + struct integral_limits_unsigned_short + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_short::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_short::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_short::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_short::is_modulo; + + //********************************* + // int + template + struct integral_limits_int + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_int::digits; + + template + ETL_CONSTANT int integral_limits_int::digits10; + + template + ETL_CONSTANT bool integral_limits_int::is_signed; + + template + ETL_CONSTANT bool integral_limits_int::is_modulo; + + //********************************* + // unsigned int + template + struct integral_limits_unsigned_int + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_int::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_int::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_int::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_int::is_modulo; + + //********************************* + // long + template + struct integral_limits_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_long::digits; + + template + ETL_CONSTANT int integral_limits_long::digits10; + + template + ETL_CONSTANT bool integral_limits_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_long::is_modulo; + + //********************************* + // unsigned long + template + struct integral_limits_unsigned_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_long::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_long::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_long::is_modulo; + + //********************************* + // long long + template + struct integral_limits_long_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_long_long::digits; + + template + ETL_CONSTANT int integral_limits_long_long::digits10; + + template + ETL_CONSTANT bool integral_limits_long_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_long_long::is_modulo; + + //********************************* + // unsigned long long + template + struct integral_limits_unsigned_long_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_long_long::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_long_long::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_long_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_long_long::is_modulo; + + //********************************* + // Floating point limits common + template + class floating_point_limits_common + { + public: + + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_integer = false; + static ETL_CONSTANT bool is_exact = false; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT bool has_infinity = true; + static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; + static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool is_modulo = false; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate; + static ETL_CONSTANT float_round_style round_style = round_indeterminate; + + static float round_error() { return float(0.5); } + }; + + template + ETL_CONSTANT bool floating_point_limits_common::is_specialized; + + template + ETL_CONSTANT bool floating_point_limits_common::is_integer; + + template + ETL_CONSTANT bool floating_point_limits_common::is_exact; + + template + ETL_CONSTANT int floating_point_limits_common::radix; + + template + ETL_CONSTANT bool floating_point_limits_common::has_infinity; + + template + ETL_CONSTANT bool floating_point_limits_common::has_quiet_NaN; + + template + ETL_CONSTANT bool floating_point_limits_common::has_signaling_NaN; + + template + ETL_CONSTANT bool floating_point_limits_common::has_denorm_loss; + + template + ETL_CONSTANT bool floating_point_limits_common::is_iec559; + + template + ETL_CONSTANT bool floating_point_limits_common::is_bounded; + + template + ETL_CONSTANT bool floating_point_limits_common::traps; + + template + ETL_CONSTANT bool floating_point_limits_common::tinyness_before; + + template + ETL_CONSTANT float_denorm_style floating_point_limits_common::has_denorm; + + template + ETL_CONSTANT float_round_style floating_point_limits_common::round_style; + + //********************************* + // float + template + struct floating_point_limits_float + { + static ETL_CONSTANT int digits = FLT_MANT_DIG; + static ETL_CONSTANT int digits10 = FLT_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_float::digits; + + template + ETL_CONSTANT int floating_point_limits_float::digits10; + + template + ETL_CONSTANT int floating_point_limits_float::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_float::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_float::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_float::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_float::max_exponent10; + + //********************************* + // double + template + struct floating_point_limits_double + { + static ETL_CONSTANT int digits = DBL_MANT_DIG; + static ETL_CONSTANT int digits10 = DBL_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_double::digits; + + template + ETL_CONSTANT int floating_point_limits_double::digits10; + + template + ETL_CONSTANT int floating_point_limits_double::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_double::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_double::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_double::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_double::max_exponent10; + + //********************************* + // long double + template + struct floating_point_limits_long_double + { + static ETL_CONSTANT int digits = LDBL_MANT_DIG; + static ETL_CONSTANT int digits10 = LDBL_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_long_double::digits; + + template + ETL_CONSTANT int floating_point_limits_long_double::digits10; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_long_double::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_long_double::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_exponent10; + } //*************************************************************************** // Default @@ -279,18 +768,14 @@ namespace etl template class numeric_limits : public numeric_limits { }; - //*************************************************************************** + //*********************************** // bool template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_bool<> { public: - static ETL_CONSTANT int digits = 1; - static ETL_CONSTANT int digits10 = 0; - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR bool min() { return false; } static ETL_CONSTEXPR bool max() { return true; } static ETL_CONSTEXPR bool lowest() { return false; } @@ -302,23 +787,14 @@ namespace etl static ETL_CONSTEXPR bool signaling_NaN() { return false; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // char template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR char min() { return char(CHAR_MIN); } static ETL_CONSTEXPR char max() { return char(CHAR_MAX); } static ETL_CONSTEXPR char lowest() { return char(CHAR_MIN); } @@ -330,23 +806,14 @@ namespace etl static ETL_CONSTEXPR char signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // unsigned char template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned char min() { return 0U; } static ETL_CONSTEXPR unsigned char max() { return UCHAR_MAX; } static ETL_CONSTEXPR unsigned char lowest() { return 0U; } @@ -358,23 +825,14 @@ namespace etl static ETL_CONSTEXPR unsigned char signaling_NaN() { return 0U; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // signed char template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_signed_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR signed char min() { return SCHAR_MIN; } static ETL_CONSTEXPR signed char max() { return SCHAR_MAX; } static ETL_CONSTEXPR signed char lowest() { return SCHAR_MIN; } @@ -386,24 +844,15 @@ namespace etl static ETL_CONSTEXPR signed char signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - #if ETL_HAS_NATIVE_CHAR8_T //*************************************************************************** // char8_t template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char8_t<> { public: - - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char8_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = false; - + static ETL_CONSTEXPR char8_t min() { return char8_t(CHAR_MIN); } static ETL_CONSTEXPR char8_t max() { return char8_t(CHAR_MAX); } static ETL_CONSTEXPR char8_t lowest() { return char8_t(CHAR_MIN); } @@ -414,26 +863,17 @@ namespace etl static ETL_CONSTEXPR char8_t quiet_NaN() { return 0; } static ETL_CONSTEXPR char8_t signaling_NaN() { return 0; } }; - - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; #endif #if ETL_HAS_NATIVE_CHAR16_T //*************************************************************************** // char16_t template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char16_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR char16_t min() { return 0U; } static ETL_CONSTEXPR char16_t max() { return UINT_LEAST16_MAX; } static ETL_CONSTEXPR char16_t lowest() { return 0U; } @@ -444,26 +884,17 @@ namespace etl static ETL_CONSTEXPR char16_t quiet_NaN() { return 0U; } static ETL_CONSTEXPR char16_t signaling_NaN() { return 0U; } }; - - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; #endif #if ETL_HAS_NATIVE_CHAR32_T //*************************************************************************** // char32_t template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char32_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR char32_t min() { return 0U; } static ETL_CONSTEXPR char32_t max() { return UINT_LEAST32_MAX; } static ETL_CONSTEXPR char32_t lowest() { return 0U; } @@ -474,24 +905,16 @@ namespace etl static ETL_CONSTEXPR char32_t quiet_NaN() { return 0U; } static ETL_CONSTEXPR char32_t signaling_NaN() { return 0U; } }; - - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; #endif //*************************************************************************** // wchar_t template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_wchar_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; static ETL_CONSTEXPR wchar_t min() { return WCHAR_MIN; } static ETL_CONSTEXPR wchar_t max() { return WCHAR_MAX; } static ETL_CONSTEXPR wchar_t lowest() { return WCHAR_MIN; } @@ -503,23 +926,14 @@ namespace etl static ETL_CONSTEXPR wchar_t signaling_NaN() { return wchar_t(0); } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // short template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_short<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR short min() { return SHRT_MIN; } static ETL_CONSTEXPR short max() { return SHRT_MAX; } static ETL_CONSTEXPR short lowest() { return SHRT_MIN; } @@ -531,23 +945,14 @@ namespace etl static ETL_CONSTEXPR short signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // unsigned short template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_short<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned short min() { return 0U; } static ETL_CONSTEXPR unsigned short max() { return USHRT_MAX; } static ETL_CONSTEXPR unsigned short lowest() { return 0U; } @@ -559,23 +964,14 @@ namespace etl static ETL_CONSTEXPR unsigned short signaling_NaN() { return 0U; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // int template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_int<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR int min() { return INT_MIN; } static ETL_CONSTEXPR int max() { return INT_MAX; } static ETL_CONSTEXPR int lowest() { return INT_MIN; } @@ -587,23 +983,14 @@ namespace etl static ETL_CONSTEXPR int signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // unsigned int template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_int<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned int min() { return 0U; } static ETL_CONSTEXPR unsigned int max() { return UINT_MAX; } static ETL_CONSTEXPR unsigned int lowest() { return 0U; } @@ -615,23 +1002,14 @@ namespace etl static ETL_CONSTEXPR unsigned int signaling_NaN() { return 0U; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // long template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR long min() { return LONG_MIN; } static ETL_CONSTEXPR long max() { return LONG_MAX; } static ETL_CONSTEXPR long lowest() { return LONG_MIN; } @@ -643,23 +1021,14 @@ namespace etl static ETL_CONSTEXPR long signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // unsigned long template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned long min() { return 0U; } static ETL_CONSTEXPR unsigned long max() { return ULONG_MAX; } static ETL_CONSTEXPR unsigned long lowest() { return 0U; } @@ -671,23 +1040,14 @@ namespace etl static ETL_CONSTEXPR unsigned long signaling_NaN() { return 0U; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // long long template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_long_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR long long min() { return LLONG_MIN; } static ETL_CONSTEXPR long long max() { return LLONG_MAX; } static ETL_CONSTEXPR long long lowest() { return LLONG_MIN; } @@ -699,23 +1059,14 @@ namespace etl static ETL_CONSTEXPR long long signaling_NaN() { return 0; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // unsigned long long template<> - class numeric_limits : public etl_integral_limits<> + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_long_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned long long min() { return 0U; } static ETL_CONSTEXPR unsigned long long max() { return ULLONG_MAX; } static ETL_CONSTEXPR unsigned long long lowest() { return 0U; } @@ -727,15 +1078,11 @@ namespace etl static ETL_CONSTEXPR unsigned long long signaling_NaN() { return 0U; } }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT bool numeric_limits::is_signed; - ETL_CONSTANT bool numeric_limits::is_modulo; - //*************************************************************************** // float template<> - class numeric_limits : public etl_floating_point_limits<> + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_float<> { public: @@ -747,30 +1094,13 @@ namespace etl static ETL_CONSTEXPR float infinity() { return HUGE_VALF; } static float quiet_NaN() { return ETL_NANF; } static float signaling_NaN() { return ETL_NANF; } - - static ETL_CONSTANT int digits = FLT_MANT_DIG; - static ETL_CONSTANT int digits10 = FLT_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP; }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT int numeric_limits::max_digits10; - - ETL_CONSTANT int numeric_limits::min_exponent; - ETL_CONSTANT int numeric_limits::min_exponent10; - ETL_CONSTANT int numeric_limits::max_exponent; - ETL_CONSTANT int numeric_limits::max_exponent10; - //*************************************************************************** // double template<> - class numeric_limits : public etl_floating_point_limits<> + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_double<> { public: @@ -782,30 +1112,13 @@ namespace etl static ETL_CONSTEXPR double infinity() { return HUGE_VAL; } static double quiet_NaN() { return ETL_NAN; } static double signaling_NaN() { return ETL_NAN; } - - static ETL_CONSTANT int digits = DBL_MANT_DIG; - static ETL_CONSTANT int digits10 = DBL_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP; }; - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT int numeric_limits::max_digits10; - - ETL_CONSTANT int numeric_limits::min_exponent; - ETL_CONSTANT int numeric_limits::min_exponent10; - ETL_CONSTANT int numeric_limits::max_exponent; - ETL_CONSTANT int numeric_limits::max_exponent10; - //*************************************************************************** // long double template<> - class numeric_limits : public etl_floating_point_limits<> + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_long_double<> { public: @@ -817,25 +1130,7 @@ namespace etl static ETL_CONSTEXPR long double infinity() { return HUGE_VALL; } static long double quiet_NaN() { return ETL_NANL; } static long double signaling_NaN() { return ETL_NANL; } - - static ETL_CONSTANT int digits = LDBL_MANT_DIG; - static ETL_CONSTANT int digits10 = LDBL_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP; }; - - ETL_CONSTANT int numeric_limits::digits; - ETL_CONSTANT int numeric_limits::digits10; - ETL_CONSTANT int numeric_limits::max_digits10; - - ETL_CONSTANT int numeric_limits::min_exponent; - ETL_CONSTANT int numeric_limits::min_exponent10; - ETL_CONSTANT int numeric_limits::max_exponent; - ETL_CONSTANT int numeric_limits::max_exponent10; } #else @@ -860,10 +1155,15 @@ namespace etl denorm_present = std::denorm_present }; +#if ETL_USING_CPP11 + template + using numeric_limits = std::numeric_limits; +#else template class numeric_limits : public std::numeric_limits { }; +#endif } #endif diff --git a/include/etl/parameter_pack.h b/include/etl/parameter_pack.h index e5760453..7f30a82c 100644 --- a/include/etl/parameter_pack.h +++ b/include/etl/parameter_pack.h @@ -121,9 +121,19 @@ namespace etl using type_from_index_t = typename type_from_index::type; }; + //*********************************** template using parameter_pack_t = typename etl::parameter_pack::template type_from_index_t; + //*********************************** + template + constexpr size_t parameter_pack::size; + + //*********************************** + template + template + constexpr size_t parameter_pack::template index_of_type::value; + #if ETL_USING_CPP17 template inline constexpr size_t parameter_pack_v = etl::parameter_pack::template index_of_type::value; diff --git a/include/etl/private/bitset_legacy.h b/include/etl/private/bitset_legacy.h index 5d785152..e03135ce 100644 --- a/include/etl/private/bitset_legacy.h +++ b/include/etl/private/bitset_legacy.h @@ -183,6 +183,15 @@ namespace etl return p_bitset->test(position); } + //******************************* + /// Copy constructor. + //******************************* + bit_reference(const bit_reference& other) + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Assignment operator. //******************************* diff --git a/include/etl/private/bitset_new.h b/include/etl/private/bitset_new.h index 9352d2b9..2b01ecc3 100644 --- a/include/etl/private/bitset_new.h +++ b/include/etl/private/bitset_new.h @@ -810,7 +810,7 @@ namespace etl //*************************************************************************** template ::bits == Active_Bits> class bitset; @@ -819,7 +819,7 @@ namespace etl /// Just defines 'npos'. //*************************************************************************** template <> - class bitset<0U, void, true> : public bitset_constants<> + class bitset<0U, char, true> : public bitset_constants<> { }; @@ -827,7 +827,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset<0U, void, false> : public bitset_constants<> + class bitset<0U, char, false> : public bitset_constants<> { }; @@ -866,6 +866,15 @@ namespace etl friend class bitset; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -892,15 +901,6 @@ namespace etl return *this; } - //******************************* - /// Copy constructor. - //******************************* - ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT - : p_bitset(other.p_bitset) - , position(other.position) - { - } - //******************************* /// Flip the bit. //******************************* @@ -1751,6 +1751,15 @@ namespace etl friend class bitset; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -1777,15 +1786,6 @@ namespace etl return *this; } - //******************************* - /// Copy constructor. - //******************************* - ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT - : p_bitset(other.p_bitset) - , position(other.position) - { - } - //******************************* /// Flip the bit. //******************************* @@ -2448,7 +2448,7 @@ namespace etl { //*************************************************************************** template ::bits == Active_Bits> class bitset_ext; @@ -2457,7 +2457,7 @@ namespace etl /// Just defines 'npos'. //*************************************************************************** template <> - class bitset_ext<0U, void, true> : public bitset_constants<> + class bitset_ext<0U, char, true> : public bitset_constants<> { }; @@ -2465,7 +2465,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset_ext<0U, void, false> : public bitset_constants<> + class bitset_ext<0U, char, false> : public bitset_constants<> { }; @@ -2506,6 +2506,15 @@ namespace etl friend class bitset_ext; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -3381,6 +3390,15 @@ namespace etl friend class bitset_ext; + //******************************* + /// Copy constructor + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 5d344b5c..76a90c62 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -1352,10 +1352,10 @@ namespace etl /// in which every recursive instantiation of `visit_result_helper` appends /// more elements and give it a pass through `common_type_t`. //*************************************************************************** - template