From 23616de771e722394e65fbac71a297a6b1ace214 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sat, 30 Nov 2019 12:42:26 +0100 Subject: [PATCH 01/16] Add NO_STL std::reverse implementation (#174) Follows the example implementation on [1]. [1] https://en.cppreference.com/w/cpp/algorithm/reverse --- include/etl/stl/alternate/algorithm.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/etl/stl/alternate/algorithm.h b/include/etl/stl/alternate/algorithm.h index 9dc16b66..57f67402 100644 --- a/include/etl/stl/alternate/algorithm.h +++ b/include/etl/stl/alternate/algorithm.h @@ -156,6 +156,17 @@ namespace ETLSTD return de; } + //*************************************************************************** + // reverse + template + void reverse(TIterator first, TIterator last) + { + while ((first != last) && (first != --last)) + { + ETLSTD::swap(*first++, *last); + } + } + //*************************************************************************** // move template From 50bc741d61daed6c993e3cda7c16dda964938d0a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Dec 2019 18:21:10 +0000 Subject: [PATCH 02/16] Merge remote-tracking branch 'origin/feature/no_stl_unit_tests' into development # Conflicts: # include/etl/stl/alternate/algorithm.h # include/etl/stl/alternate/iterator.h # include/etl/version.h # library.json # library.properties # support/Release notes.txt # test/test_no_stl_algorithm.cpp # test/test_no_stl_iterator.cpp # test/vs2017/etl.vcxproj --- .../ArmTimerCallbacks.uvoptx | 1 + .../ArmTimerCallbacks.uvprojx | 33 +- include/etl/algorithm.h | 98 ++--- include/etl/array.h | 34 +- include/etl/array_view.h | 16 +- include/etl/array_wrapper.h | 12 +- include/etl/basic_string.h | 120 +++--- include/etl/binary.h | 10 +- include/etl/bit_stream.h | 22 +- include/etl/bitset.h | 14 +- include/etl/callback_timer.h | 30 +- include/etl/char_traits.h | 6 +- include/etl/compare.h | 2 +- include/etl/container.h | 20 +- include/etl/cstring.h | 2 +- include/etl/cyclic_value.h | 8 +- include/etl/deque.h | 133 +++---- include/etl/fixed_iterator.h | 17 +- include/etl/flat_map.h | 52 +-- include/etl/flat_multimap.h | 46 +-- include/etl/flat_multiset.h | 54 +-- include/etl/flat_set.h | 58 +-- include/etl/forward_list.h | 39 +- include/etl/frame_check_sequence.h | 4 +- include/etl/function.h | 4 + include/etl/icache.h | 2 +- include/etl/indirect_vector.h | 51 +-- include/etl/intrusive_forward_list.h | 17 +- include/etl/intrusive_links.h | 65 ++-- include/etl/intrusive_list.h | 17 +- include/etl/io_port.h | 19 +- include/etl/iterator.h | 26 +- include/etl/list.h | 65 ++-- include/etl/map.h | 35 +- include/etl/memory.h | 104 +++--- include/etl/message_bus.h | 16 +- include/etl/message_timer.h | 47 ++- include/etl/multicast_delegate.h | 143 -------- include/etl/multimap.h | 29 +- include/etl/multiset.h | 26 +- include/etl/murmur3.h | 4 +- include/etl/observer.h | 12 +- include/etl/optional.h | 2 +- include/etl/pearson.h | 4 +- include/etl/platform.h | 17 +- include/etl/pool.h | 12 +- include/etl/priority_queue.h | 26 +- .../alternate => private}/choose_namespace.h | 12 +- include/etl/private/choose_pair_types.h | 45 +++ include/etl/private/choose_tag_types.h | 51 +++ include/etl/private/ivectorpointer.h | 20 +- include/etl/private/pvoidvector.h | 32 +- include/etl/private/to_string_helper.h | 12 +- include/etl/profiles/armv6_no_stl.h | 2 +- include/etl/queue.h | 2 +- include/etl/queue_mpmc_mutex.h | 10 +- include/etl/queue_spsc_atomic.h | 6 +- include/etl/queue_spsc_isr.h | 8 +- include/etl/queue_spsc_locked.h | 8 +- include/etl/ratio.h | 4 +- include/etl/reference_flat_map.h | 51 +-- include/etl/reference_flat_multimap.h | 59 +-- include/etl/reference_flat_multiset.h | 56 +-- include/etl/reference_flat_set.h | 45 +-- include/etl/scheduler.h | 2 +- include/etl/set.h | 31 +- include/etl/stack.h | 4 +- include/etl/state_chart.h | 4 +- include/etl/stl/algorithm.h | 4 + include/etl/stl/alternate/algorithm.h | 287 ++++++++++----- include/etl/stl/alternate/functional.h | 10 +- include/etl/stl/alternate/iterator.h | 225 ++++++------ include/etl/stl/alternate/limits.h | 341 +++++++++--------- include/etl/stl/alternate/utility.h | 5 +- include/etl/stl/functional.h | 4 + include/etl/stl/iterator.h | 4 + include/etl/stl/limits.h | 4 + include/etl/stl/utility.h | 4 + include/etl/string_view.h | 38 +- include/etl/u16string.h | 2 +- include/etl/u32string.h | 2 +- include/etl/unordered_map.h | 31 +- include/etl/unordered_multimap.h | 27 +- include/etl/unordered_multiset.h | 29 +- include/etl/unordered_set.h | 29 +- include/etl/variant.h | 2 +- include/etl/variant_pool.h | 11 +- include/etl/variant_pool_generator.h | 2 +- include/etl/vector.h | 82 ++--- include/etl/version.h | 6 +- include/etl/wstring.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 + test/codeblocks/ETL.cbp | 23 +- test/etl_profile.h | 4 + test/no_stl_test_iterators.h | 11 +- test/test_algorithm.cpp | 16 +- test/test_deque.cpp | 2 + test/test_flat_map.cpp | 102 +++--- test/test_flat_multimap.cpp | 94 ++--- test/test_flat_multiset.cpp | 12 +- test/test_flat_set.cpp | 10 +- test/test_forward_list.cpp | 3 + test/test_forward_list_shared_pool.cpp | 4 +- test/test_indirect_vector.cpp | 2 + test/test_indirect_vector_external_buffer.cpp | 3 +- test/test_intrusive_forward_list.cpp | 1 + test/test_intrusive_list.cpp | 1 + test/test_iterator.cpp | 12 +- test/test_list.cpp | 4 +- test/test_list_shared_pool.cpp | 3 + test/test_map.cpp | 76 ++-- test/test_multimap.cpp | 192 +++++----- test/test_multiset.cpp | 14 +- test/test_no_stl_algorithm.cpp | 86 ++++- test/test_no_stl_functional.cpp | 1 + test/test_no_stl_iterator.cpp | 68 ++++ test/test_priority_queue.cpp | 8 +- test/test_queue_mpmc_mutex.cpp | 4 + test/test_queue_mpmc_mutex_small.cpp | 4 + test/test_queue_spsc_atomic.cpp | 4 + test/test_queue_spsc_atomic_small.cpp | 4 + test/test_reference_flat_map.cpp | 18 +- test/test_reference_flat_multimap.cpp | 14 +- test/test_reference_flat_multiset.cpp | 10 +- test/test_reference_flat_set.cpp | 6 +- test/test_set.cpp | 30 +- test/test_string_char.cpp | 2 + test/test_string_u16.cpp | 2 + test/test_string_u32.cpp | 2 + test/test_string_view.cpp | 2 - test/test_string_wchar_t.cpp | 2 + test/test_unordered_map.cpp | 10 +- test/test_unordered_multimap.cpp | 24 +- test/test_unordered_multiset.cpp | 4 +- test/test_variant.cpp | 4 +- test/test_vector.cpp | 2 + test/test_vector_external_buffer.cpp | 2 + test/test_vector_non_trivial.cpp | 2 + test/test_vector_pointer.cpp | 2 + test/test_vector_pointer_external_buffer.cpp | 2 + test/vs2017/etl.sln | 12 + test/vs2017/etl.vcxproj | 246 ++++++++++++- test/vs2017/etl.vcxproj.filters | 10 +- 145 files changed, 2516 insertions(+), 1858 deletions(-) delete mode 100644 include/etl/multicast_delegate.h rename include/etl/{stl/alternate => private}/choose_namespace.h (87%) create mode 100644 include/etl/private/choose_pair_types.h create mode 100644 include/etl/private/choose_tag_types.h diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx index 040f00a1..0315aa0b 100644 --- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx +++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx @@ -210,6 +210,7 @@ 1 + 0 0 2 10000000 diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx index 497bc1bd..04579270 100644 --- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx +++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx @@ -10,14 +10,14 @@ Target 1 0x4 ARM-ADS - 6090000::V6.9::.\ARMCLANG - 1 + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 STM32F401RETx STMicroelectronics - Keil.STM32F4xx_DFP.2.13.0 - http://www.keil.com/pack + Keil.STM32F4xx_DFP.2.14.0 + http://www.keil.com/pack/ IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -184,6 +184,7 @@ 0 0 2 + 0 0 0 8 @@ -422,26 +423,26 @@ - - + + - - + + - - + + - - + + @@ -450,16 +451,16 @@ RTE\Device\STM32F401RETx\startup_stm32f401xe.s - - + + RTE\Device\STM32F401RETx\system_stm32f4xx.c - - + + diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 51c46de4..7c36bd9e 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -56,7 +56,7 @@ namespace etl //*************************************************************************** template - std::pair minmax_element(TIterator begin, + ETL_PAIR minmax_element(TIterator begin, TIterator end, TCompare compare) { @@ -78,7 +78,7 @@ namespace etl ++begin; } - return std::pair(minimum, maximum); + return ETL_PAIR(minimum, maximum); } //*************************************************************************** @@ -87,12 +87,12 @@ namespace etl /// //*************************************************************************** template - std::pair minmax_element(TIterator begin, + ETL_PAIR minmax_element(TIterator begin, TIterator end) { - typedef typename std::iterator_traits::value_type value_t; + typedef typename ETL_STD::iterator_traits::value_type value_t; - return etl::minmax_element(begin, end, std::less()); + return etl::minmax_element(begin, end, ETL_STD::less()); } //*************************************************************************** @@ -101,10 +101,10 @@ namespace etl /// //*************************************************************************** template - std::pair minmax(const T& a, + ETL_PAIR minmax(const T& a, const T& b) { - return (b < a) ? std::pair(b, a) : std::pair(a, b); + return (b < a) ? ETL_PAIR(b, a) : ETL_PAIR(a, b); } //*************************************************************************** @@ -114,11 +114,11 @@ namespace etl //*************************************************************************** template - std::pair minmax(const T& a, + ETL_PAIR minmax(const T& a, const T& b, TCompare compare) { - return compare(b, a) ? std::pair(b, a) : std::pair(a, b); + return compare(b, a) ? ETL_PAIR(b, a) : ETL_PAIR(a, b); } //*************************************************************************** @@ -223,11 +223,11 @@ namespace etl TOutputIterator o_begin, TOutputIterator o_end) { - size_t s_size = std::distance(i_begin, i_end); - size_t d_size = std::distance(o_begin, o_end); + size_t s_size = ETL_STD::distance(i_begin, i_end); + size_t d_size = ETL_STD::distance(o_begin, o_end); size_t size = (s_size < d_size) ? s_size : d_size; - return std::copy(i_begin, i_begin + size, o_begin); + return ETL_STD::copy(i_begin, i_begin + size, o_begin); } //*************************************************************************** @@ -271,7 +271,7 @@ namespace etl TSize n, TOutputIterator o_begin) { - return std::copy(i_begin, i_begin + n, o_begin); + return ETL_STD::copy(i_begin, i_begin + n, o_begin); } //*************************************************************************** @@ -430,7 +430,7 @@ namespace etl TIterator end, const TValue& value) { - TIterator it = std::lower_bound(begin, end, value); + TIterator it = ETL_STD::lower_bound(begin, end, value); if ((it == end) || (*it != value)) { @@ -455,7 +455,7 @@ namespace etl TBinaryPredicate predicate, TBinaryEquality equality) { - TIterator it = std::lower_bound(begin, end, value, predicate); + TIterator it = ETL_STD::lower_bound(begin, end, value, predicate); if ((it == end) || !equality(*it, value)) { @@ -514,7 +514,7 @@ namespace etl TIterator end, TUnaryPredicate predicate) { - return std::find_if(begin, end, predicate) != end; + return ETL_STD::find_if(begin, end, predicate) != end; } //*************************************************************************** @@ -528,7 +528,7 @@ namespace etl TIterator end, TUnaryPredicate predicate) { - return std::find_if(begin, end, predicate) == end; + return ETL_STD::find_if(begin, end, predicate) == end; } //*************************************************************************** @@ -546,15 +546,15 @@ namespace etl { TIterator2 end2 = begin2; - std::advance(end2, std::distance(begin1, end1)); + ETL_STD::advance(end2, ETL_STD::distance(begin1, end1)); for (TIterator1 i = begin1; i != end1; ++i) { - if (i == std::find(begin1, i, *i)) + if (i == ETL_STD::find(begin1, i, *i)) { - size_t n = std::count(begin2, end2, *i); + size_t n = ETL_STD::count(begin2, end2, *i); - if (n == 0 || size_t(std::count(i, end1, *i)) != n) + if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n) { return false; } @@ -581,11 +581,11 @@ namespace etl { for (TIterator1 i = begin1; i != end1; ++i) { - if (i == std::find(begin1, i, *i)) + if (i == ETL_STD::find(begin1, i, *i)) { - size_t n = std::count(begin2, end2, *i); + size_t n = ETL_STD::count(begin2, end2, *i); - if (n == 0 || size_t(std::count(i, end1, *i)) != n) + if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n) { return false; } @@ -613,19 +613,19 @@ namespace etl { TIterator2 end2 = begin2; - std::advance(end2, std::distance(begin1, end1)); + ETL_STD::advance(end2, ETL_STD::distance(begin1, end1)); for (TIterator1 i = begin1; i != end1; ++i) { #if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1))) #else - if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) + if (i == ETL_STD::find_if(begin1, i, ETL_STD::bind1st(predicate, *i))) #endif { - size_t n = std::count(begin2, end2, *i); + size_t n = ETL_STD::count(begin2, end2, *i); - if (n == 0 || size_t(std::count(i, end1, *i)) != n) + if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n) { return false; } @@ -657,12 +657,12 @@ namespace etl #if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1))) #else - if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) + if (i == ETL_STD::find_if(begin1, i, ETL_STD::bind1st(predicate, *i))) #endif { - size_t n = std::count(begin2, end2, *i); + size_t n = ETL_STD::count(begin2, end2, *i); - if (n == 0 || size_t(std::count(i, end1, *i)) != n) + if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n) { return false; } @@ -737,7 +737,7 @@ namespace etl typename TDestinationTrue, typename TDestinationFalse, typename TUnaryPredicate> - std::pair partition_copy(TSource begin, + ETL_PAIR partition_copy(TSource begin, TSource end, TDestinationTrue destination_true, TDestinationFalse destination_false, @@ -755,7 +755,7 @@ namespace etl } } - return std::pair(destination_true, destination_false); + return ETL_PAIR(destination_true, destination_false); } //*************************************************************************** @@ -865,7 +865,7 @@ namespace etl TOutputIterator o_begin, TUnaryFunction function) { - std::transform(i_begin, i_begin + n, o_begin, function); + ETL_STD::transform(i_begin, i_begin + n, o_begin, function); } //*************************************************************************** @@ -887,7 +887,7 @@ namespace etl TOutputIterator o_begin, TBinaryFunction function) { - std::transform(i_begin1, i_begin1 + n, i_begin2, o_begin, function); + ETL_STD::transform(i_begin1, i_begin1 + n, i_begin2, o_begin, function); } //*************************************************************************** @@ -1063,7 +1063,7 @@ namespace etl template - std::pair partition_transform(TSource begin, + ETL_PAIR partition_transform(TSource begin, TSource end, TDestinationTrue destination_true, TDestinationFalse destination_false, @@ -1083,7 +1083,7 @@ namespace etl } } - return std::pair(destination_true, destination_false); + return ETL_PAIR(destination_true, destination_false); } //*************************************************************************** @@ -1098,7 +1098,7 @@ namespace etl typename TBinaryFunctionTrue, typename TBinaryFunctionFalse, typename TBinaryPredicate> - std::pair partition_transform(TSource1 begin1, + ETL_PAIR partition_transform(TSource1 begin1, TSource1 end1, TSource2 begin2, TDestinationTrue destination_true, @@ -1119,7 +1119,7 @@ namespace etl } } - return std::pair(destination_true, destination_false); + return ETL_PAIR(destination_true, destination_false); } //*************************************************************************** @@ -1135,9 +1135,9 @@ namespace etl return; } - typedef typename std::iterator_traits::difference_type difference_t; + typedef typename ETL_STD::iterator_traits::difference_type difference_t; - difference_t n = std::distance(first, last); + difference_t n = ETL_STD::distance(first, last); for (difference_t i = n / 2; i > 0; i /= 2) { @@ -1148,12 +1148,12 @@ namespace etl TIterator itr1 = first; TIterator itr2 = first; - std::advance(itr1, k); - std::advance(itr2, k + i); + ETL_STD::advance(itr1, k); + ETL_STD::advance(itr2, k + i); if (compare(*itr2, *itr1)) { - std::iter_swap(itr1, itr2); + ETL_STD::iter_swap(itr1, itr2); } } } @@ -1167,7 +1167,7 @@ namespace etl template void shell_sort(TIterator first, TIterator last) { - etl::shell_sort(first, last, std::less::value_type>()); + etl::shell_sort(first, last, ETL_STD::less::value_type>()); } //*************************************************************************** @@ -1180,7 +1180,7 @@ namespace etl { for (TIterator itr = first; itr != last; ++itr) { - std::rotate(std::upper_bound(first, itr, *itr, compare), itr, std::next(itr)); + ETL_STD::rotate(ETL_STD::upper_bound(first, itr, *itr, compare), itr, ETL_STD::next(itr)); } } @@ -1191,7 +1191,7 @@ namespace etl template void insertion_sort(TIterator first, TIterator last) { - etl::insertion_sort(first, last, std::less::value_type>()); + etl::insertion_sort(first, last, ETL_STD::less::value_type>()); } //*************************************************************************** @@ -1212,7 +1212,7 @@ namespace etl template void sort(TIterator first, TIterator last) { - etl::shell_sort(first, last, std::less::value_type>()); + etl::shell_sort(first, last, ETL_STD::less::value_type>()); } //*************************************************************************** @@ -1235,7 +1235,7 @@ namespace etl template void stable_sort(TIterator first, TIterator last) { - etl::insertion_sort(first, last, std::less::value_type>()); + etl::insertion_sort(first, last, ETL_STD::less::value_type>()); } #if ETL_CPP11_SUPPORTED diff --git a/include/etl/array.h b/include/etl/array.h index 2c0e854d..748bfef4 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -107,8 +107,8 @@ namespace etl typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* // Element access @@ -342,7 +342,7 @@ namespace etl //************************************************************************* void fill(parameter_t value) { - std::fill(begin(), end(), value); + ETL_STD::fill(begin(), end(), value); } //************************************************************************* @@ -353,7 +353,7 @@ namespace etl { for (size_t i = 0; i < SIZE; ++i) { - std::swap(_buffer[i], other._buffer[i]); + ETL_STD::swap(_buffer[i], other._buffer[i]); } } @@ -384,7 +384,7 @@ namespace etl iterator p = etl::copy(first, last, begin(), end()); // Default initialise any that are left. - std::fill(p, end(), value); + ETL_STD::fill(p, end(), value); } //************************************************************************* @@ -406,7 +406,7 @@ namespace etl { iterator p = const_cast(position); - std::copy_backward(p, end() - 1, end()); + ETL_STD::copy_backward(p, end() - 1, end()); *p = value; return p; @@ -436,14 +436,14 @@ namespace etl iterator p = const_cast(position); iterator result(p); - size_t source_size = std::distance(first, last); - size_t destination_space = std::distance(position, cend()); + size_t source_size = ETL_STD::distance(first, last); + size_t destination_space = ETL_STD::distance(position, cend()); // Do we need to move anything? if (source_size < destination_space) { - size_t length = SIZE - (std::distance(begin(), p) + source_size); - std::copy_backward(p, p + length, end()); + size_t length = SIZE - (ETL_STD::distance(begin(), p) + source_size); + ETL_STD::copy_backward(p, p + length, end()); } // Copy from the range. @@ -470,7 +470,7 @@ namespace etl iterator erase(const_iterator position) { iterator p = const_cast(position); - std::copy(p + 1, end(), p); + ETL_STD::copy(p + 1, end(), p); return p; } @@ -495,7 +495,7 @@ namespace etl iterator erase(const_iterator first, const_iterator last) { iterator p = const_cast(first); - std::copy(last, cend(), p); + ETL_STD::copy(last, cend(), p); return p; } @@ -518,7 +518,7 @@ namespace etl { iterator p = const_cast(position); - std::copy(p + 1, end(), p); + ETL_STD::copy(p + 1, end(), p); back() = value; return p; @@ -544,8 +544,8 @@ namespace etl { iterator p = const_cast(first); - p = std::copy(last, cend(), p); - std::fill(p, end(), value); + p = ETL_STD::copy(last, cend(), p); + ETL_STD::fill(p, end(), value); return const_cast(first); } @@ -574,7 +574,7 @@ namespace etl template bool operator ==(const etl::array& lhs, const etl::array& rhs) { - return std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()); + return ETL_STD::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()); } //************************************************************************* @@ -598,7 +598,7 @@ namespace etl template bool operator <(const etl::array& lhs, const etl::array& rhs) { - return std::lexicographical_compare(lhs.cbegin(), + return ETL_STD::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend()); diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 52f99a4c..1187e531 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -108,8 +108,8 @@ namespace etl typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Default constructor. @@ -137,7 +137,7 @@ namespace etl template ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) : mbegin(etl::addressof(*begin_)), - mend(etl::addressof(*begin_) + std::distance(begin_, end_)) + mend(etl::addressof(*begin_) + ETL_STD::distance(begin_, end_)) { } @@ -356,7 +356,7 @@ namespace etl void assign(const TIterator begin_, const TIterator end_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + std::distance(begin_, end_); + mend = etl::addressof(*begin_) + ETL_STD::distance(begin_, end_); } //************************************************************************* @@ -411,8 +411,8 @@ namespace etl //************************************************************************* void swap(array_view& other) { - std::swap(mbegin, other.mbegin); - std::swap(mend, other.mend); + ETL_STD::swap(mbegin, other.mbegin); + ETL_STD::swap(mend, other.mend); } //************************************************************************* @@ -437,7 +437,7 @@ namespace etl friend bool operator == (const array_view& lhs, const array_view& rhs) { return (lhs.size() == rhs.size()) && - std::equal(lhs.begin(), lhs.end(), rhs.begin()); + ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //************************************************************************* @@ -453,7 +453,7 @@ namespace etl //************************************************************************* friend bool operator < (const array_view& lhs, const array_view& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //************************************************************************* diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index f299a442..ab64120c 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -93,8 +93,8 @@ namespace etl typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef typename etl::parameter_type::type parameter_t; @@ -310,7 +310,7 @@ namespace etl //************************************************************************* void fill(parameter_t value) { - std::fill(begin(), end(), value); + ETL_STD::fill(begin(), end(), value); } //************************************************************************* @@ -322,7 +322,7 @@ namespace etl { for (size_t i = 0; i < SIZE; ++i) { - std::swap(ARRAY_[i], other.begin()[i]); + ETL_STD::swap(ARRAY_[i], other.begin()[i]); } } }; @@ -334,7 +334,7 @@ namespace etl bool operator == (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { - return (SIZEL == SIZER) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (SIZEL == SIZER) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //************************************************************************* @@ -354,7 +354,7 @@ namespace etl bool operator < (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //************************************************************************* diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 5d23ed84..c61da3a4 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -282,11 +282,11 @@ namespace etl typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef size_t size_type; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the string. @@ -418,12 +418,12 @@ namespace etl is_truncated = true; } - new_size = std::min(new_size, CAPACITY); + new_size = ETL_STD::min(new_size, CAPACITY); // Size up? if (new_size > current_size) { - std::fill(p_buffer + current_size, p_buffer + new_size, value); + ETL_STD::fill(p_buffer + current_size, p_buffer + new_size, value); } current_size = new_size; @@ -596,7 +596,7 @@ namespace etl is_truncated = (length_ > CAPACITY); - length_ = std::min(length_, CAPACITY); + length_ = ETL_STD::min(length_, CAPACITY); etl::copy_n(other, length_, begin()); @@ -615,7 +615,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator)); #endif @@ -643,9 +643,9 @@ namespace etl is_truncated = (n > CAPACITY); - n = std::min(n, CAPACITY); + n = ETL_STD::min(n, CAPACITY); - std::fill_n(begin(), n, value); + ETL_STD::fill_n(begin(), n, value); current_size = n; p_buffer[current_size] = 0; } @@ -780,7 +780,7 @@ namespace etl { // Insert in the middle. ++current_size; - std::copy_backward(insert_position, end() - 1, end()); + ETL_STD::copy_backward(insert_position, end() - 1, end()); *insert_position = value; } else @@ -796,7 +796,7 @@ namespace etl if (position != end()) { // Insert in the middle. - std::copy_backward(insert_position, end() - 1, end()); + ETL_STD::copy_backward(insert_position, end() - 1, end()); *insert_position = value; } @@ -823,7 +823,7 @@ namespace etl // Quick hack, as iterators are pointers. iterator insert_position = const_cast(position); - const size_t start = std::distance(cbegin(), position); + const size_t start = ETL_STD::distance(cbegin(), position); // No effect. if (start >= CAPACITY) @@ -841,7 +841,7 @@ namespace etl } current_size = CAPACITY; - std::fill(insert_position, end(), value); + ETL_STD::fill(insert_position, end(), value); } else { @@ -850,7 +850,7 @@ namespace etl const size_t to_position = start + shift_amount; const size_t remaining_characters = current_size - start; const size_t max_shift_characters = CAPACITY - start - shift_amount; - const size_t characters_to_shift = std::min(max_shift_characters, remaining_characters); + const size_t characters_to_shift = ETL_STD::min(max_shift_characters, remaining_characters); // Will the string truncate? if ((start + shift_amount + remaining_characters) > CAPACITY) @@ -863,8 +863,8 @@ namespace etl current_size += shift_amount; } - std::copy_backward(insert_position, insert_position + characters_to_shift, begin() + to_position + characters_to_shift); - std::fill(insert_position, insert_position + shift_amount, value); + ETL_STD::copy_backward(insert_position, insert_position + characters_to_shift, begin() + to_position + characters_to_shift); + ETL_STD::fill(insert_position, insert_position + shift_amount, value); } p_buffer[current_size] = 0; @@ -885,8 +885,8 @@ namespace etl return; } - const size_t start = std::distance(begin(), position); - const size_t n = std::distance(first, last); + const size_t start = ETL_STD::distance(begin(), position); + const size_t n = ETL_STD::distance(first, last); // No effect. if (start >= CAPACITY) @@ -917,7 +917,7 @@ namespace etl const size_t to_position = start + shift_amount; const size_t remaining_characters = current_size - start; const size_t max_shift_characters = CAPACITY - start - shift_amount; - const size_t characters_to_shift = std::min(max_shift_characters, remaining_characters); + const size_t characters_to_shift = ETL_STD::min(max_shift_characters, remaining_characters); // Will the string truncate? if ((start + shift_amount + remaining_characters) > CAPACITY) @@ -930,7 +930,7 @@ namespace etl current_size += shift_amount; } - std::copy_backward(position, position + characters_to_shift, begin() + to_position + characters_to_shift); + ETL_STD::copy_backward(position, position + characters_to_shift, begin() + to_position + characters_to_shift); while (first != last) { @@ -1037,7 +1037,7 @@ namespace etl etl::ibasic_string& erase(size_t position, size_t length_ = npos) { // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); erase(begin() + position, begin() + position + length_); @@ -1051,7 +1051,7 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { - std::copy(i_element + 1, end(), i_element); + ETL_STD::copy(i_element + 1, end(), i_element); p_buffer[--current_size] = 0; return i_element; @@ -1067,8 +1067,8 @@ namespace etl //********************************************************************* iterator erase(iterator first, iterator last) { - std::copy(last, end(), first); - size_t n_delete = std::distance(first, last); + ETL_STD::copy(last, end(), first); + size_t n_delete = ETL_STD::distance(first, last); current_size -= n_delete; p_buffer[current_size] = 0; @@ -1098,7 +1098,7 @@ namespace etl is_truncated = true; } - size_t endpos = std::min(pos + len, size()); + size_t endpos = ETL_STD::min(pos + len, size()); for (size_t i = pos; i < endpos; ++i) { @@ -1120,7 +1120,7 @@ namespace etl return npos; } - const_iterator iposition = std::search(begin() + pos, end(), str.begin(), str.end()); + const_iterator iposition = ETL_STD::search(begin() + pos, end(), str.begin(), str.end()); if (iposition == end()) { @@ -1128,7 +1128,7 @@ namespace etl } else { - return std::distance(begin(), iposition); + return ETL_STD::distance(begin(), iposition); } } @@ -1146,7 +1146,7 @@ namespace etl } #endif - const_iterator iposition = std::search(begin() + pos, end(), s, s + etl::strlen(s)); + const_iterator iposition = ETL_STD::search(begin() + pos, end(), s, s + etl::strlen(s)); if (iposition == end()) { @@ -1154,7 +1154,7 @@ namespace etl } else { - return std::distance(begin(), iposition); + return ETL_STD::distance(begin(), iposition); } } @@ -1173,7 +1173,7 @@ namespace etl } #endif - const_iterator iposition = std::search(begin() + pos, end(), s, s + n); + const_iterator iposition = ETL_STD::search(begin() + pos, end(), s, s + n); if (iposition == end()) { @@ -1181,7 +1181,7 @@ namespace etl } else { - return std::distance(begin(), iposition); + return ETL_STD::distance(begin(), iposition); } } @@ -1192,11 +1192,11 @@ namespace etl //********************************************************************* size_t find(T c, size_t position = 0) const { - const_iterator i = std::find(begin() + position, end(), c); + const_iterator i = ETL_STD::find(begin() + position, end(), c); if (i != end()) { - return std::distance(begin(), i); + return ETL_STD::distance(begin(), i); } else { @@ -1223,7 +1223,7 @@ namespace etl position = size() - position; - const_reverse_iterator iposition = std::search(rbegin() + position, rend(), str.rbegin(), str.rend()); + const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), str.rbegin(), str.rend()); if (iposition == rend()) { @@ -1231,7 +1231,7 @@ namespace etl } else { - return size() - str.size() - std::distance(rbegin(), iposition); + return size() - str.size() - ETL_STD::distance(rbegin(), iposition); } } @@ -1259,7 +1259,7 @@ namespace etl const_reverse_iterator srbegin(s + len); const_reverse_iterator srend(s); - const_reverse_iterator iposition = std::search(rbegin() + position, rend(), srbegin, srend); + const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), srbegin, srend); if (iposition == rend()) { @@ -1267,7 +1267,7 @@ namespace etl } else { - return size() - len - std::distance(rbegin(), iposition); + return size() - len - ETL_STD::distance(rbegin(), iposition); } } @@ -1293,7 +1293,7 @@ namespace etl const_reverse_iterator srbegin(s + length_); const_reverse_iterator srend(s); - const_reverse_iterator iposition = std::search(rbegin() + position, rend(), srbegin, srend); + const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), srbegin, srend); if (iposition == rend()) { @@ -1301,7 +1301,7 @@ namespace etl } else { - return size() - length_ - std::distance(rbegin(), iposition); + return size() - length_ - ETL_STD::distance(rbegin(), iposition); } } @@ -1319,11 +1319,11 @@ namespace etl position = size() - position; - const_reverse_iterator i = std::find(rbegin() + position, rend(), c); + const_reverse_iterator i = ETL_STD::find(rbegin() + position, rend(), c); if (i != rend()) { - return size() - std::distance(rbegin(), i) - 1; + return size() - ETL_STD::distance(rbegin(), i) - 1; } else { @@ -1342,7 +1342,7 @@ namespace etl ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); // Erase the bit we want to replace. erase(position, length_); @@ -1388,8 +1388,8 @@ namespace etl ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds)); // Limit the lengths. - length_ = std::min(length_, size() - position); - sublength = std::min(sublength, str.size() - subposition); + length_ = ETL_STD::min(length_, size() - position); + sublength = ETL_STD::min(sublength, str.size() - subposition); // Erase the bit we want to replace. erase(position, length_); @@ -1413,7 +1413,7 @@ namespace etl ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); // Erase the bit we want to replace. erase(position, length_); @@ -1450,7 +1450,7 @@ namespace etl ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); // Erase the bit we want to replace. erase(position, length_); @@ -1487,7 +1487,7 @@ namespace etl ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); // Erase the bit we want to replace. erase(position, length_); @@ -1554,7 +1554,7 @@ namespace etl ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); // Limit the length. - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); return compare(p_buffer + position, p_buffer + position + length_, @@ -1571,8 +1571,8 @@ namespace etl ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds)); // Limit the lengths. - length_ = std::min(length_, size() - position); - sublength = std::min(sublength, str.size() - subposition); + length_ = ETL_STD::min(length_, size() - position); + sublength = ETL_STD::min(sublength, str.size() - subposition); return compare(p_buffer + position, p_buffer + position + length_, @@ -1712,7 +1712,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -1745,7 +1745,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -1869,7 +1869,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -1907,7 +1907,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -2106,7 +2106,7 @@ namespace etl template bool operator ==(const etl::ibasic_string& lhs, const etl::ibasic_string& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2119,7 +2119,7 @@ namespace etl template bool operator ==(const etl::ibasic_string& lhs, const T* rhs) { - return (lhs.size() == etl::strlen(rhs)) && std::equal(lhs.begin(), lhs.end(), rhs); + return (lhs.size() == etl::strlen(rhs)) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs); } //*************************************************************************** @@ -2132,7 +2132,7 @@ namespace etl template bool operator ==(const T* lhs, const etl::ibasic_string& rhs) { - return (rhs.size() == etl::strlen(lhs)) && std::equal(rhs.begin(), rhs.end(), lhs); + return (rhs.size() == etl::strlen(lhs)) && ETL_STD::equal(rhs.begin(), rhs.end(), lhs); } @@ -2186,7 +2186,7 @@ namespace etl template bool operator <(const etl::ibasic_string& lhs, const etl::ibasic_string& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //*************************************************************************** @@ -2199,7 +2199,7 @@ namespace etl template bool operator <(const etl::ibasic_string& lhs, const T* rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs, rhs + etl::strlen(rhs)); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs, rhs + etl::strlen(rhs)); } //*************************************************************************** @@ -2212,7 +2212,7 @@ namespace etl template bool operator <(const T* lhs, const etl::ibasic_string& rhs) { - return std::lexicographical_compare(lhs, lhs + etl::strlen(lhs), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs, lhs + etl::strlen(lhs), rhs.begin(), rhs.end()); } diff --git a/include/etl/binary.h b/include/etl/binary.h index d701f37f..104f75e6 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -238,7 +238,7 @@ namespace etl ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - ETL_STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); + ETL_STATIC_ASSERT(NBITS <= ETL_STD::numeric_limits::digits, "NBITS too large for return type"); struct S { @@ -260,8 +260,8 @@ namespace etl ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - ETL_STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); - ETL_STATIC_ASSERT(SHIFT <= std::numeric_limits::digits, "SHIFT too large"); + ETL_STATIC_ASSERT(NBITS <= ETL_STD::numeric_limits::digits, "NBITS too large for return type"); + ETL_STATIC_ASSERT(SHIFT <= ETL_STD::numeric_limits::digits, "SHIFT too large"); struct S { @@ -283,7 +283,7 @@ namespace etl ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); + ETL_ASSERT((NBITS <= ETL_STD::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); TReturn mask = TReturn(1) << (NBITS - 1); value = value & static_cast((TReturn(1) << NBITS) - 1); @@ -304,7 +304,7 @@ namespace etl ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); + ETL_ASSERT((NBITS <= ETL_STD::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); TReturn mask = TReturn(1) << (NBITS - 1); value = (value >> SHIFT) & static_cast((TReturn(1) << NBITS) - 1); diff --git a/include/etl/bit_stream.h b/include/etl/bit_stream.h index dc8a8285..36a2c0b0 100644 --- a/include/etl/bit_stream.h +++ b/include/etl/bit_stream.h @@ -68,7 +68,7 @@ namespace etl //*************************************************************************** bit_stream(char* begin_, char* end_) : pdata(reinterpret_cast(begin_)), - length(std::distance(begin_, end_)) + length(ETL_STD::distance(begin_, end_)) { restart(); } @@ -78,7 +78,7 @@ namespace etl //*************************************************************************** bit_stream(unsigned char* begin_, unsigned char* end_) : pdata(begin_), - length(std::distance(begin_, end_)) + length(ETL_STD::distance(begin_, end_)) { restart(); } @@ -128,7 +128,7 @@ namespace etl //*************************************************************************** void set_stream(char* begin_, char* end_) { - set_stream(begin_, std::distance(begin_, end_)); + set_stream(begin_, ETL_STD::distance(begin_, end_)); } //*************************************************************************** @@ -136,7 +136,7 @@ namespace etl //*************************************************************************** void set_stream(unsigned char* begin_, unsigned char* end_) { - set_stream(begin_, std::distance(begin_, end_)); + set_stream(begin_, ETL_STD::distance(begin_, end_)); } //*************************************************************************** @@ -266,7 +266,7 @@ namespace etl // Get the bits from the stream. while (width != 0) { - unsigned char mask_width = static_cast(std::min(width, bits_in_byte)); + unsigned char mask_width = static_cast(ETL_STD::min(width, bits_in_byte)); unsigned char chunk = get_chunk(mask_width); width -= mask_width; @@ -379,7 +379,7 @@ namespace etl // Send the bits to the stream. while (width != 0) { - unsigned char mask_width = static_cast(std::min(width, bits_in_byte)); + unsigned char mask_width = static_cast(ETL_STD::min(width, bits_in_byte)); width -= mask_width; uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << width; @@ -412,7 +412,7 @@ namespace etl // Send the bits to the stream. while (width != 0) { - unsigned char mask_width = static_cast(std::min(width, bits_in_byte)); + unsigned char mask_width = static_cast(ETL_STD::min(width, bits_in_byte)); width -= mask_width; uint64_t mask = ((uint64_t(1U) << mask_width) - 1U) << width; @@ -495,11 +495,11 @@ namespace etl // Network to host. if (etl::endianness::value() == etl::endian::little) { - std::reverse_copy(data, data + sizeof(T), temp); + ETL_STD::reverse_copy(data, data + sizeof(T), temp); } else { - std::copy(data, data + sizeof(T), temp); + ETL_STD::copy(data, data + sizeof(T), temp); } value = *reinterpret_cast(temp); @@ -516,11 +516,11 @@ namespace etl // Host to network. if (etl::endianness::value() == etl::endian::little) { - std::reverse_copy(pf, pf + sizeof(T), data); + ETL_STD::reverse_copy(pf, pf + sizeof(T), data); } else { - std::copy(pf, pf + sizeof(T), data); + ETL_STD::copy(pf, pf + sizeof(T), data); } } diff --git a/include/etl/bitset.h b/include/etl/bitset.h index f2fd18ac..89fdd9b9 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -312,7 +312,7 @@ namespace etl { reset(); - size_t i = std::min(NBITS, etl::strlen(text)); + size_t i = ETL_STD::min(NBITS, etl::strlen(text)); while (i > 0) { @@ -329,7 +329,7 @@ namespace etl { reset(); - size_t i = std::min(NBITS, etl::strlen(text)); + size_t i = ETL_STD::min(NBITS, etl::strlen(text)); while (i > 0) { @@ -346,7 +346,7 @@ namespace etl { reset(); - size_t i = std::min(NBITS, etl::strlen(text)); + size_t i = ETL_STD::min(NBITS, etl::strlen(text)); while (i > 0) { @@ -363,7 +363,7 @@ namespace etl { reset(); - size_t i = std::min(NBITS, etl::strlen(text)); + size_t i = ETL_STD::min(NBITS, etl::strlen(text)); while (i > 0) { @@ -380,7 +380,7 @@ namespace etl { reset(); - size_t i = std::min(NBITS, etl::strlen(text)); + size_t i = ETL_STD::min(NBITS, etl::strlen(text)); while (i > 0) { @@ -746,7 +746,7 @@ namespace etl //************************************************************************* void swap(ibitset& other) { - std::swap_ranges(pdata, pdata + SIZE, other.pdata); + ETL_STD::swap_ranges(pdata, pdata + SIZE, other.pdata); } protected: @@ -818,7 +818,7 @@ namespace etl //************************************************************************* static bool is_equal(const ibitset& lhs, const ibitset&rhs) { - return std::equal(lhs.pdata, lhs.pdata + lhs.SIZE, rhs.pdata); + return ETL_STD::equal(lhs.pdata, lhs.pdata + lhs.SIZE, rhs.pdata); } element_t TOP_MASK; diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 265c46da..282fa863 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -39,6 +39,7 @@ SOFTWARE. #include "static_assert.h" #include "timer.h" #include "atomic.h" +#include "error_handler.h" #if ETL_CPP11_SUPPORTED #include "delegate.h" @@ -47,18 +48,27 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "43" -#if !defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) - #error ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK not defined -#endif +#if defined(ETL_IN_UNIT_TEST) && defined(ETL_NO_STL) + #define ETL_DISABLE_TIMER_UPDATES + #define ETL_ENABLE_TIMER_UPDATES + #define ETL_TIMER_UPDATES_ENABLED true -#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) - #error Only define one of ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK -#endif + #undef ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK + #undef ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK +#else + #if !defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) + #error ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK not defined + #endif -#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) - #define ETL_DISABLE_TIMER_UPDATES (++process_semaphore) - #define ETL_ENABLE_TIMER_UPDATES (--process_semaphore) - #define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0) + #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) + #error Only define one of ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK + #endif + + #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) + #define ETL_DISABLE_TIMER_UPDATES (++process_semaphore) + #define ETL_ENABLE_TIMER_UPDATES (--process_semaphore) + #define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0) + #endif #endif #if defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index f6548f7e..d0004d9b 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -141,7 +141,7 @@ namespace etl { if (p != 0) { - std::fill_n(p, n, c); + ETL_STD::fill_n(p, n, c); } return p; @@ -156,9 +156,9 @@ namespace etl } else { - etl::copy_n(std::reverse_iterator(src + count), + etl::copy_n(ETL_STD::reverse_iterator(src + count), count, - std::reverse_iterator(dest + count)); + ETL_STD::reverse_iterator(dest + count)); } return dest; diff --git a/include/etl/compare.h b/include/etl/compare.h index c3aa8d18..3fbb3e9f 100644 --- a/include/etl/compare.h +++ b/include/etl/compare.h @@ -48,7 +48,7 @@ namespace etl /// Defines <=, >, >= interms of < /// Default //*************************************************************************** - template > + template > struct compare { typedef typename etl::parameter_type::type first_argument_type; diff --git a/include/etl/container.h b/include/etl/container.h index 303a97a7..dfadbb53 100644 --- a/include/etl/container.h +++ b/include/etl/container.h @@ -177,9 +177,9 @@ namespace etl ///\ingroup container //***************************************************************************** template - ETL_CONSTEXPR std::reverse_iterator rbegin(const TValue(&data)[ARRAY_SIZE]) + ETL_CONSTEXPR ETL_STD::reverse_iterator rbegin(const TValue(&data)[ARRAY_SIZE]) { - return std::reverse_iterator(&data[ARRAY_SIZE]); + return ETL_STD::reverse_iterator(&data[ARRAY_SIZE]); } //***************************************************************************** @@ -187,9 +187,9 @@ namespace etl ///\ingroup container //***************************************************************************** template - ETL_CONSTEXPR std::reverse_iterator crbegin(const TValue(&data)[ARRAY_SIZE]) + ETL_CONSTEXPR ETL_STD::reverse_iterator crbegin(const TValue(&data)[ARRAY_SIZE]) { - return std::reverse_iterator(&data[ARRAY_SIZE]); + return ETL_STD::reverse_iterator(&data[ARRAY_SIZE]); } //***************************************************************************** @@ -227,9 +227,9 @@ namespace etl ///\ingroup container //***************************************************************************** template - ETL_CONSTEXPR std::reverse_iterator rend(const TValue(&data)[ARRAY_SIZE]) + ETL_CONSTEXPR ETL_STD::reverse_iterator rend(const TValue(&data)[ARRAY_SIZE]) { - return std::reverse_iterator(&data[0]); + return ETL_STD::reverse_iterator(&data[0]); } //***************************************************************************** @@ -237,9 +237,9 @@ namespace etl ///\ingroup container //***************************************************************************** template - ETL_CONSTEXPR std::reverse_iterator crend(const TValue(&data)[ARRAY_SIZE]) + ETL_CONSTEXPR ETL_STD::reverse_iterator crend(const TValue(&data)[ARRAY_SIZE]) { - return std::reverse_iterator(&data[0]); + return ETL_STD::reverse_iterator(&data[0]); } //***************************************************************************** @@ -249,7 +249,7 @@ namespace etl template TIterator next(TIterator iterator, ptrdiff_t n = 1) { - std::advance(iterator, n); + ETL_STD::advance(iterator, n); return iterator; } @@ -260,7 +260,7 @@ namespace etl template TIterator prev(TIterator iterator, ptrdiff_t n = 1) { - std::advance(iterator, -n); + ETL_STD::advance(iterator, -n); return iterator; } diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 5e700536..1d073417 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -180,7 +180,7 @@ namespace etl { ETL_ASSERT(position < this->size(), ETL_ERROR(string_out_of_bounds)); - length_ = std::min(length_, this->size() - position); + length_ = ETL_STD::min(length_, this->size() - position); new_string.assign(buffer + position, buffer + position + length_); } diff --git a/include/etl/cyclic_value.h b/include/etl/cyclic_value.h index 1680d034..dadcb277 100644 --- a/include/etl/cyclic_value.h +++ b/include/etl/cyclic_value.h @@ -257,7 +257,7 @@ namespace etl //************************************************************************* void swap(cyclic_value& other) { - std::swap(value, other.value); + ETL_STD::swap(value, other.value); } //************************************************************************* @@ -531,9 +531,9 @@ namespace etl //************************************************************************* void swap(cyclic_value& other) { - std::swap(first_value, other.first_value); - std::swap(last_value, other.last_value); - std::swap(value, other.value); + ETL_STD::swap(first_value, other.first_value); + ETL_STD::swap(last_value, other.last_value); + ETL_STD::swap(value, other.value); } //************************************************************************* diff --git a/include/etl/deque.h b/include/etl/deque.h index d103b319..8f340ec0 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -51,6 +51,7 @@ SOFTWARE. #include "debug_count.h" #include "algorithm.h" #include "type_traits.h" +#include "iterator.h" #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include @@ -238,7 +239,7 @@ namespace etl #endif typedef T* pointer; typedef const T* const_pointer; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -255,7 +256,7 @@ namespace etl //************************************************************************* /// Iterator //************************************************************************* - struct iterator : public std::iterator + struct iterator : public etl::iterator { friend class ideque; @@ -420,7 +421,7 @@ namespace etl //*************************************************** void swap(iterator& other) { - std::swap(index, other.index); + ETL_STD::swap(index, other.index); } private: @@ -441,7 +442,7 @@ namespace etl //************************************************************************* /// Const Iterator //************************************************************************* - struct const_iterator : public std::iterator + struct const_iterator : public etl::iterator { friend class ideque; @@ -602,7 +603,7 @@ namespace etl //*************************************************** void swap(const_iterator& other) { - std::swap(index, other.index); + ETL_STD::swap(index, other.index); } private: @@ -633,8 +634,8 @@ namespace etl pointer p_buffer; }; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Assigns a range to the deque. @@ -892,13 +893,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. *--position = value; @@ -909,7 +910,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. *position = value; @@ -934,38 +935,38 @@ namespace etl if (insert_position == begin()) { - create_element_front(std::move(value)); + create_element_front(ETL_STD::move(value)); position = _begin; } else if (insert_position == end()) { - create_element_back(std::move(value)); + create_element_back(ETL_STD::move(value)); position = _end - 1; } else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. - create_element_front(std::move(*_begin)); + create_element_front(ETL_STD::move(*_begin)); // Move the values. - std::move(_begin + 1, position, _begin); + ETL_STD::move(_begin + 1, position, _begin); // Write the new value. - *--position = std::move(value); + *--position = ETL_STD::move(value); } else { // Construct the _end. - create_element_back(std::move(*(_end - 1))); + create_element_back(ETL_STD::move(*(_end - 1))); // Move the values. - std::move_backward(position, _end - 2, _end - 1); + ETL_STD::move_backward(position, _end - 2, _end - 1); // Write the new value. - *position = std::move(value); + *position = ETL_STD::move(value); } } @@ -1007,13 +1008,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. --position; @@ -1026,7 +1027,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. (*position).~T(); @@ -1034,7 +1035,7 @@ namespace etl } } - ::new (p) T(std::forward(args)...); + ::new (p) T(ETL_STD::forward(args)...); return position; } @@ -1074,13 +1075,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. --position; @@ -1093,7 +1094,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. (*position).~T(); @@ -1139,13 +1140,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. --position; @@ -1158,7 +1159,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. (*position).~T(); @@ -1204,13 +1205,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. --position; @@ -1223,7 +1224,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. (*position).~T(); @@ -1269,13 +1270,13 @@ namespace etl else { // Are we closer to the front? - if (std::distance(_begin, position) < std::distance(position, _end - 1)) + if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1)) { // Construct the _begin. create_element_front(*_begin); // Move the values. - std::copy(_begin + 1, position, _begin); + ETL_STD::copy(_begin + 1, position, _begin); // Write the new value. --position; @@ -1288,7 +1289,7 @@ namespace etl create_element_back(*(_end - 1)); // Move the values. - std::copy_backward(position, _end - 2, _end - 1); + ETL_STD::copy_backward(position, _end - 2, _end - 1); // Write the new value. (*position).~T(); @@ -1342,8 +1343,8 @@ namespace etl if (distance(_begin, insert_position) <= difference_type(current_size / 2)) { size_t n_insert = n; - size_t n_move = std::distance(begin(), position); - size_t n_create_copy = std::min(n_insert, n_move); + size_t n_move = ETL_STD::distance(begin(), position); + size_t n_create_copy = ETL_STD::min(n_insert, n_move); size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_old = n_move - n_create_copy; @@ -1371,15 +1372,15 @@ namespace etl // Copy new. to = position - n_create_copy; - std::fill_n(to, n_copy_new, value); + ETL_STD::fill_n(to, n_copy_new, value); position = _begin + n_move; } else { size_t n_insert = n; - size_t n_move = std::distance(position, end()); - size_t n_create_copy = std::min(n_insert, n_move); + size_t n_move = ETL_STD::distance(position, end()); + size_t n_create_copy = ETL_STD::min(n_insert, n_move); size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_old = n_move - n_create_copy; @@ -1399,10 +1400,10 @@ namespace etl } // Copy old. - std::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); + ETL_STD::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); // Copy new. - std::fill_n(position, n_copy_new, value); + ETL_STD::fill_n(position, n_copy_new, value); } } @@ -1422,7 +1423,7 @@ namespace etl { iterator position; - difference_type n = std::distance(range_begin, range_end); + difference_type n = ETL_STD::distance(range_begin, range_end); ETL_ASSERT((current_size + n) <= CAPACITY, ETL_ERROR(deque_full)); @@ -1450,8 +1451,8 @@ namespace etl if (distance(_begin, insert_position) < difference_type(current_size / 2)) { size_t n_insert = n; - size_t n_move = std::distance(begin(), position); - size_t n_create_copy = std::min(n_insert, n_move); + size_t n_move = ETL_STD::distance(begin(), position); + size_t n_create_copy = ETL_STD::min(n_insert, n_move); size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_old = n_move - n_create_copy; @@ -1481,8 +1482,8 @@ namespace etl else { size_t n_insert = n; - size_t n_move = std::distance(position, end()); - size_t n_create_copy = std::min(n_insert, n_move); + size_t n_move = ETL_STD::distance(position, end()); + size_t n_create_copy = ETL_STD::min(n_insert, n_move); size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_old = n_move - n_create_copy; @@ -1503,7 +1504,7 @@ namespace etl } // Copy old. - std::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); + ETL_STD::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); // Copy new. item = range_begin; @@ -1540,13 +1541,13 @@ namespace etl // Are we closer to the front? if (distance(_begin, position) < difference_type(current_size / 2)) { - std::copy_backward(_begin, position, position + 1); + ETL_STD::copy_backward(_begin, position, position + 1); destroy_element_front(); ++position; } else { - std::copy(position + 1, _end, position); + ETL_STD::copy(position + 1, _end, position); destroy_element_back(); } } @@ -1567,7 +1568,7 @@ namespace etl ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)), ETL_ERROR(deque_out_of_bounds)); // How many to erase? - size_t length = std::distance(range_begin, range_end); + size_t length = ETL_STD::distance(range_begin, range_end); // At the beginning? if (position == _begin) @@ -1596,7 +1597,7 @@ namespace etl if (distance(_begin, position) < difference_type(current_size / 2)) { // Move the items. - std::copy_backward(_begin, position, position + length); + ETL_STD::copy_backward(_begin, position, position + length); for (size_t i = 0; i < length; ++i) { @@ -1609,7 +1610,7 @@ namespace etl // Must be closer to the back. { // Move the items. - std::copy(position + length, _end, position); + ETL_STD::copy(position + length, _end, position); for (size_t i = 0; i < length; ++i) { @@ -1645,7 +1646,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(deque_full)); #endif - create_element_back(std::move(item)); + create_element_back(ETL_STD::move(item)); } #endif @@ -1661,7 +1662,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(deque_full)); #endif - ::new (&(*_end)) T(std::forward(args)...); + ::new (&(*_end)) T(ETL_STD::forward(args)...); ++_end; ++current_size; ETL_INCREMENT_DEBUG_COUNT @@ -1773,7 +1774,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(deque_full)); #endif - create_element_front(std::move(item)); + create_element_front(ETL_STD::move(item)); } #endif @@ -1790,7 +1791,7 @@ namespace etl #endif --_begin; - ::new (&(*_begin)) T(std::forward(args)...); + ::new (&(*_begin)) T(ETL_STD::forward(args)...); ++current_size; ETL_INCREMENT_DEBUG_COUNT } @@ -1964,7 +1965,7 @@ namespace etl iterator itr = rhs.begin(); while (itr != rhs.end()) { - push_back(std::move(*itr)); + push_back(ETL_STD::move(*itr)); ++itr; } @@ -2116,7 +2117,7 @@ namespace etl void create_element_front(rvalue_reference value) { --_begin; - ::new (&(*_begin)) T(std::move(value)); + ::new (&(*_begin)) T(ETL_STD::move(value)); ++current_size; ETL_INCREMENT_DEBUG_COUNT } @@ -2126,7 +2127,7 @@ namespace etl //********************************************************************* void create_element_back(rvalue_reference value) { - ::new (&(*_end)) T(std::move(value)); + ::new (&(*_end)) T(ETL_STD::move(value)); ++_end; ++current_size; ETL_INCREMENT_DEBUG_COUNT @@ -2232,7 +2233,7 @@ namespace etl typedef T& reference; typedef const T& const_reference; typedef size_t size_type; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //************************************************************************* /// Default constructor. @@ -2277,7 +2278,7 @@ namespace etl typename etl::ideque::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2341,7 +2342,7 @@ namespace etl typename etl::ideque::iterator itr = rhs.begin(); while (itr != rhs.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2361,7 +2362,7 @@ namespace etl void repair() { #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - ETL_ASSERT(std::is_trivially_copyable::value, ETL_ERROR(etl::deque_incompatible_type)); + ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::deque_incompatible_type)); #endif etl::ideque::repair_buffer(reinterpret_cast(&buffer[0])); @@ -2383,7 +2384,7 @@ namespace etl template bool operator ==(const etl::ideque& lhs, const etl::ideque& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2409,7 +2410,7 @@ namespace etl template bool operator <(const etl::ideque& lhs, const etl::ideque& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/fixed_iterator.h b/include/etl/fixed_iterator.h index f7086c34..877babb6 100644 --- a/include/etl/fixed_iterator.h +++ b/include/etl/fixed_iterator.h @@ -32,6 +32,7 @@ SOFTWARE. #define ETL_FIXED_ITERATOR_INCLUDED #include "platform.h" +#include "iterator.h" #include "stl/iterator.h" @@ -44,7 +45,7 @@ namespace etl /// This can be useful when using STL algorithms to interact with fixed memory locations such as registers. ///\ingroup iterator template - class fixed_iterator : std::iterator::iterator_category, typename std::iterator_traits::value_type> + class fixed_iterator : etl::iterator::iterator_category, typename ETL_STD::iterator_traits::value_type> { public: @@ -99,7 +100,7 @@ namespace etl //*************************************************************************** /// Dereference operator. //*************************************************************************** - typename std::iterator_traits::value_type operator *() + typename ETL_STD::iterator_traits::value_type operator *() { return *it; } @@ -107,7 +108,7 @@ namespace etl //*************************************************************************** /// Dereference operator. //*************************************************************************** - const typename std::iterator_traits::value_type operator *() const + const typename ETL_STD::iterator_traits::value_type operator *() const { return *it; } @@ -139,7 +140,7 @@ namespace etl //*************************************************************************** /// += operator. //*************************************************************************** - fixed_iterator& operator +=(typename std::iterator_traits::difference_type /*offset*/) + fixed_iterator& operator +=(typename ETL_STD::iterator_traits::difference_type /*offset*/) { return *this; } @@ -147,7 +148,7 @@ namespace etl //*************************************************************************** /// -= operator. //*************************************************************************** - fixed_iterator& operator -=(typename std::iterator_traits::difference_type /*offset*/) + fixed_iterator& operator -=(typename ETL_STD::iterator_traits::difference_type /*offset*/) { return *this; } @@ -180,7 +181,7 @@ namespace etl //***************************************************************************** template etl::fixed_iterator& operator +(etl::fixed_iterator& lhs, - typename std::iterator_traits::difference_type /*rhs*/) + typename ETL_STD::iterator_traits::difference_type /*rhs*/) { return lhs; } @@ -190,7 +191,7 @@ namespace etl //***************************************************************************** template etl::fixed_iterator& operator -(etl::fixed_iterator& lhs, - typename std::iterator_traits::difference_type /*rhs*/) + typename ETL_STD::iterator_traits::difference_type /*rhs*/) { return lhs; } @@ -199,7 +200,7 @@ namespace etl /// - fixed_iterator operator. //***************************************************************************** template - typename std::iterator_traits::difference_type operator -(etl::fixed_iterator& lhs, + typename ETL_STD::iterator_traits::difference_type operator -(etl::fixed_iterator& lhs, etl::fixed_iterator& rhs) { return TIterator(lhs) - TIterator(rhs); diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 8d1e1fc8..8375e9a9 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -60,7 +60,7 @@ namespace etl /// Can be used as a reference type for all flat_maps containing a specific type. ///\ingroup flat_map //*************************************************************************** - template > + template > class iflat_map : private etl::ireference_flat_map { private: @@ -72,7 +72,7 @@ namespace etl public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; typedef TKey key_type; typedef TMapped mapped_type; typedef TKeyCompare key_compare; @@ -85,9 +85,9 @@ namespace etl typedef typename refmap_t::iterator iterator; typedef typename refmap_t::const_iterator const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -232,7 +232,7 @@ namespace etl //********************************************************************* mapped_type& operator [](key_parameter_t key) { - return insert(std::make_pair(key, mapped_type())).first->second; + return insert(ETL_MAKE_PAIR(key, mapped_type())).first->second; } //********************************************************************* @@ -268,7 +268,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full)); #endif @@ -285,11 +285,11 @@ namespace etl /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const_reference value) + ETL_PAIR insert(const_reference value) { iterator i_element = lower_bound(value.first); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(value.first, i_element->first)) @@ -335,7 +335,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the map. //************************************************************************* - std::pair emplace(const value_type& value) + ETL_PAIR emplace(const value_type& value) { return emplace(value.first, value.second); } @@ -345,18 +345,18 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, Args && ... args) + ETL_PAIR emplace(const key_type& key, Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); // Create it. value_type* pvalue = storage.allocate(); ::new ((void*)etl::addressof(pvalue->first)) key_type(key); - ::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward(args)...); + ::new ((void*)etl::addressof(pvalue->second)) mapped_type(ETL_STD::forward(args)...); iterator i_element = lower_bound(key); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) @@ -379,7 +379,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1) + ETL_PAIR emplace(const key_type& key, const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); @@ -390,7 +390,7 @@ namespace etl iterator i_element = lower_bound(key); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) @@ -411,7 +411,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); @@ -422,7 +422,7 @@ namespace etl iterator i_element = lower_bound(key); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) @@ -443,7 +443,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); @@ -454,7 +454,7 @@ namespace etl iterator i_element = lower_bound(key); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) @@ -475,7 +475,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); @@ -486,7 +486,7 @@ namespace etl iterator i_element = lower_bound(key); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) @@ -662,7 +662,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { return refmap_t::equal_range(key); } @@ -672,7 +672,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { return refmap_t::equal_range(key); } @@ -793,7 +793,7 @@ namespace etl template bool operator ==(const etl::iflat_map& lhs, const etl::iflat_map& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -813,11 +813,11 @@ namespace etl /// A flat_map implementation that uses a fixed size buffer. ///\tparam TKey The key type. ///\tparam TValue The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup flat_map //*************************************************************************** - template > + template > class flat_map : public etl::iflat_map { public: diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index b431cb10..0069ea92 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -59,12 +59,12 @@ namespace etl /// Can be used as a reference type for all flat_multimaps containing a specific type. ///\ingroup flat_multimap //*************************************************************************** - template > + template > class iflat_multimap : public etl::ireference_flat_multimap { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; private: @@ -86,9 +86,9 @@ namespace etl typedef typename refmap_t::iterator iterator; typedef typename refmap_t::const_iterator const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -237,7 +237,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full)); #endif @@ -254,11 +254,11 @@ namespace etl /// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const value_type& value) + ETL_PAIR insert(const value_type& value) { ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_multimap_full)); - std::pair result(end(), false); + ETL_PAIR result(end(), false); iterator i_element = lower_bound(value.first); @@ -300,7 +300,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the map. //************************************************************************* - std::pair emplace(const value_type& value) + ETL_PAIR emplace(const value_type& value) { return insert(value); } @@ -308,7 +308,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the map. //************************************************************************* - std::pair emplace(const key_type& key, const mapped_type& value) + ETL_PAIR emplace(const key_type& key, const mapped_type& value) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); @@ -327,14 +327,14 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, Args && ... args) + ETL_PAIR emplace(const key_type& key, Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); // Create it. value_type* pvalue = storage.allocate(); ::new ((void*)etl::addressof(pvalue->first)) key_type(key); - ::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward(args)...); + ::new ((void*)etl::addressof(pvalue->second)) mapped_type(ETL_STD::forward(args)...); iterator i_element = lower_bound(key); ETL_INCREMENT_DEBUG_COUNT @@ -346,7 +346,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1) + ETL_PAIR emplace(const key_type& key, const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); @@ -364,7 +364,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); @@ -382,7 +382,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); @@ -400,7 +400,7 @@ namespace etl /// Emplaces a value to the map. //************************************************************************* template - std::pair emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) + ETL_PAIR emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); @@ -423,7 +423,7 @@ namespace etl //********************************************************************* size_t erase(key_parameter_t key) { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); if (range.first == end()) { @@ -431,7 +431,7 @@ namespace etl } else { - size_t d = std::distance(range.first, range.second); + size_t d = ETL_STD::distance(range.first, range.second); erase(range.first, range.second); return d; } @@ -571,7 +571,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { return refmap_t::equal_range(key); } @@ -581,7 +581,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { return refmap_t::equal_range(key); } @@ -700,7 +700,7 @@ namespace etl template bool operator ==(const etl::iflat_multimap& lhs, const etl::iflat_multimap& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -720,11 +720,11 @@ namespace etl /// A flat_multimap implementation that uses a fixed size buffer. ///\tparam TKey The key type. ///\tparam TValue The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup flat_multimap //*************************************************************************** - template > + template > class flat_multimap : public etl::iflat_multimap { public: diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 51c74f74..931f61c6 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -57,7 +57,7 @@ namespace etl /// Can be used as a reference type for all flat_multisets containing a specific type. ///\ingroup flat_multiset //*************************************************************************** - template > + template > class iflat_multiset : private etl::ireference_flat_multiset { private: @@ -80,9 +80,9 @@ namespace etl typedef typename refset_t::iterator iterator; typedef typename refset_t::const_iterator const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -209,7 +209,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full)); #endif @@ -226,13 +226,13 @@ namespace etl /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(parameter_t value) + ETL_PAIR insert(parameter_t value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); - iterator i_element = std::lower_bound(begin(), end(), value, compare); + iterator i_element = ETL_STD::lower_bound(begin(), end(), value, compare); value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); @@ -273,7 +273,7 @@ namespace etl /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(parameter_t value) + ETL_PAIR emplace(parameter_t value) { return insert(value); } @@ -283,25 +283,25 @@ namespace etl //************************************************************************* #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) template - std::pair emplace(Args && ... args) + ETL_PAIR emplace(Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); // Create it. value_type* pvalue = storage.allocate(); - ::new (pvalue) value_type(std::forward(args)...); + ::new (pvalue) value_type(ETL_STD::forward(args)...); iterator i_element = lower_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return std::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_PAIR(refset_t::insert_at(i_element, *pvalue)); } #else //************************************************************************* /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1) + ETL_PAIR emplace(const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); @@ -312,14 +312,14 @@ namespace etl iterator i_element = lower_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return std::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_PAIR(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2) + ETL_PAIR emplace(const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); @@ -330,14 +330,14 @@ namespace etl iterator i_element = lower_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return std::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_PAIR(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2, const T3& value3) + ETL_PAIR emplace(const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); @@ -348,14 +348,14 @@ namespace etl iterator i_element = lower_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return std::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_PAIR(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) + ETL_PAIR emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); @@ -366,7 +366,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return std::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_PAIR(refset_t::insert_at(i_element, *pvalue)); } #endif @@ -377,7 +377,7 @@ namespace etl //********************************************************************* size_t erase(parameter_t key) { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); if (range.first == end()) { @@ -385,7 +385,7 @@ namespace etl } else { - size_t d = std::distance(range.first, range.second); + size_t d = ETL_STD::distance(range.first, range.second); erase(range.first, range.second); return d; } @@ -525,7 +525,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) + ETL_PAIR equal_range(parameter_t key) { return refset_t::equal_range(key); } @@ -535,7 +535,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) const + ETL_PAIR equal_range(parameter_t key) const { return refset_t::equal_range(key); } @@ -656,7 +656,7 @@ namespace etl template bool operator ==(const etl::iflat_multiset& lhs, const etl::iflat_multiset& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -675,11 +675,11 @@ namespace etl //*************************************************************************** /// A flat_multiset implementation that uses a fixed size buffer. ///\tparam T The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup flat_multiset //*************************************************************************** - template > + template > class flat_multiset : public etl::iflat_multiset { public: diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 0c5f847c..9b0e2d76 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -59,7 +59,7 @@ namespace etl /// Can be used as a reference type for all flat_sets containing a specific type. ///\ingroup flat_set //*************************************************************************** - template > + template > class iflat_set : private etl::ireference_flat_set { private: @@ -82,9 +82,9 @@ namespace etl typedef typename refset_t::iterator iterator; typedef typename refset_t::const_iterator const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -211,7 +211,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full)); #endif @@ -228,11 +228,11 @@ namespace etl /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(parameter_t value) + ETL_PAIR insert(parameter_t value) { iterator i_element = lower_bound(value); - std::pair result(i_element, false); + ETL_PAIR result(i_element, false); // Doesn't already exist? if ((i_element == end()) || compare(value, *i_element)) @@ -278,7 +278,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the set. //************************************************************************* - std::pair emplace(parameter_t value) + ETL_PAIR emplace(parameter_t value) { return insert(value); } @@ -288,15 +288,15 @@ namespace etl //************************************************************************* #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) template - std::pair emplace(Args && ... args) + ETL_PAIR emplace(Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); - std::pair result; + ETL_PAIR result; // Create it. value_type* pvalue = storage.allocate(); - ::new (pvalue) value_type(std::forward(args)...); + ::new (pvalue) value_type(ETL_STD::forward(args)...); iterator i_element = lower_bound(*pvalue); @@ -311,7 +311,7 @@ namespace etl // Destroy it. pvalue->~value_type(); storage.release(pvalue); - result = std::pair(end(), false); + result = ETL_PAIR(end(), false); } return result; @@ -321,11 +321,11 @@ namespace etl /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1) + ETL_PAIR emplace(const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); - std::pair result; + ETL_PAIR result; // Create it. value_type* pvalue = storage.allocate(); @@ -344,7 +344,7 @@ namespace etl // Destroy it. pvalue->~value_type(); storage.release(pvalue); - result = std::pair(end(), false); + result = ETL_PAIR(end(), false); } return result; @@ -354,11 +354,11 @@ namespace etl /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2) + ETL_PAIR emplace(const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); - std::pair result; + ETL_PAIR result; // Create it. value_type* pvalue = storage.allocate(); @@ -377,7 +377,7 @@ namespace etl // Destroy it. pvalue->~value_type(); storage.release(pvalue); - result = std::pair(end(), false); + result = ETL_PAIR(end(), false); } return result; @@ -387,11 +387,11 @@ namespace etl /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2, const T3& value3) + ETL_PAIR emplace(const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); - std::pair result; + ETL_PAIR result; // Create it. value_type* pvalue = storage.allocate(); @@ -410,7 +410,7 @@ namespace etl // Destroy it. pvalue->~value_type(); storage.release(pvalue); - result = std::pair(end(), false); + result = ETL_PAIR(end(), false); } return result; @@ -420,11 +420,11 @@ namespace etl /// Emplaces a value to the set. //************************************************************************* template - std::pair emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) + ETL_PAIR emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); - std::pair result; + ETL_PAIR result; // Create it. value_type* pvalue = storage.allocate(); @@ -443,7 +443,7 @@ namespace etl // Destroy it. pvalue->~value_type(); storage.release(pvalue); - result = std::pair(end(), false); + result = ETL_PAIR(end(), false); } return result; @@ -608,7 +608,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) + ETL_PAIR equal_range(parameter_t key) { return refset_t::equal_range(key); } @@ -618,7 +618,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) const + ETL_PAIR equal_range(parameter_t key) const { return refset_t::upper_bound(key); } @@ -739,7 +739,7 @@ namespace etl template bool operator ==(const etl::iflat_set& lhs, const etl::iflat_set& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -758,11 +758,11 @@ namespace etl //*************************************************************************** /// A flat_set implementation that uses a fixed size buffer. ///\tparam T The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup flat_set //*************************************************************************** - template > + template > class flat_set : public etl::iflat_set { public: diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index db4e649b..76e03ac8 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -50,6 +50,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" #include "memory.h" +#include "iterator.h" #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include @@ -403,7 +404,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -491,7 +492,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -571,7 +572,7 @@ namespace etl const node_t* p_node; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //************************************************************************* /// Gets the beginning of the forward_list. @@ -670,7 +671,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(forward_list_iterator)); #endif @@ -734,7 +735,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); #endif - data_node_t& data_node = allocate_data_node(std::move(value)); + data_node_t& data_node = allocate_data_node(ETL_STD::move(value)); insert_node_after(start_node, data_node); } #endif @@ -750,7 +751,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); #endif data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::forward(args)...); + ::new (&(p_data_node->value)) T(ETL_STD::forward(args)...); ETL_INCREMENT_DEBUG_COUNT insert_node_after(start_node, *p_data_node); } @@ -906,7 +907,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::forward(args)...); + ::new (&(p_data_node->value)) T(ETL_STD::forward(args)...); ETL_INCREMENT_DEBUG_COUNT insert_node_after(*position.p_node, *p_data_node); @@ -1000,7 +1001,7 @@ namespace etl void insert_after(iterator position, TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT((d + size()) <= MAX_SIZE, ETL_ERROR(forward_list_full)); #endif @@ -1140,7 +1141,7 @@ namespace etl //************************************************************************* void unique() { - unique(std::equal_to()); + unique(ETL_STD::equal_to()); } //************************************************************************* @@ -1181,7 +1182,7 @@ namespace etl //************************************************************************* void sort() { - sort(std::less()); + sort(ETL_STD::less()); } //************************************************************************* @@ -1385,7 +1386,7 @@ namespace etl //************************************************************************* iforward_list& operator = (iforward_list&& rhs) { - move_container(std::move(rhs)); + move_container(ETL_STD::move(rhs)); return *this; } @@ -1459,7 +1460,7 @@ namespace etl data_node_t& allocate_data_node(rvalue_reference value) { data_node_t* p_node = p_node_pool->allocate(); - ::new (&(p_node->value)) T(std::move(value)); + ::new (&(p_node->value)) T(ETL_STD::move(value)); ETL_INCREMENT_DEBUG_COUNT return *p_node; @@ -1486,7 +1487,7 @@ namespace etl { ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); - data_node_t& data_node = this->allocate_data_node(std::move(*first++)); + data_node_t& data_node = this->allocate_data_node(ETL_STD::move(*first++)); join(p_last_node, &data_node); data_node.next = nullptr; p_last_node = &data_node; @@ -1632,7 +1633,7 @@ namespace etl forward_list(forward_list&& other) : etl::iforward_list(node_pool, MAX_SIZE, false) { - this->move_container(std::move(other)); + this->move_container(ETL_STD::move(other)); } #endif @@ -1685,7 +1686,7 @@ namespace etl forward_list& operator = (forward_list&& rhs) { - this->move_container(std::move(rhs)); + this->move_container(ETL_STD::move(rhs)); return *this; } @@ -1773,7 +1774,7 @@ namespace etl typename etl::iforward_list::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -1830,7 +1831,7 @@ namespace etl //************************************************************************* forward_list& operator = (forward_list&& rhs) { - this->move_container(std::move(rhs)); + this->move_container(ETL_STD::move(rhs)); return *this; } @@ -1861,7 +1862,7 @@ namespace etl bool operator ==(const etl::iforward_list& lhs, const etl::iforward_list& rhs) { return (lhs.size() == rhs.size()) && - std::equal(lhs.begin(), lhs.end(), rhs.begin()); + ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //************************************************************************* @@ -1886,7 +1887,7 @@ namespace etl template bool operator <(const etl::iforward_list& lhs, const etl::iforward_list& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index c3d95009..a1ed9028 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -74,7 +74,7 @@ namespace etl template frame_check_sequence(TIterator begin, const TIterator end) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Type not supported"); reset(); add(begin, end); @@ -96,7 +96,7 @@ namespace etl template void add(TIterator begin, const TIterator end) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Type not supported"); while (begin != end) { diff --git a/include/etl/function.h b/include/etl/function.h index 53568b82..51843759 100644 --- a/include/etl/function.h +++ b/include/etl/function.h @@ -56,6 +56,8 @@ namespace etl typedef TParameter parameter_type; ///< The type of parameter sent to the function. + virtual ~ifunction() {} + //************************************************************************* /// The function operator that will be overridden. //************************************************************************* @@ -73,6 +75,8 @@ namespace etl typedef void parameter_type; ///< The type of parameter sent to the function. + virtual ~ifunction() {} + //************************************************************************* /// The function operator that will be overridden. //************************************************************************* diff --git a/include/etl/icache.h b/include/etl/icache.h index 1cd6fc62..52b9995f 100644 --- a/include/etl/icache.h +++ b/include/etl/icache.h @@ -104,7 +104,7 @@ namespace etl protected: - typedef std::pair key_value_t; + typedef ETL_PAIR key_value_t; bool write_through; ///< If true, the cache should write changed items back to the store immediately. If false then a flush() or destruct will be required. diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 6fac471f..3aff627d 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "vector.h" #include "pool.h" +#include "iterator.h" #include "stl/iterator.h" #include "stl/functional.h" @@ -99,7 +100,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -237,7 +238,7 @@ namespace etl //************************************************************************* /// const_iterator. //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -362,8 +363,8 @@ namespace etl lookup_itr_t lookup_itr; }; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; protected: @@ -640,10 +641,10 @@ namespace etl template void assign(TIterator first, TIterator last) { - ETL_STATIC_ASSERT((etl::is_same::type, typename etl::remove_cv::value_type>::type>::value), "Iterator type does not match container type"); + ETL_STATIC_ASSERT((etl::is_same::type, typename etl::remove_cv::value_type>::type>::value), "Iterator type does not match container type"); #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(static_cast(d) <= capacity(), ETL_ERROR(vector_full)); #endif @@ -709,7 +710,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(size() != capacity(), ETL_ERROR(vector_full)); #endif - T* p = storage.create(std::move(value)); + T* p = storage.create(ETL_STD::move(value)); lookup.push_back(p); } #endif @@ -723,7 +724,7 @@ namespace etl template void emplace_back(Args && ... args) { - T* p = storage.create(std::forward(args)...); + T* p = storage.create(ETL_STD::forward(args)...); lookup.push_back(p); } #else @@ -815,7 +816,7 @@ namespace etl { ETL_ASSERT(size() + 1 <= capacity(), ETL_ERROR(vector_full)); - T* p = storage.create(T(std::move(value))); + T* p = storage.create(T(ETL_STD::move(value))); position = iterator(lookup.insert(position.lookup_itr, p)); return position; @@ -831,7 +832,7 @@ namespace etl { ETL_ASSERT(!full(), ETL_ERROR(vector_full)); - T* p = storage.create(T(std::forward(args)...)); + T* p = storage.create(T(ETL_STD::forward(args)...)); position = iterator(lookup.insert(position.lookup_itr, p)); return position; @@ -914,7 +915,7 @@ namespace etl template void insert(iterator position, TIterator first, TIterator last) { - size_t count = size_t(std::distance(first, last)); + size_t count = size_t(ETL_STD::distance(first, last)); ETL_ASSERT((size() + count) <= capacity(), ETL_ERROR(vector_full)); @@ -990,7 +991,7 @@ namespace etl iterator itr = rhs.begin(); while (itr != rhs.end()) { - push_back(std::move(*itr)); + push_back(ETL_STD::move(*itr)); ++itr; } @@ -1060,7 +1061,7 @@ namespace etl //************************************************************************* void sort() { - sort_function(begin(), end(), std::less()); + sort_function(begin(), end(), ETL_STD::less()); } //************************************************************************* @@ -1077,7 +1078,7 @@ namespace etl //************************************************************************* void sort(iterator first, iterator last) { - sort_function(first, last, std::less()); + sort_function(first, last, ETL_STD::less()); } //************************************************************************* @@ -1094,7 +1095,7 @@ namespace etl //************************************************************************* void stable_sort() { - stable_sort_function(begin(), end(), std::less()); + stable_sort_function(begin(), end(), ETL_STD::less()); } //************************************************************************* @@ -1111,7 +1112,7 @@ namespace etl //************************************************************************* void stable_sort(iterator first, iterator last) { - stable_sort_function(first, last, std::less()); + stable_sort_function(first, last, ETL_STD::less()); } //************************************************************************* @@ -1128,7 +1129,7 @@ namespace etl //************************************************************************* bool is_sorted() const { - return is_sorted_function(cbegin(), cend(), std::less()); + return is_sorted_function(cbegin(), cend(), ETL_STD::less()); } //************************************************************************* @@ -1145,7 +1146,7 @@ namespace etl //************************************************************************* bool is_sorted(const_iterator first, const_iterator last) const { - return is_sorted_function(first, last, std::less()); + return is_sorted_function(first, last, ETL_STD::less()); } //************************************************************************* @@ -1197,7 +1198,7 @@ namespace etl while (itr != other.end()) { - push_back(std::move(*itr)); + push_back(ETL_STD::move(*itr)); ++itr; } @@ -1286,7 +1287,7 @@ namespace etl template bool operator ==(const etl::iindirect_vector& lhs, const etl::iindirect_vector& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1312,7 +1313,7 @@ namespace etl template bool operator <(const etl::iindirect_vector& lhs, const etl::iindirect_vector& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //*************************************************************************** @@ -1449,7 +1450,7 @@ namespace etl indirect_vector(indirect_vector&& other) : etl::iindirect_vector(lookup_vector, storage_pool) { - this->move_container(std::move(other)); + this->move_container(ETL_STD::move(other)); } //************************************************************************* @@ -1457,7 +1458,7 @@ namespace etl //************************************************************************* indirect_vector& operator = (indirect_vector&& rhs) { - this->move_container(std::move(rhs)); + this->move_container(ETL_STD::move(rhs)); return *this; } @@ -1577,7 +1578,7 @@ namespace etl : etl::iindirect_vector(lookup_, pool_) { ETL_ASSERT(lookup_.capacity() <= pool_.capacity(), ETL_ERROR(indirect_vector_buffer_missmatch)); - this->move_container(std::move(other)); + this->move_container(ETL_STD::move(other)); } //************************************************************************* @@ -1585,7 +1586,7 @@ namespace etl //************************************************************************* indirect_vector& operator = (indirect_vector&& rhs) { - this->move_container(std::move(rhs)); + this->move_container(ETL_STD::move(rhs)); return *this; } diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 6f1d6cc2..879865f5 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -48,6 +48,7 @@ SOFTWARE. #include "error_handler.h" #include "intrusive_links.h" #include "algorithm.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "20" @@ -152,7 +153,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - intmax_t d = std::distance(first, last); + intmax_t d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_forward_list_iterator_exception)); #endif @@ -327,7 +328,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -417,7 +418,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -494,7 +495,7 @@ namespace etl const value_type* p_value; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //************************************************************************* /// Constructor. @@ -650,7 +651,7 @@ namespace etl { if (first != end() && (first != last)) { - this->current_size -= std::distance(first, last) - 1; + this->current_size -= ETL_STD::distance(first, last) - 1; link_type* p_first = first.p_value; link_type* p_last = last.p_value; @@ -711,7 +712,7 @@ namespace etl //************************************************************************* void sort() { - sort(std::less()); + sort(ETL_STD::less()); } //************************************************************************* @@ -957,7 +958,7 @@ namespace etl { if (&other != this) { - size_t n = std::distance(begin_, end_) - 1; + size_t n = ETL_STD::distance(begin_, end_) - 1; this->current_size += n; other.current_size -= n; } @@ -986,7 +987,7 @@ namespace etl //************************************************************************* void merge(list_type& other) { - merge(other, std::less()); + merge(other, ETL_STD::less()); } //************************************************************************* diff --git a/include/etl/intrusive_links.h b/include/etl/intrusive_links.h index 5a04169f..d018f4e8 100644 --- a/include/etl/intrusive_links.h +++ b/include/etl/intrusive_links.h @@ -40,6 +40,7 @@ SOFTWARE. #include "error_handler.h" #include "stl/utility.h" +#include "stl/algorithm.h" #undef ETL_FILE #define ETL_FILE "22" @@ -89,22 +90,22 @@ namespace etl template struct forward_link { - enum - { - ID = ID_, - }; + enum + { + ID = ID_, + }; - void clear() - { - etl_next = nullptr; - } + void clear() + { + etl_next = nullptr; + } - bool is_linked() const - { - return etl_next != nullptr; - } + bool is_linked() const + { + return etl_next != nullptr; + } - forward_link* etl_next; + forward_link* etl_next; }; // Reference, Reference @@ -246,29 +247,29 @@ namespace etl template struct bidirectional_link { - enum - { - ID = ID_, - }; + enum + { + ID = ID_, + }; - void clear() - { - etl_previous = nullptr; - etl_next = nullptr; - } + void clear() + { + etl_previous = nullptr; + etl_next = nullptr; + } - bool is_linked() const - { - return (etl_previous != nullptr) || (etl_next != nullptr); - } + bool is_linked() const + { + return (etl_previous != nullptr) || (etl_next != nullptr); + } - void reverse() - { - std::swap(etl_previous, etl_next); - } + void reverse() + { + ETL_STD::swap(etl_previous, etl_next); + } - bidirectional_link* etl_previous; - bidirectional_link* etl_next; + bidirectional_link* etl_previous; + bidirectional_link* etl_next; void unlink() { diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 29b308e2..059bb121 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -45,6 +45,7 @@ SOFTWARE. #include "intrusive_links.h" #include "static_assert.h" #include "algorithm.h" +#include "iterator.h" #include "stl/algorithm.h" #include "stl/iterator.h" @@ -132,7 +133,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - intmax_t d = std::distance(first, last); + intmax_t d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_list_iterator_exception)); #endif @@ -382,7 +383,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -487,7 +488,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -579,7 +580,7 @@ namespace etl const value_type* p_value; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //************************************************************************* /// Constructor. @@ -733,7 +734,7 @@ namespace etl // Join the ends. etl::link(p_first->etl_previous, p_last); - this->current_size -= std::distance(first, last); + this->current_size -= ETL_STD::distance(first, last); if (p_last == &this->terminal_link) { @@ -780,7 +781,7 @@ namespace etl //************************************************************************* void sort() { - sort(std::less()); + sort(ETL_STD::less()); } //************************************************************************* @@ -1012,7 +1013,7 @@ namespace etl { if (&other != this) { - size_t n = std::distance(begin_, end_); + size_t n = ETL_STD::distance(begin_, end_); this->current_size += n; other.current_size -= n; } @@ -1035,7 +1036,7 @@ namespace etl //************************************************************************* void merge(list_type& other) { - merge(other, std::less()); + merge(other, ETL_STD::less()); } //************************************************************************* diff --git a/include/etl/io_port.h b/include/etl/io_port.h index b0b94dc0..713c0047 100644 --- a/include/etl/io_port.h +++ b/include/etl/io_port.h @@ -39,6 +39,7 @@ SOFTWARE. #include "platform.h" #include "nullptr.h" +#include "iterator.h" #include "stl/iterator.h" @@ -48,7 +49,7 @@ namespace etl /// Read write port. //*************************************************************************** template - class io_port_rw : public std::iterator + class io_port_rw : public etl::iterator { public: @@ -128,7 +129,7 @@ namespace etl /// Read only port. //*************************************************************************** template - class io_port_ro : public std::iterator + class io_port_ro : public etl::iterator { public: @@ -192,7 +193,7 @@ namespace etl /// Write only port. //*************************************************************************** template - class io_port_wo : public std::iterator + class io_port_wo : public etl::iterator { public: @@ -256,7 +257,7 @@ namespace etl /// Write only port with shadow register. //*************************************************************************** template - class io_port_wos : public std::iterator + class io_port_wos : public etl::iterator { public: @@ -335,7 +336,7 @@ namespace etl /// Specialisation for dynamic addresses. //*************************************************************************** template - class io_port_rw : public std::iterator + class io_port_rw : public etl::iterator { public: @@ -446,7 +447,7 @@ namespace etl /// Specialisation for dynamic addresses. //*************************************************************************** template - class io_port_ro : public std::iterator + class io_port_ro : public etl::iterator { public: @@ -535,7 +536,7 @@ namespace etl /// Specialisation for dynamic addresses. //*************************************************************************** template - class io_port_wo : public std::iterator + class io_port_wo : public etl::iterator { public: @@ -630,7 +631,7 @@ namespace etl /// Specialisation for dynamic addresses. //*************************************************************************** template - class io_port_wos : public std::iterator + class io_port_wos : public etl::iterator { public: @@ -639,7 +640,7 @@ namespace etl typedef volatile T& reference; typedef volatile const T& const_reference; - class iterator : public std::iterator + class iterator : public etl::iterator { typedef io_port_wos iop_t; diff --git a/include/etl/iterator.h b/include/etl/iterator.h index fb38b370..d4ff0321 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -42,34 +42,50 @@ SOFTWARE. namespace etl { + //*************************************************************************** + /// iterator + //*************************************************************************** + template + struct iterator + { + typedef T value_type; + typedef TDistance difference_type; + typedef TPointer pointer; + typedef TReference reference; + typedef TCategory iterator_category; + }; + + //*************************************************************************** + // Helper templates. + //*************************************************************************** template struct is_input_iterator { - static const bool value = etl::is_same::iterator_category, std::input_iterator_tag>::value; + static const bool value = etl::is_same::iterator_category, ETL_INPUT_ITERATOR_TAG>::value; }; template struct is_output_iterator { - static const bool value = etl::is_same::iterator_category, std::output_iterator_tag>::value; + static const bool value = etl::is_same::iterator_category, ETL_OUTPUT_ITERATOR_TAG>::value; }; template struct is_forward_iterator { - static const bool value = etl::is_same::iterator_category, std::forward_iterator_tag>::value; + static const bool value = etl::is_same::iterator_category, ETL_FORWARD_ITERATOR_TAG>::value; }; template struct is_bidirectional_iterator { - static const bool value = etl::is_same::iterator_category, std::bidirectional_iterator_tag>::value; + static const bool value = etl::is_same::iterator_category, ETL_BIDIRECTIONAL_ITERATOR_TAG>::value; }; template struct is_random_iterator { - static const bool value = etl::is_same::iterator_category, std::random_access_iterator_tag>::value; + static const bool value = etl::is_same::iterator_category, ETL_RANDOM_ACCESS_ITERATOR_TAG>::value; }; template diff --git a/include/etl/list.h b/include/etl/list.h index f6ea7616..d86b6dce 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -50,6 +50,7 @@ SOFTWARE. #include "type_traits.h" #include "algorithm.h" #include "memory.h" +#include "iterator.h" #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include @@ -181,7 +182,7 @@ namespace etl //*********************************************************************** inline void reverse() { - std::swap(previous, next); + ETL_STD::swap(previous, next); } node_t* previous; @@ -481,7 +482,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -582,7 +583,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -675,10 +676,10 @@ namespace etl const node_t* p_node; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Gets the beginning of the list. @@ -809,7 +810,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(list_iterator)); ETL_ASSERT(size_t(d) <= MAX_SIZE, ETL_ERROR(list_full)); #endif @@ -865,7 +866,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - insert_node(get_head(), allocate_data_node(std::move(value))); + insert_node(get_head(), allocate_data_node(ETL_STD::move(value))); } #endif @@ -882,7 +883,7 @@ namespace etl ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::forward(args)...); + ::new (&(p_data_node->value)) T(ETL_STD::forward(args)...); ETL_INCREMENT_DEBUG_COUNT insert_node(get_head(), *p_data_node); } @@ -988,7 +989,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - insert_node(terminal_node, allocate_data_node(std::move(value))); + insert_node(terminal_node, allocate_data_node(ETL_STD::move(value))); } #endif @@ -1005,7 +1006,7 @@ namespace etl ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::forward(args)...); + ::new (&(p_data_node->value)) T(ETL_STD::forward(args)...); ETL_INCREMENT_DEBUG_COUNT insert_node(terminal_node, *p_data_node); } @@ -1100,7 +1101,7 @@ namespace etl { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - data_node_t& data_node = allocate_data_node(std::move(value)); + data_node_t& data_node = allocate_data_node(ETL_STD::move(value)); insert_node(*position.p_node, data_node); return iterator(data_node); @@ -1118,7 +1119,7 @@ namespace etl ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::forward(args)...); + ::new (&(p_data_node->value)) T(ETL_STD::forward(args)...); ETL_INCREMENT_DEBUG_COUNT insert_node(*position.p_node, *p_data_node); @@ -1268,7 +1269,7 @@ namespace etl else if (n < size()) { iterator i_start = end(); - std::advance(i_start, -difference_type(size() - n)); + ETL_STD::advance(i_start, -difference_type(size() - n)); erase(i_start, end()); } // Larger? @@ -1333,7 +1334,7 @@ namespace etl //************************************************************************* void unique() { - unique(std::equal_to()); + unique(ETL_STD::equal_to()); } //************************************************************************* @@ -1389,7 +1390,7 @@ namespace etl typename ilist::iterator itr = other.begin(); while (itr != other.end()) { - to = insert(to, std::move(*itr++)); + to = insert(to, ETL_STD::move(*itr++)); } other.erase(other.begin(), other.end()); @@ -1429,7 +1430,7 @@ namespace etl else { // From another list. - insert(to, std::move(*from)); + insert(to, ETL_STD::move(*from)); other.erase(from); } } @@ -1470,7 +1471,7 @@ namespace etl ilist::iterator itr = first; while (itr != last) { - to = insert(to, std::move(*itr++)); + to = insert(to, ETL_STD::move(*itr++)); ++to; } @@ -1484,7 +1485,7 @@ namespace etl //************************************************************************* void merge(ilist& other) { - merge(other, std::less()); + merge(other, ETL_STD::less()); } //************************************************************************* @@ -1541,7 +1542,7 @@ namespace etl //************************************************************************* void merge(ilist&& other) { - merge(std::move(other), std::less()); + merge(ETL_STD::move(other), ETL_STD::less()); } //************************************************************************* @@ -1576,7 +1577,7 @@ namespace etl { while ((other_begin != other_end) && (compare(*other_begin, *this_begin))) { - insert(this_begin, std::move(*other_begin)); + insert(this_begin, ETL_STD::move(*other_begin)); ++other_begin; } } @@ -1587,7 +1588,7 @@ namespace etl { while (other_begin != other_end) { - insert(this_end, std::move(*other_begin++)); + insert(this_end, ETL_STD::move(*other_begin++)); } } @@ -1602,7 +1603,7 @@ namespace etl //************************************************************************* void sort() { - sort(std::less()); + sort(ETL_STD::less()); } //************************************************************************* @@ -1764,7 +1765,7 @@ namespace etl iterator itr = rhs.begin(); while (itr != rhs.end()) { - push_back(std::move(*itr)); + push_back(ETL_STD::move(*itr)); ++itr; } @@ -1916,7 +1917,7 @@ namespace etl ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = p_node_pool->allocate(); - ::new (&(p_data_node->value)) T(std::move(value)); + ::new (&(p_data_node->value)) T(ETL_STD::move(value)); ETL_INCREMENT_DEBUG_COUNT return *p_data_node; @@ -2032,7 +2033,7 @@ namespace etl typename etl::ilist::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2088,7 +2089,7 @@ namespace etl typename etl::ilist::iterator itr = rhs.begin(); while (itr != rhs.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2190,7 +2191,7 @@ namespace etl typename etl::ilist::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2213,7 +2214,7 @@ namespace etl //************************************************************************* /// Construct from initializer_list. //************************************************************************* - list(std::initializer_list init, etl::ipool& node_pool) + list(ETL_STD::initializer_list init, etl::ipool& node_pool) : ilist(node_pool, node_pool.max_size(), true) { this->assign(init.begin(), init.end()); @@ -2246,7 +2247,7 @@ namespace etl typename etl::ilist::iterator itr = rhs.begin(); while (itr != rhs.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -2281,7 +2282,7 @@ namespace etl template bool operator ==(const etl::ilist& lhs, const etl::ilist& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //************************************************************************* @@ -2306,7 +2307,7 @@ namespace etl template bool operator <(const etl::ilist& lhs, const etl::ilist& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/map.h b/include/etl/map.h index b95345b9..79a11f7e 100755 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -49,6 +49,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" #include "parameter_type.h" +#include "iterator.h" #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include @@ -461,13 +462,13 @@ namespace etl /// A templated base for all etl::map types. ///\ingroup map //*************************************************************************** - template > + template > class imap : public etl::map_base { public: typedef TKey key_type; - typedef std::pair value_type; + typedef ETL_PAIR value_type; typedef TMapped mapped_type; typedef TKeyCompare key_compare; typedef value_type& reference; @@ -574,7 +575,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -695,7 +696,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -803,10 +804,10 @@ namespace etl friend class const_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Gets the beginning of the map. @@ -916,7 +917,7 @@ namespace etl if (!i_element.p_node) { // Doesn't exist, so create a new one. - i_element = insert(std::make_pair(key, mapped_type())).first; + i_element = insert(ETL_MAKE_PAIR(key, mapped_type())).first; } return i_element->second; @@ -988,9 +989,9 @@ namespace etl /// Returns two iterators with bounding (lower bound, upper bound) the key /// provided //************************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { - return std::make_pair( + return ETL_MAKE_PAIR( iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_upper_node(root_node, key))); } @@ -999,9 +1000,9 @@ namespace etl /// Returns two const iterators with bounding (lower bound, upper bound) /// the key provided. //************************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { - return std::make_pair( + return ETL_MAKE_PAIR( const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_upper_node(root_node, key))); } @@ -1092,7 +1093,7 @@ namespace etl /// If asserts or exceptions are enabled, emits map_full if the map is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const value_type& value) + ETL_PAIR insert(const value_type& value) { // Default to no inserted node Node* inserted_node = nullptr; @@ -1108,7 +1109,7 @@ namespace etl inserted = inserted_node == &node; // Insert node into tree and return iterator to new node location in tree - return std::make_pair(iterator(*this, inserted_node), inserted); + return ETL_MAKE_PAIR(iterator(*this, inserted_node), inserted); } //********************************************************************* @@ -2041,7 +2042,7 @@ namespace etl //************************************************************************* /// A templated map implementation that uses a fixed size buffer. //************************************************************************* - template > + template > class map : public etl::imap { public: @@ -2128,7 +2129,7 @@ namespace etl template bool operator ==(const etl::imap& lhs, const etl::imap& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2154,7 +2155,7 @@ namespace etl template bool operator <(const etl::imap& lhs, const etl::imap& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/memory.h b/include/etl/memory.h index 032a0dbf..8e6ff921 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -62,10 +62,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value) { - std::fill(o_begin, o_end, value); + ETL_STD::fill(o_begin, o_end, value); return o_end; } @@ -75,10 +75,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename ETL_STD::iterator_traits::value_type value_type; while (o_begin != o_end) { @@ -95,12 +95,12 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) { - count += int32_t(std::distance(o_begin, o_end)); + count += int32_t(ETL_STD::distance(o_begin, o_end)); - std::fill(o_begin, o_end, value); + ETL_STD::fill(o_begin, o_end, value); return o_end; } @@ -111,10 +111,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) { - count += int32_t(std::distance(o_begin, o_end)); + count += int32_t(ETL_STD::distance(o_begin, o_end)); etl::uninitialized_fill(o_begin, o_end, value); @@ -149,10 +149,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin) { - return std::copy(i_begin, i_end, o_begin); + return ETL_STD::copy(i_begin, i_end, o_begin); } //***************************************************************************** @@ -160,10 +160,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename ETL_STD::iterator_traits::value_type value_type; TOutputIterator o_end = o_begin; @@ -183,11 +183,11 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) { - TOutputIterator o_end = std::copy(i_begin, i_end, o_begin); - count += int32_t(std::distance(o_begin, o_end)); + TOutputIterator o_end = ETL_STD::copy(i_begin, i_end, o_begin); + count += int32_t(ETL_STD::distance(o_begin, o_end)); return o_end; } @@ -198,12 +198,12 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) { TOutputIterator o_end = etl::uninitialized_copy(i_begin, i_end, o_begin); - count += int32_t(std::distance(o_begin, o_end)); + count += int32_t(ETL_STD::distance(o_begin, o_end)); return o_end; } @@ -280,7 +280,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator /*o_begin*/, TOutputIterator /*o_end*/) { } @@ -290,10 +290,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename ETL_STD::iterator_traits::value_type value_type; while (o_begin != o_end) { @@ -308,10 +308,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count = int32_t(std::distance(o_begin, o_end)); + count = int32_t(ETL_STD::distance(o_begin, o_end)); } //***************************************************************************** @@ -320,10 +320,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count += int32_t(std::distance(o_begin, o_end)); + count += int32_t(ETL_STD::distance(o_begin, o_end)); etl::uninitialized_default_construct(o_begin, o_end); } @@ -333,7 +333,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n) { TOutputIterator o_end = o_begin + n; @@ -346,7 +346,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n) { TOutputIterator o_end = o_begin + n; @@ -362,7 +362,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count) { TOutputIterator o_end = o_begin + n; @@ -378,7 +378,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TOutputIterator>::type + typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count) { TOutputIterator o_end = o_begin + n; @@ -429,7 +429,7 @@ namespace etl template void create_copy_at(T* p, T&& value) { - ::new (p) T(std::move(value)); + ::new (p) T(ETL_STD::move(value)); } #endif @@ -486,7 +486,7 @@ namespace etl template T& make_copy_at(T* p, T&& other) { - ::new (p) T(std::move(other)); + ::new (p) T(ETL_STD::move(other)); return *reinterpret_cast(p); } #endif @@ -522,7 +522,7 @@ namespace etl template T& make_value_at(T* p, TParameter&& value) { - ::new (p) T(std::move(value)); + ::new (p) T(ETL_STD::move(value)); return *reinterpret_cast(p); } #endif @@ -544,12 +544,12 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename ETL_STD::iterator_traits::value_type value_type; - std::fill(o_begin, o_end, value_type()); + ETL_STD::fill(o_begin, o_end, value_type()); } //***************************************************************************** @@ -557,10 +557,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename ETL_STD::iterator_traits::value_type value_type; while (o_begin != o_end) { @@ -577,7 +577,7 @@ namespace etl template void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count += int32_t(std::distance(o_begin, o_end)); + count += int32_t(ETL_STD::distance(o_begin, o_end)); etl::uninitialized_value_construct(o_begin, o_end); } @@ -664,7 +664,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type destroy(TIterator /*i_begin*/, TIterator /*i_end*/) { } @@ -674,7 +674,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type destroy(TIterator i_begin, TIterator i_end) { while (i_begin != i_end) @@ -690,10 +690,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type destroy(TIterator i_begin, TIterator i_end, TCounter& count) { - count -= int32_t(std::distance(i_begin, i_end)); + count -= int32_t(ETL_STD::distance(i_begin, i_end)); } //***************************************************************************** @@ -702,10 +702,10 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, void>::type + typename etl::enable_if::value_type>::value, void>::type destroy(TIterator i_begin, TIterator i_end, TCounter& count) { - count -= int32_t(std::distance(i_begin, i_end)); + count -= int32_t(ETL_STD::distance(i_begin, i_end)); while (i_begin != i_end) { @@ -719,7 +719,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TIterator>::type + typename etl::enable_if::value_type>::value, TIterator>::type destroy_n(TIterator i_begin, TSize n) { return i_begin + n; @@ -730,7 +730,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TIterator>::type + typename etl::enable_if::value_type>::value, TIterator>::type destroy_n(TIterator i_begin, TSize n) { while (n > 0) @@ -749,7 +749,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TIterator>::type + typename etl::enable_if::value_type>::value, TIterator>::type destroy_n(TIterator i_begin, TSize n, TCounter& count) { count -= n; @@ -762,7 +762,7 @@ namespace etl ///\ingroup memory //***************************************************************************** template - typename etl::enable_if::value_type>::value, TIterator>::type + typename etl::enable_if::value_type>::value, TIterator>::type destroy_n(TIterator i_begin, TSize n, TCounter& count) { count -= n; @@ -911,7 +911,7 @@ namespace etl void swap(unique_ptr& value) { - std::swap(p, value.p); + ETL_STD::swap(p, value.p); } ETL_CONSTEXPR operator bool() const @@ -1045,7 +1045,7 @@ namespace etl void swap(unique_ptr& v) { - std::swap(p, v.p); + ETL_STD::swap(p, v.p); } ETL_CONSTEXPR operator bool() const @@ -1159,7 +1159,7 @@ namespace etl template void memory_clear_range(volatile T* begin, volatile T* end) { - const size_t n = static_cast(std::distance(begin, end)); + const size_t n = static_cast(ETL_STD::distance(begin, end)); memory_clear_range(begin, n); } @@ -1217,7 +1217,7 @@ namespace etl template void memory_set_range(volatile T* begin, volatile T* end, const char value) { - const size_t n = static_cast(std::distance(begin, end)); + const size_t n = static_cast(ETL_STD::distance(begin, end)); memory_set_range(begin, n, value); } diff --git a/include/etl/message_bus.h b/include/etl/message_bus.h index 7e19ccd6..2844feea 100644 --- a/include/etl/message_bus.h +++ b/include/etl/message_bus.h @@ -102,7 +102,7 @@ namespace etl if (ok) { - router_list_t::iterator irouter = std::upper_bound(router_list.begin(), + router_list_t::iterator irouter = ETL_STD::upper_bound(router_list.begin(), router_list.end(), router.get_message_router_id(), compare_router_id()); @@ -125,10 +125,10 @@ namespace etl } else { - std::pair range = std::equal_range(router_list.begin(), - router_list.end(), - id, - compare_router_id()); + ETL_PAIR range = ETL_STD::equal_range(router_list.begin(), + router_list.end(), + id, + compare_router_id()); router_list.erase(range.first, range.second); } @@ -137,7 +137,7 @@ namespace etl //******************************************* void unsubscribe(etl::imessage_router& router) { - router_list_t::iterator irouter = std::find(router_list.begin(), + router_list_t::iterator irouter = ETL_STD::find(router_list.begin(), router_list.end(), &router); @@ -212,7 +212,7 @@ namespace etl router_list_t::iterator irouter = router_list.begin(); // Find routers with the id. - std::pair range = std::equal_range(router_list.begin(), + ETL_PAIR range = ETL_STD::equal_range(router_list.begin(), router_list.end(), destination_router_id, compare_router_id()); @@ -230,7 +230,7 @@ namespace etl // Do any message buses. // These are always at the end of the list. - irouter = std::lower_bound(router_list.begin(), + irouter = ETL_STD::lower_bound(router_list.begin(), router_list.end(), etl::imessage_bus::MESSAGE_BUS, compare_router_id()); diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 8aa9c18e..56f3cabf 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -45,28 +45,37 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "44" -#if !defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) - #error ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK not defined -#endif +#if defined(ETL_IN_UNIT_TEST) && defined(ETL_NO_STL) + #define ETL_DISABLE_TIMER_UPDATES + #define ETL_ENABLE_TIMER_UPDATES + #define ETL_TIMER_UPDATES_ENABLED true -#if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) - #error Only define one of ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK -#endif - -#if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) - #define ETL_DISABLE_TIMER_UPDATES (++process_semaphore) - #define ETL_ENABLE_TIMER_UPDATES (--process_semaphore) - #define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0) -#endif - -#if defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) - #if !defined(ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) || !defined(ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS) - #error ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS and/or ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS not defined + #undef ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK + #undef ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK +#else + #if !defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) + #error ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK not defined #endif - #define ETL_DISABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) - #define ETL_ENABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS) - #define ETL_TIMER_UPDATES_ENABLED true + #if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) + #error Only define one of ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK + #endif + + #if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) + #define ETL_DISABLE_TIMER_UPDATES (++process_semaphore) + #define ETL_ENABLE_TIMER_UPDATES (--process_semaphore) + #define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0) + #endif + + #if defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) + #if !defined(ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) || !defined(ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS) + #error ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS and/or ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS not defined + #endif + + #define ETL_DISABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) + #define ETL_ENABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS) + #define ETL_TIMER_UPDATES_ENABLED true + #endif #endif namespace etl diff --git a/include/etl/multicast_delegate.h b/include/etl/multicast_delegate.h deleted file mode 100644 index 9fc3f31a..00000000 --- a/include/etl/multicast_delegate.h +++ /dev/null @@ -1,143 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. -https://github.com/ETLCPP/etl -https://www.etlcpp.com - -Copyright(c) 2019 jwellbelove - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -******************************************************************************/ - -/****************************************************************************** - - Copyright (C) 2017 by Sergey A Kryukov: derived work - http://www.SAKryukov.org - http://www.codeproject.com/Members/SAKryukov - - Based on original work by Sergey Ryazanov: - "The Impossibly Fast C++ Delegates", 18 Jul 2005 - https://www.codeproject.com/articles/11015/the-impossibly-fast-c-delegates - - MIT license: - http://en.wikipedia.org/wiki/MIT_License - - Original publication: https://www.codeproject.com/Articles/1170503/The-Impossibly-Fast-Cplusplus-Delegates-Fixed - -******************************************************************************/ - -//#pragma once -//#include "delegate.h" -//#include -//#include -// -//namespace SA { -// -// template -// class multicast_delegate final : private delegate_base { -// public: -// -// multicast_delegate() = default; -// ~multicast_delegate() { -// for (auto& element : invocationList) delete element; -// invocationList.clear(); -// } //~multicast_delegate -// -// bool isNull() const { return invocationList.size() < 1; } -// bool operator ==(void* ptr) const { -// return (ptr == nullptr) && this->isNull(); -// } //operator == -// bool operator !=(void* ptr) const { -// return (ptr != nullptr) || (!this->isNull()); -// } //operator != -// -// size_t size() const { return invocationList.size(); } -// -// multicast_delegate& operator =(const multicast_delegate&) = delete; -// multicast_delegate(const multicast_delegate&) = delete; -// -// bool operator ==(const multicast_delegate& another) const { -// if (invocationList.size() != another.invocationList.size()) return false; -// auto anotherIt = another.invocationList.begin(); -// for (auto it = invocationList.begin(); it != invocationList.end(); ++it) -// if (**it != **anotherIt) return false; -// return true; -// } //== -// bool operator !=(const multicast_delegate& another) const { return !(*this == another); } -// -// bool operator ==(const delegate& another) const { -// if (isNull() && another.isNull()) return true; -// if (another.isNull() || (size() != 1)) return false; -// return (another.invocation == **invocationList.begin()); -// } //== -// bool operator !=(const delegate& another) const { return !(*this == another); } -// -// multicast_delegate& operator +=(const multicast_delegate& another) { -// for (auto& item : another.invocationList) // clone, not copy; flattens hierarchy: -// this->invocationList.push_back(new typename delegate_base::InvocationElement(item->object, item->stub)); -// return *this; -// } //operator += -// -// template // template instantiation is not neededm, will be deduced/inferred: -// multicast_delegate& operator +=(const LAMBDA & lambda) { -// delegate d = delegate::template create(lambda); -// return *this += d; -// } //operator += -// -// multicast_delegate& operator +=(const delegate& another) { -// if (another.isNull()) return *this; -// this->invocationList.push_back(new typename delegate_base::InvocationElement(another.invocation.object, another.invocation.stub)); -// return *this; -// } //operator += -// -// // will work even if RET is void, return values are ignored: -// // (for handling return values, see operator(..., handler)) -// void operator()(PARAMS... arg) const { -// for (auto& item : invocationList) -// (*(item->stub))(item->object, arg...); -// } //operator() -// -// template -// void operator()(PARAMS... arg, HANDLER handler) const { -// size_t index = 0; -// for (auto& item : invocationList) { -// RET value = (*(item->stub))(item->object, arg...); -// handler(index, &value); -// ++index; -// } //loop -// } //operator() -// -// void operator()(PARAMS... arg, delegate handler) const { -// operator()(arg..., handler); -// } //operator() -// void operator()(PARAMS... arg, std::function handler) const { -// operator()(arg..., handler); -// } //operator() -// -// private: -// -// std::list::InvocationElement *> invocationList; -// -// }; //class multicast_delegate -// -//} /* namespace SA */ -// diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 291294de..34e11f60 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -49,6 +49,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" #include "parameter_type.h" +#include "iterator.h" #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include @@ -623,12 +624,12 @@ namespace etl /// A templated base for all etl::multimap types. ///\ingroup map //*************************************************************************** - template > + template > class imultimap : public etl::multimap_base { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; typedef const TKey key_type; typedef TMapped mapped_type; typedef TKeyCompare key_compare; @@ -732,7 +733,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -852,7 +853,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -959,10 +960,10 @@ namespace etl }; friend class const_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Gets the beginning of the multimap. @@ -1096,9 +1097,9 @@ namespace etl /// Returns two iterators with bounding (lower bound, upper bound) the key /// provided //************************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { - return std::make_pair( + return ETL_MAKE_PAIR( iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_upper_node(root_node, key))); } @@ -1107,9 +1108,9 @@ namespace etl /// Returns two const iterators with bounding (lower bound, upper bound) /// the key provided. //************************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { - return std::make_pair( + return ETL_MAKE_PAIR( const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_upper_node(root_node, key))); } @@ -1930,7 +1931,7 @@ namespace etl //************************************************************************* /// A templated multimap implementation that uses a fixed size buffer. //************************************************************************* - template > + template > class multimap : public etl::imultimap { public: @@ -2017,7 +2018,7 @@ namespace etl template bool operator ==(const etl::imultimap& lhs, const etl::imultimap& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2043,7 +2044,7 @@ namespace etl template bool operator <(const etl::imultimap& lhs, const etl::imultimap& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 89a902c5..6e03ce4b 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -623,7 +623,7 @@ namespace etl /// A templated base for all etl::multiset types. ///\ingroup set //*************************************************************************** - template > + template > class imultiset : public etl::multiset_base { public: @@ -713,7 +713,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -818,7 +818,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -925,10 +925,10 @@ namespace etl }; friend class const_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Gets the beginning of the multiset. @@ -1062,9 +1062,9 @@ namespace etl /// Returns two iterators with bounding (lower bound, upper bound) the key /// provided //************************************************************************* - std::pair equal_range(const value_type& key) + ETL_PAIR equal_range(const value_type& key) { - return std::make_pair( + return ETL_MAKE_PAIR( iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_upper_node(root_node, key))); } @@ -1073,9 +1073,9 @@ namespace etl /// Returns two const iterators with bounding (lower bound, upper bound) /// the key provided. //************************************************************************* - std::pair equal_range(const value_type& key) const + ETL_PAIR equal_range(const value_type& key) const { - return std::make_pair( + return ETL_MAKE_PAIR( const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_upper_node(root_node, key))); } @@ -1895,7 +1895,7 @@ namespace etl //************************************************************************* /// A templated multiset implementation that uses a fixed size buffer. //************************************************************************* - template > + template > class multiset : public etl::imultiset { public: @@ -1982,7 +1982,7 @@ namespace etl template bool operator ==(const etl::imultiset& lhs, const etl::imultiset& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2008,7 +2008,7 @@ namespace etl template bool operator <(const etl::imultiset& lhs, const etl::imultiset& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/murmur3.h b/include/etl/murmur3.h index 61077bd0..5d54f47b 100644 --- a/include/etl/murmur3.h +++ b/include/etl/murmur3.h @@ -81,7 +81,7 @@ namespace etl murmur3(TIterator begin, const TIterator end, value_type seed_ = 0) : seed(seed_) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Incompatible type"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Incompatible type"); reset(); while (begin != end) @@ -119,7 +119,7 @@ namespace etl template void add(TIterator begin, const TIterator end) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Incompatible type"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Incompatible type"); ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)); while (begin != end) diff --git a/include/etl/observer.h b/include/etl/observer.h index 8d146ce0..9de10a64 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -115,9 +115,9 @@ namespace etl void add_observer(TObserver& observer) { // See if we already have it in our list. - typename Observer_List::const_iterator i_observer = std::find(observer_list.begin(), - observer_list.end(), - &observer); + typename Observer_List::const_iterator i_observer = ETL_STD::find(observer_list.begin(), + observer_list.end(), + &observer); // Not there? if (i_observer == observer_list.end()) @@ -138,9 +138,9 @@ namespace etl bool remove_observer(TObserver& observer) { // See if we have it in our list. - typename Observer_List::iterator i_observer = std::find(observer_list.begin(), - observer_list.end(), - &observer); + typename Observer_List::iterator i_observer = ETL_STD::find(observer_list.begin(), + observer_list.end(), + &observer); // Found it? if (i_observer != observer_list.end()) diff --git a/include/etl/optional.h b/include/etl/optional.h index 3afe1685..b03636f9 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -343,7 +343,7 @@ namespace etl storage.template get_reference().~T(); } - ::new (storage.template get_address()) T(std::forward(args)...); + ::new (storage.template get_address()) T(ETL_STD::forward(args)...); valid = true; } #else diff --git a/include/etl/pearson.h b/include/etl/pearson.h index 6d3da65e..ab06cfa0 100644 --- a/include/etl/pearson.h +++ b/include/etl/pearson.h @@ -81,7 +81,7 @@ namespace etl pearson(TIterator begin, const TIterator end) : first(true) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Type not supported"); reset(); add(begin, end); @@ -103,7 +103,7 @@ namespace etl template void add(TIterator begin, const TIterator end) { - ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits::value_type) == 1, "Type not supported"); while (begin != end) { diff --git a/include/etl/platform.h b/include/etl/platform.h index eed65efa..ebd8b6d9 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -64,11 +64,6 @@ SOFTWARE. // The macros below are dependent on the profile. -#if defined(ETL_COMPILER_MICROSOFT) - // Disable warning of deprecated std::iterator. - #pragma warning(disable : 4996) -#endif - #if defined(ETL_COMPILER_GCC) #define ETL_COMPILER_VERSION __GNUC__ #define ETL_COMPILER_FULL_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) @@ -79,13 +74,17 @@ SOFTWARE. #if ETL_CPP11_SUPPORTED #define ETL_CONSTEXPR constexpr + #define ETL_CONST constexpr #else #define ETL_CONSTEXPR + #define ETL_CONST const #endif #if ETL_CPP17_SUPPORTED + #define ETL_CONSTEXPR17 constexpr #define ETL_IF_CONSTEXPR constexpr #else + #define ETL_CONSTEXPR17 #define ETL_IF_CONSTEXPR #endif @@ -98,9 +97,17 @@ SOFTWARE. #if ETL_CPP11_SUPPORTED #define ETL_NOEXCEPT noexcept #define ETL_NOEXCEPT_EXPR(expression) noexcept(expression) + #define ETL_NODISCARD [[nodiscard]] #else #define ETL_NOEXCEPT #define ETL_NOEXCEPT_EXPR(expression) + #define ETL_NODISCARD +#endif + +#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR) + #define ETL_EXPLICIT_STRING_FROM_CHAR explicit +#else + #define ETL_EXPLICIT_STRING_FROM_CHAR #endif #if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR) diff --git a/include/etl/pool.h b/include/etl/pool.h index 56adb235..a70d4b6d 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -138,7 +138,7 @@ namespace etl return reinterpret_cast(allocate_item()); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create default. /// If asserts or exceptions are enabled and there are no more free items an @@ -224,7 +224,7 @@ namespace etl if (p) { - ::new (p) T(std::forward(args)...); + ::new (p) T(ETL_STD::forward(args)...); } return p; @@ -497,7 +497,7 @@ namespace etl return ipool::allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// If asserts or exceptions are enabled and there are no more free items an @@ -571,7 +571,7 @@ namespace etl { ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); - return ipool::create(std::forward(args)...); + return ipool::create(ETL_STD::forward(args)...); } #endif @@ -648,7 +648,7 @@ namespace etl return base_t::template allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// If asserts or exceptions are enabled and there are no more free items an @@ -724,7 +724,7 @@ namespace etl { ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); - return base_t::template create(std::forward(args)...); + return base_t::template create(ETL_STD::forward(args)...); } #endif diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index d84c0b9e..9904c908 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -115,7 +115,7 @@ namespace etl /// \tparam TContainer to hold the T queue values /// \tparam TCompare to use in comparing T values //*************************************************************************** - template > + template > class ipriority_queue { public: @@ -126,7 +126,7 @@ namespace etl typedef T& reference; ///< A reference to the type used in the queue. typedef const T& const_reference; ///< A const reference to the type used in the queue. typedef typename TContainer::size_type size_type; ///< The type used for determining the size of the queue. - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; private: @@ -165,7 +165,7 @@ namespace etl // Put element at end container.push_back(value); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_PRIORITY_QUEUE_FORCE_CPP03) @@ -181,9 +181,9 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full)); // Put element at end - container.emplace_back(std::forward(args)...); + container.emplace_back(ETL_STD::forward(args)...); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } #else //************************************************************************* @@ -200,7 +200,7 @@ namespace etl // Put element at end container.emplace_back(value1); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -217,7 +217,7 @@ namespace etl // Put element at end container.emplace_back(value1, value2); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -234,7 +234,7 @@ namespace etl // Put element at end container.emplace_back(value1, value2, value3); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -251,7 +251,7 @@ namespace etl // Put element at end container.emplace_back(value1, value2, value3, value4); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), compare); + ETL_STD::push_heap(container.begin(), container.end(), compare); } #endif @@ -268,14 +268,14 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d >= 0, ETL_ERROR(etl::priority_queue_iterator)); ETL_ASSERT(static_cast(d) <= max_size(), ETL_ERROR(etl::priority_queue_full)); #endif clear(); container.assign(first, last); - std::make_heap(container.begin(), container.end(), compare); + ETL_STD::make_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -285,7 +285,7 @@ namespace etl void pop() { // Move largest element to end - std::pop_heap(container.begin(), container.end(), compare); + ETL_STD::pop_heap(container.begin(), container.end(), compare); // Actually remove largest element at end container.pop_back(); } @@ -386,7 +386,7 @@ namespace etl /// \tparam T The type this queue should support. /// \tparam SIZE The maximum capacity of the queue. //*************************************************************************** - template , typename TCompare = std::less > + template , typename TCompare = ETL_STD::less > class priority_queue : public etl::ipriority_queue { public: diff --git a/include/etl/stl/alternate/choose_namespace.h b/include/etl/private/choose_namespace.h similarity index 87% rename from include/etl/stl/alternate/choose_namespace.h rename to include/etl/private/choose_namespace.h index 55a4120e..935b72ac 100644 --- a/include/etl/stl/alternate/choose_namespace.h +++ b/include/etl/private/choose_namespace.h @@ -31,15 +31,15 @@ SOFTWARE. #ifndef ETL_STL_CHOOSE_NAMESPACE_INCLUDED #define ETL_STL_CHOOSE_NAMESPACE_INCLUDED -#include "../../platform.h" +#include "../platform.h" -#if defined(ETL_IN_UNIT_TEST) - #ifndef ETLSTD - #define ETLSTD etlstd // Used for the unit tests. +#if defined(ETL_NO_STL) + #ifndef ETL_STD + #define ETL_STD etlstd /// Namespace for the alternate STL. #endif #else - #ifndef ETLSTD - #define ETLSTD std // Used for normal code. + #ifndef ETL_STD + #define ETL_STD std /// Namespace for conventional STL #endif #endif diff --git a/include/etl/private/choose_pair_types.h b/include/etl/private/choose_pair_types.h new file mode 100644 index 00000000..2c19e8e8 --- /dev/null +++ b/include/etl/private/choose_pair_types.h @@ -0,0 +1,45 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_STL_CHOOSE_PAIR_TYPES_INCLUDED +#define ETL_STL_CHOOSE_PAIR_TYPES_INCLUDED + +#include "../platform.h" + +#if defined(ETL_IN_UNIT_TEST) // When in the unit tests we have to ensure that the STL and ETL are using the same definitions. + #include + #define ETL_PAIR std::pair + #define ETL_MAKE_PAIR std::make_pair +#else + #define ETL_PAIR etlstd::pair + #define ETL_MAKE_PAIR etlstd::make_pair +#endif + +#endif diff --git a/include/etl/private/choose_tag_types.h b/include/etl/private/choose_tag_types.h new file mode 100644 index 00000000..d6eeebe2 --- /dev/null +++ b/include/etl/private/choose_tag_types.h @@ -0,0 +1,51 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_STL_CHOOSE_TAG_TYPES_INCLUDED +#define ETL_STL_CHOOSE_TAG_TYPES_INCLUDED + +#include "../platform.h" + +#if defined(ETL_IN_UNIT_TEST) // When in the unit tests we have to ensure that the STL and ETL are using the same definitions. + #include + #define ETL_INPUT_ITERATOR_TAG std::input_iterator_tag + #define ETL_OUTPUT_ITERATOR_TAG std::output_iterator_tag + #define ETL_FORWARD_ITERATOR_TAG std::forward_iterator_tag + #define ETL_BIDIRECTIONAL_ITERATOR_TAG std::bidirectional_iterator_tag + #define ETL_RANDOM_ACCESS_ITERATOR_TAG std::random_access_iterator_tag +#else + #define ETL_INPUT_ITERATOR_TAG etlstd::input_iterator_tag + #define ETL_OUTPUT_ITERATOR_TAG etlstd::output_iterator_tag + #define ETL_FORWARD_ITERATOR_TAG etlstd::forward_iterator_tag + #define ETL_BIDIRECTIONAL_ITERATOR_TAG etlstd::bidirectional_iterator_tag + #define ETL_RANDOM_ACCESS_ITERATOR_TAG etlstd::random_access_iterator_tag +#endif + +#endif diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index 7ff6796c..51e174f4 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -56,10 +56,10 @@ namespace etl typedef const value_type* const_pointer; typedef value_type* iterator; typedef const value_type* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef size_t size_type; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -441,7 +441,7 @@ namespace etl //********************************************************************* void initialise_source_external_buffer_after_move() { - ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) p_end = p_buffer; } @@ -451,7 +451,7 @@ namespace etl //********************************************************************* void initialise_destination_external_buffer_after_move() { - ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) } }; @@ -467,10 +467,10 @@ namespace etl typedef const value_type* const_pointer; typedef value_type* iterator; typedef const value_type* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef size_t size_type; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -852,7 +852,7 @@ namespace etl //********************************************************************* void initialise_source_external_buffer_after_move() { - ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) p_end = p_buffer; } @@ -862,7 +862,7 @@ namespace etl //********************************************************************* void initialise_destination_external_buffer_after_move() { - ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) } }; diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 19ada2ee..7277b299 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -67,10 +67,10 @@ namespace etl typedef const value_type* const_pointer; typedef value_type* iterator; typedef const value_type* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef size_t size_type; - typedef std::iterator_traits::difference_type difference_type; + typedef ETL_STD::iterator_traits::difference_type difference_type; public: @@ -211,7 +211,7 @@ namespace etl // Size up if necessary. if (p_end < p_new_end) { - std::fill(p_end, p_new_end, value); + ETL_STD::fill(p_end, p_new_end, value); } p_end = p_new_end; @@ -326,7 +326,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(static_cast(d) <= CAPACITY, ETL_ERROR(vector_full)); #endif @@ -402,7 +402,7 @@ namespace etl if (position != end()) { ++p_end; - std::copy_backward(position, end() - 1, end()); + ETL_STD::copy_backward(position, end() - 1, end()); *position = value; } else @@ -424,8 +424,8 @@ namespace etl { ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full)); - std::copy_backward(position, p_end, p_end + n); - std::fill_n(position, n, value); + ETL_STD::copy_backward(position, p_end, p_end + n); + ETL_STD::fill_n(position, n, value); p_end += n; } @@ -441,12 +441,12 @@ namespace etl template void insert(iterator position, TIterator first, TIterator last) { - size_t count = std::distance(first, last); + size_t count = ETL_STD::distance(first, last); ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); - std::copy_backward(position, p_end, p_end + count); - std::copy(first, last, position); + ETL_STD::copy_backward(position, p_end, p_end + count); + ETL_STD::copy(first, last, position); p_end += count; } @@ -457,7 +457,7 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { - std::copy(i_element + 1, end(), i_element); + ETL_STD::copy(i_element + 1, end(), i_element); --p_end; return i_element; @@ -473,8 +473,8 @@ namespace etl //********************************************************************* iterator erase(iterator first, iterator last) { - std::copy(last, end(), first); - size_t n_delete = std::distance(first, last); + ETL_STD::copy(last, end(), first); + size_t n_delete = ETL_STD::distance(first, last); // Just adjust the count. p_end -= n_delete; @@ -580,7 +580,7 @@ namespace etl //*************************************************************************** inline bool operator ==(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -604,7 +604,7 @@ namespace etl //*************************************************************************** inline bool operator <(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //*************************************************************************** diff --git a/include/etl/private/to_string_helper.h b/include/etl/private/to_string_helper.h index 470f7bc3..31452b86 100644 --- a/include/etl/private/to_string_helper.h +++ b/include/etl/private/to_string_helper.h @@ -33,7 +33,7 @@ SOFTWARE. ///\ingroup private -#include +#include #include "../platform.h" #include "../absolute.h" @@ -57,7 +57,7 @@ namespace etl template void add_alignment(TIString& str, typename TIString::iterator position, const etl::basic_format_spec& format) { - uint32_t length = static_cast(std::distance(position, str.end())); + uint32_t length = static_cast(ETL_STD::distance(position, str.end())); if (length < format.get_width()) { @@ -166,7 +166,7 @@ namespace etl } // Reverse the string we appended. - std::reverse(start, str.end()); + ETL_STD::reverse(start, str.end()); } etl::private_to_string::add_alignment(str, start, format); @@ -235,14 +235,14 @@ namespace etl iterator start = str.end(); - if (std::isnan(value) || std::isinf(value)) + if (isnan(value) || isinf(value)) { - etl::private_to_string::add_nan_inf(std::isnan(value), std::isinf(value), str); + etl::private_to_string::add_nan_inf(isnan(value), isinf(value), str); } else { // Make sure we format the two halves correctly. - uint32_t max_precision = std::numeric_limits::digits10; + uint32_t max_precision = ETL_STD::numeric_limits::digits10; etl::basic_format_spec integral_format = format; integral_format.decimal().width(0).precision(format.get_precision() > max_precision ? max_precision : format.get_precision()); diff --git a/include/etl/profiles/armv6_no_stl.h b/include/etl/profiles/armv6_no_stl.h index 07bc98ba..fbf4fc6e 100644 --- a/include/etl/profiles/armv6_no_stl.h +++ b/include/etl/profiles/armv6_no_stl.h @@ -37,7 +37,7 @@ SOFTWARE. #define ETL_TARGET_DEVICE_ARM #define ETL_TARGET_OS_NONE -#define ETL_COMPILER_CLANG +#define ETL_COMPILER_ARM6 #define ETL_CPP11_SUPPORTED 1 #define ETL_CPP14_SUPPORTED 0 #define ETL_CPP17_SUPPORTED 0 diff --git a/include/etl/queue.h b/include/etl/queue.h index cd778ba8..143bd5b2 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -330,7 +330,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif - ::new (&p_buffer[in]) T(std::forward(args)...); + ::new (&p_buffer[in]) T(ETL_STD::forward(args)...); add_in(); } #else diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index de176a7d..410abfcc 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -37,12 +37,17 @@ SOFTWARE. #include #include "platform.h" + +#if ETL_HAS_MUTEX + #include "alignment.h" #include "parameter_type.h" #include "mutex.h" #include "memory_model.h" #include "integral_limits.h" +#include "stl/utility.h" + #undef ETL_FILE #define ETL_FILE "48" @@ -174,7 +179,7 @@ namespace etl { access.lock(); - bool result = emplace_implementation(std::forward(args)...); + bool result = emplace_implementation(ETL_STD::forward(args)...); access.unlock(); @@ -387,7 +392,7 @@ namespace etl { if (current_size != MAX_SIZE) { - ::new (&p_buffer[write_index]) T(std::forward(args)...); + ::new (&p_buffer[write_index]) T(ETL_STD::forward(args)...); write_index = get_next_index(write_index, MAX_SIZE); @@ -587,3 +592,4 @@ namespace etl #undef ETL_FILE #endif +#endif diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index fefdd8ce..08d36e1d 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -46,6 +46,8 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "47" +#if ETL_HAS_ATOMIC + namespace etl { template @@ -237,7 +239,7 @@ namespace etl if (next_index != read.load(etl::memory_order_acquire)) { - ::new (&p_buffer[write_index]) T(std::forward(args)...); + ::new (&p_buffer[write_index]) T(ETL_STD::forward(args)...); write.store(next_index, etl::memory_order_release); @@ -471,6 +473,8 @@ namespace etl }; } +#endif + #undef ETL_FILE #endif diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 7150dad5..e2b449d3 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -42,6 +42,8 @@ SOFTWARE. #include "memory_model.h" #include "integral_limits.h" +#include "stl/utility.h" + #undef ETL_FILE #define ETL_FILE "46" @@ -80,7 +82,7 @@ namespace etl template bool emplace_from_isr(Args&&... args) { - return emplace_implementation(std::forward(args)...); + return emplace_implementation(ETL_STD::forward(args)...); } #endif @@ -205,7 +207,7 @@ namespace etl { if (current_size != MAX_SIZE) { - ::new (&p_buffer[write_index]) T(std::forward(args)...); + ::new (&p_buffer[write_index]) T(ETL_STD::forward(args)...); write_index = get_next_index(write_index, MAX_SIZE); @@ -438,7 +440,7 @@ namespace etl { TAccess::lock(); - bool result = this->emplace_implementation(std::forward(args)...); + bool result = this->emplace_implementation(ETL_STD::forward(args)...); TAccess::unlock(); diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index bfb42af0..2f62dee5 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -43,6 +43,8 @@ SOFTWARE. #include "integral_limits.h" #include "function.h" +#include "stl/utility.h" + #undef ETL_FILE #define ETL_FILE "46" @@ -81,7 +83,7 @@ namespace etl template bool emplace_from_unlocked(Args&&... args) { - return emplace_implementation(std::forward(args)...); + return emplace_implementation(ETL_STD::forward(args)...); } #endif @@ -206,7 +208,7 @@ namespace etl { if (current_size != MAX_SIZE) { - ::new (&p_buffer[write_index]) T(std::forward(args)...); + ::new (&p_buffer[write_index]) T(ETL_STD::forward(args)...); write_index = get_next_index(write_index, MAX_SIZE); @@ -435,7 +437,7 @@ namespace etl { lock(); - bool result = this->emplace_implementation(std::forward(args)...); + bool result = this->emplace_implementation(ETL_STD::forward(args)...); unlock(); diff --git a/include/etl/ratio.h b/include/etl/ratio.h index 015a0177..6bd79c7c 100644 --- a/include/etl/ratio.h +++ b/include/etl/ratio.h @@ -41,8 +41,8 @@ namespace etl template struct ratio { - static const std::intmax_t num = NUM; - static const std::intmax_t den = DEN; + static const intmax_t num = NUM; + static const intmax_t den = DEN; }; #if INT_MAX > INT32_MAX diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index e0392d18..4f95009d 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -41,6 +41,7 @@ SOFTWARE. #include "parameter_type.h" #include "exception.h" #include "static_assert.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "30" @@ -102,12 +103,12 @@ namespace etl /// Can be used as a reference type for all reference_flat_maps containing a specific type. ///\ingroup reference_flat_map //*************************************************************************** - template > + template > class ireference_flat_map { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; protected: @@ -125,7 +126,7 @@ namespace etl typedef size_t size_type; //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -223,7 +224,7 @@ namespace etl }; //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -316,9 +317,9 @@ namespace etl typename lookup_t::const_iterator ilookup; }; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -524,10 +525,10 @@ namespace etl template void assign(TIterator first, TIterator last) { - ETL_STATIC_ASSERT((etl::is_same::value_type>::value), "Incompatible data for assign"); + ETL_STATIC_ASSERT((etl::is_same::value_type>::value), "Incompatible data for assign"); #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full)); #endif @@ -544,7 +545,7 @@ namespace etl /// If asserts or exceptions are enabled, emits flat_map_full if the reference_flat_map is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(reference value) + ETL_PAIR insert(reference value) { iterator i_element = lower_bound(value.first); @@ -692,7 +693,7 @@ namespace etl //********************************************************************* iterator lower_bound(key_parameter_t key) { - return std::lower_bound(begin(), end(), key, compare); + return ETL_STD::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -702,7 +703,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(key_parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare); + return ETL_STD::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -712,7 +713,7 @@ namespace etl //********************************************************************* iterator upper_bound(key_parameter_t key) { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -722,7 +723,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(key_parameter_t key) const { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -730,11 +731,11 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { - iterator i_lower = std::lower_bound(begin(), end(), key, compare); + iterator i_lower = ETL_STD::lower_bound(begin(), end(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); + return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, end(), key, compare)); } //********************************************************************* @@ -742,11 +743,11 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { - const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); + const_iterator i_lower = ETL_STD::lower_bound(cbegin(), cend(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); + return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, cend(), key, compare)); } //************************************************************************* @@ -818,9 +819,9 @@ namespace etl ///\param i_element The place to insert. ///\param value The value to insert. //********************************************************************* - std::pair insert_at(iterator i_element, value_type& value) + ETL_PAIR insert_at(iterator i_element, value_type& value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); if (i_element == end()) { @@ -885,7 +886,7 @@ namespace etl template bool operator ==(const etl::ireference_flat_map& lhs, const etl::ireference_flat_map& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -905,11 +906,11 @@ namespace etl /// A reference_flat_map implementation that uses a fixed size buffer. ///\tparam TKey The key type. ///\tparam TValue The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup reference_flat_map //*************************************************************************** - template > + template > class reference_flat_map : public ireference_flat_map { public: diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index f4051566..b8c58f68 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -38,6 +38,7 @@ SOFTWARE. #include "error_handler.h" #include "debug_count.h" #include "vector.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "31" @@ -77,12 +78,12 @@ namespace etl /// Can be used as a reference type for all reference_flat_multimaps containing a specific type. ///\ingroup reference_flat_multimap //*************************************************************************** - template > + template > class ireference_flat_multimap { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; protected: @@ -100,7 +101,7 @@ namespace etl typedef size_t size_type; //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -198,7 +199,7 @@ namespace etl }; //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -291,9 +292,9 @@ namespace etl typename lookup_t::const_iterator ilookup; }; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -442,7 +443,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full)); #endif @@ -459,11 +460,11 @@ namespace etl /// If asserts or exceptions are enabled, emits reference_flat_multimap_full if the reference_flat_multimap is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(value_type& value) + ETL_PAIR insert(value_type& value) { ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multimap_full)); - std::pair result(end(), false); + ETL_PAIR result(end(), false); iterator i_element = lower_bound(value.first); @@ -504,7 +505,7 @@ namespace etl //********************************************************************* size_t erase(key_parameter_t key) { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); if (range.first == end()) { @@ -512,7 +513,7 @@ namespace etl } else { - size_t d = std::distance(range.first, range.second); + size_t d = ETL_STD::distance(range.first, range.second); erase(range.first, range.second); return d; } @@ -602,9 +603,9 @@ namespace etl //********************************************************************* size_t count(key_parameter_t key) const { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); - return std::distance(range.first, range.second); + return ETL_STD::distance(range.first, range.second); } //********************************************************************* @@ -614,7 +615,7 @@ namespace etl //********************************************************************* iterator lower_bound(key_parameter_t key) { - return std::lower_bound(begin(), end(), key, compare); + return ETL_STD::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -624,7 +625,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(key_parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare); + return ETL_STD::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -634,7 +635,7 @@ namespace etl //********************************************************************* iterator upper_bound(key_parameter_t key) { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -644,7 +645,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(key_parameter_t key) const { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -652,11 +653,11 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { - iterator i_lower = std::lower_bound(begin(), end(), key, compare); + iterator i_lower = ETL_STD::lower_bound(begin(), end(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); + return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, end(), key, compare)); } //********************************************************************* @@ -664,11 +665,11 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { - const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); + const_iterator i_lower = ETL_STD::lower_bound(cbegin(), cend(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); + return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, cend(), key, compare)); } //************************************************************************* @@ -740,9 +741,9 @@ namespace etl ///\param i_element The place to insert. ///\param value The value to insert. //********************************************************************* - std::pair insert_at(iterator i_element, value_type& value) + ETL_PAIR insert_at(iterator i_element, value_type& value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); if (i_element == end()) { @@ -798,7 +799,7 @@ namespace etl template bool operator ==(const etl::ireference_flat_multimap& lhs, const etl::ireference_flat_multimap& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -814,15 +815,15 @@ namespace etl return !(lhs == rhs); } - template > //*************************************************************************** /// A reference_flat_multimap implementation that uses a fixed size buffer. ///\tparam TKey The key type. ///\tparam TValue The value type. - ///\tparam TCompare The type to compare keys. Default = std::less + ///\tparam TCompare The type to compare keys. Default = ETL_STD::less ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\ingroup reference_flat_multimap //*************************************************************************** + template > class reference_flat_multimap : public ireference_flat_multimap { public: diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index 0b612f37..5832da70 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -98,7 +98,7 @@ namespace etl /// Can be used as a reference type for all reference_flat_multisets containing a specific type. ///\ingroup reference_flat_multiset //*************************************************************************** - template > + template > class ireference_flat_multiset { public: @@ -119,7 +119,7 @@ namespace etl public: //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -217,7 +217,7 @@ namespace etl }; //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -316,9 +316,9 @@ namespace etl public: - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the reference_flat_multiset. @@ -439,7 +439,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full)); #endif @@ -456,13 +456,13 @@ namespace etl /// If asserts or exceptions are enabled, emits reference_flat_multiset_full if the reference_flat_multiset is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(value_type& value) + ETL_PAIR insert(value_type& value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full)); - iterator i_element = std::lower_bound(begin(), end(), value, compare); + iterator i_element = ETL_STD::lower_bound(begin(), end(), value, compare); if (i_element == end()) { @@ -516,7 +516,7 @@ namespace etl //********************************************************************* size_t erase(parameter_t key) { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); if (range.first == end()) { @@ -524,7 +524,7 @@ namespace etl } else { - size_t d = std::distance(range.first, range.second); + size_t d = ETL_STD::distance(range.first, range.second); erase(range.first, range.second); return d; } @@ -566,7 +566,7 @@ namespace etl //********************************************************************* iterator find(parameter_t key) { - iterator itr = std::lower_bound(begin(), end(), key, compare); + iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -590,7 +590,7 @@ namespace etl //********************************************************************* const_iterator find(parameter_t key) const { - const_iterator itr = std::lower_bound(begin(), end(), key, compare); + const_iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -614,9 +614,9 @@ namespace etl //********************************************************************* size_t count(parameter_t key) const { - std::pair range = equal_range(key); + ETL_PAIR range = equal_range(key); - return std::distance(range.first, range.second); + return ETL_STD::distance(range.first, range.second); } //********************************************************************* @@ -626,7 +626,7 @@ namespace etl //********************************************************************* iterator lower_bound(parameter_t key) { - return std::lower_bound(begin(), end(), key, compare); + return ETL_STD::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -636,7 +636,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare); + return ETL_STD::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -646,7 +646,7 @@ namespace etl //********************************************************************* iterator upper_bound(parameter_t key) { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -656,7 +656,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(parameter_t key) const { - return std::upper_bound(cbegin(), cend(), key, compare); + return ETL_STD::upper_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -664,9 +664,9 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) + ETL_PAIR equal_range(parameter_t key) { - return std::equal_range(begin(), end(), key, compare); + return ETL_STD::equal_range(begin(), end(), key, compare); } //********************************************************************* @@ -674,9 +674,9 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) const + ETL_PAIR equal_range(parameter_t key) const { - return std::equal_range(begin(), end(), key, compare); + return ETL_STD::equal_range(begin(), end(), key, compare); } //************************************************************************* @@ -748,9 +748,9 @@ namespace etl ///\param i_element The place to insert. ///\param value The value to insert. //********************************************************************* - std::pair insert_at(iterator i_element, reference value) + ETL_PAIR insert_at(iterator i_element, reference value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); if (i_element == end()) { @@ -805,7 +805,7 @@ namespace etl /// An reference flat set ///\ingroup reference_flat_multiset //*************************************************************************** - template > + template > class reference_flat_multiset : public ireference_flat_multiset { public: @@ -868,7 +868,7 @@ namespace etl template bool operator ==(const etl::ireference_flat_multiset& lhs, const etl::ireference_flat_multiset& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 7a34c743..816255e8 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -45,6 +45,7 @@ SOFTWARE. #include "error_handler.h" #include "exception.h" #include "vector.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "32" @@ -98,7 +99,7 @@ namespace etl /// Can be used as a reference type for all reference_flat_sets containing a specific type. ///\ingroup reference_flat_set //*************************************************************************** - template > + template > class ireference_flat_set { public: @@ -119,7 +120,7 @@ namespace etl public: //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -217,7 +218,7 @@ namespace etl }; //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -316,9 +317,9 @@ namespace etl public: - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the reference_flat_set. @@ -439,7 +440,7 @@ namespace etl void assign(TIterator first, TIterator last) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full)); #endif @@ -456,7 +457,7 @@ namespace etl /// If asserts or exceptions are enabled, emits reference_flat_set_full if the reference_flat_set is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(reference value) + ETL_PAIR insert(reference value) { iterator i_element = lower_bound(value); @@ -546,7 +547,7 @@ namespace etl //********************************************************************* iterator find(parameter_t key) { - iterator itr = std::lower_bound(begin(), end(), key, compare); + iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -570,7 +571,7 @@ namespace etl //********************************************************************* const_iterator find(parameter_t key) const { - const_iterator itr = std::lower_bound(begin(), end(), key, compare); + const_iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -604,7 +605,7 @@ namespace etl //********************************************************************* iterator lower_bound(parameter_t key) { - return std::lower_bound(begin(), end(), key, compare); + return ETL_STD::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -614,7 +615,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare); + return ETL_STD::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -624,7 +625,7 @@ namespace etl //********************************************************************* iterator upper_bound(parameter_t key) { - return std::upper_bound(begin(), end(), key, compare); + return ETL_STD::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -634,7 +635,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(parameter_t key) const { - return std::upper_bound(cbegin(), cend(), key, compare); + return ETL_STD::upper_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -642,9 +643,9 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) + ETL_PAIR equal_range(parameter_t key) { - return std::equal_range(begin(), end(), key, compare); + return ETL_STD::equal_range(begin(), end(), key, compare); } //********************************************************************* @@ -652,9 +653,9 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair. //********************************************************************* - std::pair equal_range(parameter_t key) const + ETL_PAIR equal_range(parameter_t key) const { - return std::upper_bound(cbegin(), cend(), key, compare); + return ETL_STD::upper_bound(cbegin(), cend(), key, compare); } //************************************************************************* @@ -726,9 +727,9 @@ namespace etl ///\param i_element The place to insert. ///\param value The value to insert. //********************************************************************* - std::pair insert_at(iterator i_element, reference value) + ETL_PAIR insert_at(iterator i_element, reference value) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); if (i_element == end()) { @@ -787,7 +788,7 @@ namespace etl /// An reference flat set ///\ingroup reference_flat_set //*************************************************************************** - template > + template > class reference_flat_set : public ireference_flat_set { public: @@ -850,7 +851,7 @@ namespace etl template bool operator ==(const etl::ireference_flat_set& lhs, const etl::ireference_flat_set& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** diff --git a/include/etl/scheduler.h b/include/etl/scheduler.h index c5c14b2a..ea6b89dc 100644 --- a/include/etl/scheduler.h +++ b/include/etl/scheduler.h @@ -285,7 +285,7 @@ namespace etl if (!task_list.full()) { - typename task_list_t::iterator itask = std::upper_bound(task_list.begin(), + typename task_list_t::iterator itask = ETL_STD::upper_bound(task_list.begin(), task_list.end(), task.get_task_priority(), compare_priority()); diff --git a/include/etl/set.h b/include/etl/set.h index 31ab2c52..b8d1e399 100755 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -44,6 +44,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" #include "parameter_type.h" +#include "iterator.h" #include "stl/algorithm.h" #include "stl/iterator.h" @@ -456,7 +457,7 @@ namespace etl /// A templated base for all etl::set types. ///\ingroup set //*************************************************************************** - template > + template > class iset : public etl::set_base { public: @@ -548,7 +549,7 @@ namespace etl //************************************************************************* /// iterator. //************************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -653,7 +654,7 @@ namespace etl //************************************************************************* /// const_iterator //************************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -760,10 +761,10 @@ namespace etl }; friend class const_iterator; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; //************************************************************************* /// Assignment operator. @@ -910,9 +911,9 @@ namespace etl /// Returns two iterators with bounding (lower bound, upper bound) the /// value provided //************************************************************************* - std::pair equal_range(const value_type& value) + ETL_PAIR equal_range(const value_type& value) { - return std::make_pair( + return ETL_MAKE_PAIR( iterator(*this, find_lower_node(root_node, value)), iterator(*this, find_upper_node(root_node, value))); } @@ -921,9 +922,9 @@ namespace etl /// Returns two const iterators with bounding (lower bound, upper bound) /// the value provided. //************************************************************************* - std::pair equal_range(const value_type& value) const + ETL_PAIR equal_range(const value_type& value) const { - return std::make_pair( + return ETL_MAKE_PAIR( const_iterator(*this, find_lower_node(root_node, value)), const_iterator(*this, find_upper_node(root_node, value))); } @@ -1014,7 +1015,7 @@ namespace etl /// If asserts or exceptions are enabled, emits set_full if the set is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(value_type& value) + ETL_PAIR insert(value_type& value) { // Default to no inserted node Node* inserted_node = nullptr; @@ -1030,7 +1031,7 @@ namespace etl inserted = inserted_node == &node; // Insert node into tree and return iterator to new node location in tree - return std::make_pair(iterator(*this, inserted_node), inserted); + return ETL_MAKE_PAIR(iterator(*this, inserted_node), inserted); } //********************************************************************* @@ -1949,7 +1950,7 @@ namespace etl //************************************************************************* /// A templated set implementation that uses a fixed size buffer. //************************************************************************* - template > + template > class set : public etl::iset { public: @@ -2036,7 +2037,7 @@ namespace etl template bool operator ==(const etl::iset& lhs, const etl::iset& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -2062,7 +2063,7 @@ namespace etl template bool operator <(const etl::iset& lhs, const etl::iset& rhs) { - return std::lexicographical_compare(lhs.begin(), + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); diff --git a/include/etl/stack.h b/include/etl/stack.h index 43b09a75..beba0899 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -278,7 +278,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(stack_full)); #endif base_t::add_in(); - ::new (&p_buffer[top_index]) T(std::forward(args)...); + ::new (&p_buffer[top_index]) T(ETL_STD::forward(args)...); } #else //************************************************************************* @@ -408,7 +408,7 @@ namespace etl //************************************************************************* void reverse() { - std::reverse(p_buffer, p_buffer + current_size); + ETL_STD::reverse(p_buffer, p_buffer + current_size); } //************************************************************************* diff --git a/include/etl/state_chart.h b/include/etl/state_chart.h index 4602a882..800c7545 100644 --- a/include/etl/state_chart.h +++ b/include/etl/state_chart.h @@ -235,7 +235,7 @@ namespace etl } else { - return std::find_if(state_table.begin(), + return ETL_STD::find_if(state_table.begin(), state_table.end(), is_state(state_id)); } @@ -280,7 +280,7 @@ namespace etl while (t != transition_table.end()) { // Scan the transition table from the latest position. - t = std::find_if(t, + t = ETL_STD::find_if(t, transition_table.end(), is_transition(event_id, current_state_id)); diff --git a/include/etl/stl/algorithm.h b/include/etl/stl/algorithm.h index 43c1aaa7..20df7f5b 100644 --- a/include/etl/stl/algorithm.h +++ b/include/etl/stl/algorithm.h @@ -33,6 +33,10 @@ SOFTWARE. #include "../platform.h" +#include "../private/choose_namespace.h" +#include "../private/choose_tag_types.h" +#include "../private/choose_pair_types.h" + #if defined(ETL_NO_STL) #include "alternate/algorithm.h" #else diff --git a/include/etl/stl/alternate/algorithm.h b/include/etl/stl/alternate/algorithm.h index 57f67402..38974d14 100644 --- a/include/etl/stl/alternate/algorithm.h +++ b/include/etl/stl/alternate/algorithm.h @@ -32,22 +32,59 @@ SOFTWARE. #define ETL_STL_ALTERNATE_ALGORITHM_INCLUDED #include "../../platform.h" +#include "../../type_traits.h" #include -#include "../../type_traits.h" +#include "etl/private/choose_tag_types.h" +#include "etl/private/choose_pair_types.h" -#include "choose_namespace.h" +// Local alternate definitions. #include "iterator.h" #include "functional.h" #include "utility.h" -namespace ETLSTD +namespace etlstd { + //*************************************************************************** + // swap + template + void swap(T& a, T& b) + { + T c = a; + a = b; + b = c; + } + + //*************************************************************************** + // iter_swap + template + void iter_swap(TIterator1 a, TIterator2 b) + { + typename etlstd::iterator_traits::value_type c = *a; + *a = *b; + *b = c; + } + + //*************************************************************************** + // swap_ranges + template + TIterator2 swap_ranges(T1terator1 first1, + T1terator1 last1, + TIterator2 first2) + { + while (first1 != last1) + { + iter_swap(first1++, first2++); + } + + return first2; + } + //*************************************************************************** // advance template - typename etl::enable_if::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type + typename etl::enable_if::iterator_tag, etlstd::random_access_iterator_tag>::value, void>::type advance(TIterator itr, TDistance distance) { while (distance-- != 0) @@ -57,7 +94,7 @@ namespace ETLSTD } template - typename etl::enable_if::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type + typename etl::enable_if::iterator_tag, etlstd::random_access_iterator_tag>::value, void>::type advance(TIterator itr, TDistance distance) { return itr += distance; @@ -69,11 +106,11 @@ namespace ETLSTD template typename etl::enable_if::value && etl::is_pointer::value && - etl::is_pod::value_type>::value, TIterator2>::type + etl::is_pod::value_type>::value, TIterator2>::type copy(TIterator1 sb, TIterator1 se, TIterator2 db) { - typedef typename ETLSTD::iterator_traits::value_type value_t; - typedef typename ETLSTD::iterator_traits::difference_type difference_t; + typedef typename etlstd::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::difference_type difference_t; difference_t count = (se - sb); @@ -84,7 +121,7 @@ namespace ETLSTD template typename etl::enable_if::value || !etl::is_pointer::value || - !etl::is_pod::value_type>::value, TIterator2>::type + !etl::is_pod::value_type>::value, TIterator2>::type copy(TIterator1 sb, TIterator1 se, TIterator2 db) { while (sb != se) @@ -95,16 +132,29 @@ namespace ETLSTD return db; } + //*************************************************************************** + // reverse_copy + template + TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db) + { + while (sb != se) + { + *(db++) = *(--se); + } + + return db; + } + //*************************************************************************** // copy_n // Pointer template typename etl::enable_if::value && etl::is_pointer::value && - etl::is_pod::value_type>::value, TIterator2>::type + etl::is_pod::value_type>::value, TIterator2>::type copy_n(TIterator1 sb, TSize count, TIterator2 db) { - typedef typename ETLSTD::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::value_type value_t; return TIterator2(memcpy(db, sb, sizeof(value_t) * count)) + count; } @@ -113,7 +163,7 @@ namespace ETLSTD template typename etl::enable_if::value || !etl::is_pointer::value || - !etl::is_pod::value_type>::value, TIterator2>::type + !etl::is_pod::value_type>::value, TIterator2>::type copy_n(TIterator1 sb, TSize count, TIterator2 db) { while (count != 0) @@ -131,10 +181,10 @@ namespace ETLSTD template typename etl::enable_if::value && etl::is_pointer::value && - etl::is_pod::value_type>::value, TIterator2>::type + etl::is_pod::value_type>::value, TIterator2>::type copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) { - typedef typename ETLSTD::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::value_type value_t; const size_t length = (se - sb); @@ -145,7 +195,7 @@ namespace ETLSTD template typename etl::enable_if::value || !etl::is_pointer::value || - !etl::is_pod::value_type>::value, TIterator2>::type + !etl::is_pod::value_type>::value, TIterator2>::type copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) { while (se != sb) @@ -174,7 +224,7 @@ namespace ETLSTD { while (sb != se) { - *db++ = ETLSTD::move(*sb++); + *db++ = etlstd::move(*sb++); } return db; @@ -187,27 +237,55 @@ namespace ETLSTD { while (sb != se) { - *(--de) = ETLSTD::move(*(--se)); + *(--de) = etlstd::move(*(--se)); } return de; } + //*************************************************************************** + // reverse + // Pointers + template + typename etl::enable_if::value, void>::type + reverse(TIterator b, TIterator e) + { + if (b != e) + { + while (b < --e) + { + etlstd::iter_swap(b, e); + ++b; + } + } + } + + // Other + template + typename etl::enable_if::value, void>::type + reverse(TIterator b, TIterator e) + { + while ((b != e) && (b != --e)) + { + etlstd::iter_swap(b++, e); + } + } + //*************************************************************************** // lower_bound template TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) { - typedef typename ETLSTD::iterator_traits::difference_type difference_t; + typedef typename etlstd::iterator_traits::difference_type difference_t; - difference_t count = ETLSTD::distance(first, last); + difference_t count = etlstd::distance(first, last); while (count > 0) { TIterator itr = first; difference_t step = count / 2; - ETLSTD::advance(itr, step); + etlstd::advance(itr, step); if (compare(*itr, value)) { @@ -226,9 +304,9 @@ namespace ETLSTD template TIterator lower_bound(TIterator first, TIterator last, const TValue& value) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - return ETLSTD::lower_bound(first, last, value, compare()); + return etlstd::lower_bound(first, last, value, compare()); } //*************************************************************************** @@ -236,16 +314,16 @@ namespace ETLSTD template TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) { - typedef typename ETLSTD::iterator_traits::difference_type difference_t; + typedef typename etlstd::iterator_traits::difference_type difference_t; - difference_t count = ETLSTD::distance(first, last); + difference_t count = etlstd::distance(first, last); while (count > 0) { TIterator itr = first; difference_t step = count / 2; - ETLSTD::advance(itr, step); + etlstd::advance(itr, step); if (!compare(value, *itr)) { @@ -264,27 +342,27 @@ namespace ETLSTD template TIterator upper_bound(TIterator first, TIterator last, const TValue& value) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - return ETLSTD::upper_bound(first, last, value, compare()); + return etlstd::upper_bound(first, last, value, compare()); } //*************************************************************************** // equal_range template - ETLSTD::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare) + ETL_PAIR equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare) { - return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare), - ETLSTD::upper_bound(first, last, value, compare)); + return ETL_MAKE_PAIR(etlstd::lower_bound(first, last, value, compare), + etlstd::upper_bound(first, last, value, compare)); } template - ETLSTD::pair equal_range(TIterator first, TIterator last, const TValue& value) + ETL_PAIR equal_range(TIterator first, TIterator last, const TValue& value) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare()), - ETLSTD::upper_bound(first, last, value, compare())); + return ETL_MAKE_PAIR(etlstd::lower_bound(first, last, value, compare()), + etlstd::upper_bound(first, last, value, compare())); } //*************************************************************************** @@ -403,30 +481,10 @@ namespace ETLSTD return n; } - //*************************************************************************** - // swap - template - void swap(T& a, T& b) - { - T c = a; - a = b; - b = c; - } - - //*************************************************************************** - // iter_swap - template - void iter_swap(TIterator1 a, TIterator2 b) - { - typename ETLSTD::iterator_traits::value_type c = *a; - *a = *b; - *b = c; - } - //*************************************************************************** // equal template - typename etl::enable_if::value || !etl::is_pointer::value || !etl::is_pod::value_type>::value, bool>::type + typename etl::enable_if::value || !etl::is_pointer::value || !etl::is_pod::value_type>::value, bool>::type equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) { while (first1 != last1) @@ -441,12 +499,12 @@ namespace ETLSTD } template - typename etl::enable_if::value && etl::is_pointer::value && etl::is_pod::value_type>::value, bool>::type + typename etl::enable_if::value && etl::is_pointer::value && etl::is_pod::value_type>::value, bool>::type equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) { - typedef typename ETLSTD::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::value_type value_t; - return (memcmp(first1, first2, sizeof(value_t) * (last1 - last1)) == 0); + return (memcmp(first1, first2, sizeof(value_t) * (last1 - first1)) == 0); } //*************************************************************************** @@ -481,9 +539,9 @@ namespace ETLSTD bool lexicographical_compare(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - return ETLSTD::lexicographical_compare(first1, last1, first2, last2, compare()); + return etlstd::lexicographical_compare(first1, last1, first2, last2, compare()); } //*************************************************************************** @@ -497,9 +555,9 @@ namespace ETLSTD template const T& min(const T& a, const T& b) { - typedef ETLSTD::less compare; + typedef etlstd::less compare; - return ETLSTD::min(a, b, compare()); + return etlstd::min(a, b, compare()); } //*************************************************************************** @@ -513,9 +571,9 @@ namespace ETLSTD template const T& max(const T& a, const T& b) { - typedef ETLSTD::less compare; + typedef etlstd::less compare; - return ETLSTD::max(a, b, compare()); + return etlstd::max(a, b, compare()); } //*************************************************************************** @@ -617,8 +675,8 @@ namespace ETLSTD template void pop_heap(TIterator first, TIterator last, TCompare compare) { - typedef typename ETLSTD::iterator_traits::value_type value_t; - typedef typename ETLSTD::iterator_traits::difference_type distance_t; + typedef typename etlstd::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::difference_type distance_t; value_t value = last[-1]; last[-1] = first[0]; @@ -630,17 +688,17 @@ namespace ETLSTD template void pop_heap(TIterator first, TIterator last) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - ETLSTD::pop_heap(first, last, compare()); + etlstd::pop_heap(first, last, compare()); } // Push Heap template void push_heap(TIterator first, TIterator last, TCompare compare) { - typedef typename ETLSTD::iterator_traits::difference_type difference_t; - typedef typename ETLSTD::iterator_traits::value_type value_t; + typedef typename etlstd::iterator_traits::difference_type difference_t; + typedef typename etlstd::iterator_traits::value_type value_t; private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(*(last - 1)), compare); } @@ -649,16 +707,16 @@ namespace ETLSTD template void push_heap(TIterator first, TIterator last) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - ETLSTD::push_heap(first, last, compare()); + etlstd::push_heap(first, last, compare()); } // Make Heap template void make_heap(TIterator first, TIterator last, TCompare compare) { - typedef typename ETLSTD::iterator_traits::difference_type difference_t; + typedef typename etlstd::iterator_traits::difference_type difference_t; if ((last - first) < 2) { @@ -685,16 +743,16 @@ namespace ETLSTD template void make_heap(TIterator first, TIterator last) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; - ETLSTD::make_heap(first, last, compare()); + etlstd::make_heap(first, last, compare()); } // Is Heap template bool is_heap(TIterator first, TIterator last) { - typedef ETLSTD::less::value_type> compare; + typedef etlstd::less::value_type> compare; return private_heap::is_heap(first, last - first, compare()); } @@ -711,45 +769,43 @@ namespace ETLSTD template TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare) { - if (search_first == search_last) + while (true) { - return first; - } + TIterator1 itr = first; + TIterator2 search_itr = search_first; - while (first != last) - { - TIterator1 itr1 = first; - TIterator2 itr2 = search_first; - - while (compare(*itr1,*itr2)) + while (true) { - if (itr2 == search_last) + if (search_itr == search_last) { return first; } - if (itr1 == last) + if (itr == last) { return last; } - ++itr1; - ++itr2; + if (!compare(*itr, *search_itr)) + { + break; + } + + ++itr; + ++search_itr; } ++first; } - - return last; } // Search template TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last) { - typedef ETLSTD::equal_to::value_type> compare; + typedef etlstd::equal_to::value_type> compare; - return ETLSTD::search(first, last, search_first, search_last, compare()); + return etlstd::search(first, last, search_first, search_last, compare()); } //*************************************************************************** @@ -761,7 +817,7 @@ namespace ETLSTD while (first != next) { - ETLSTD::swap(*first++, *next++); + etlstd::swap(*first++, *next++); if (next == last) { @@ -775,6 +831,49 @@ namespace ETLSTD return first; } + + //*************************************************************************** + // find_end + // Predicate + template + TIterator1 find_end(TIterator1 b, TIterator1 e, + TIterator2 sb, TIterator2 se, + TPredicate predicate) + { + if (sb == se) + { + return e; + } + + TIterator1 result = e; + + while (true) + { + TIterator1 new_result = etlstd::search(b, e, sb, se, predicate); + + if (new_result == e) + { + break; + } + else + { + result = new_result; + b = result; + ++b; + } + } + return result; + } + + // Default + template + TIterator1 find_end(TIterator1 b, TIterator1 e, + TIterator2 sb, TIterator2 se) + { + typedef etlstd::equal_to::value_type> predicate; + + return find_end(b, e, sb, se, predicate()); + } } #endif diff --git a/include/etl/stl/alternate/functional.h b/include/etl/stl/alternate/functional.h index 3c991081..7ff28b5f 100644 --- a/include/etl/stl/alternate/functional.h +++ b/include/etl/stl/alternate/functional.h @@ -3,9 +3,11 @@ #define ETL_STL_ALTERNATE_FUNCTIONAL_INCLUDED #include "../../platform.h" -#include "choose_namespace.h" -namespace ETLSTD +#include "../../private/choose_tag_types.h" +#include "../../private/choose_pair_types.h" + +namespace etlstd { //*************************************************************************** template @@ -69,7 +71,7 @@ namespace ETLSTD //*************************************************************************** template - class binder1st : public ETLSTD::unary_function + class binder1st : public etlstd::unary_function { protected: @@ -103,7 +105,7 @@ namespace ETLSTD //*************************************************************************** template - class binder2nd : public ETLSTD::unary_function + class binder2nd : public etlstd::unary_function { protected: TFunction operation; diff --git a/include/etl/stl/alternate/iterator.h b/include/etl/stl/alternate/iterator.h index 6d8ce41b..0e7583c3 100644 --- a/include/etl/stl/alternate/iterator.h +++ b/include/etl/stl/alternate/iterator.h @@ -33,26 +33,15 @@ SOFTWARE. #define ETL_STL_ALTERNATE_ITERATOR_INCLUDED #include "../../platform.h" - -#include #include "../../type_traits.h" -#include "choose_namespace.h" +#include -namespace ETLSTD +#include "../../private/choose_tag_types.h" +#include "../../private/choose_pair_types.h" + +namespace etlstd { - //*************************************************************************** - // iterator - template - struct iterator - { - typedef T value_type; - typedef TDistance difference_type; - typedef TPointer pointer; - typedef TReference reference; - typedef TCategory iterator_category; - }; - //*************************************************************************** // iterator tags struct input_iterator_tag {}; @@ -66,43 +55,37 @@ namespace ETLSTD template struct iterator_traits { - typedef typename TIterator::difference_type difference_type; + typedef typename TIterator::iterator_category iterator_category; typedef typename TIterator::value_type value_type; + typedef typename TIterator::difference_type difference_type; typedef typename TIterator::pointer pointer; typedef typename TIterator::reference reference; - typedef typename TIterator::iterator_category iterator_category; }; template struct iterator_traits { - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef random_access_iterator_tag iterator_category; + typedef ETL_RANDOM_ACCESS_ITERATOR_TAG iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; }; template struct iterator_traits { - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef random_access_iterator_tag iterator_category; + typedef ETL_RANDOM_ACCESS_ITERATOR_TAG iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef const T* pointer; + typedef const T& reference; }; //*************************************************************************** // advance template - void advance(TIterator& itr, TDistance n) - { - advance_helper(itr, n, typename ETLSTD::iterator_traits::iterator_category()); - } - - template - void advance_helper(TIterator& itr, TDistance n, ETLSTD::input_iterator_tag) + ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_INPUT_ITERATOR_TAG) { while (n--) { @@ -111,7 +94,7 @@ namespace ETLSTD } template - void advance_helper(TIterator& itr, TDistance n, ETLSTD::output_iterator_tag) + ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OUTPUT_ITERATOR_TAG) { while (n--) { @@ -120,7 +103,7 @@ namespace ETLSTD } template - void advance_helper(TIterator& itr, TDistance n, ETLSTD::forward_iterator_tag) + ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_FORWARD_ITERATOR_TAG) { while (n--) { @@ -129,7 +112,7 @@ namespace ETLSTD } template - void advance_helper(TIterator& itr, TDistance n, ETLSTD::bidirectional_iterator_tag) + ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_BIDIRECTIONAL_ITERATOR_TAG) { if (n > 0) { @@ -148,23 +131,25 @@ namespace ETLSTD } template - void advance_helper(TIterator& itr, TDistance n, ETLSTD::random_access_iterator_tag) + ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_RANDOM_ACCESS_ITERATOR_TAG) { itr += n; } + template + ETL_CONSTEXPR17 void advance(TIterator& itr, TDistance n) + { + typedef typename etlstd::iterator_traits::iterator_category tag; + + advance_helper(itr, n, tag()); + } + //*************************************************************************** // distance template - typename ETLSTD::iterator_traits::difference_type distance(TIterator first, TIterator last) + ETL_CONSTEXPR17 typename etlstd::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_INPUT_ITERATOR_TAG) { - return distance_helper(first, last, typename ETLSTD::iterator_traits::iterator_category()); - } - - template - typename ETLSTD::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::input_iterator_tag) - { - typename ETLSTD::iterator_traits::difference_type d = 0; + typename etlstd::iterator_traits::difference_type d = 0; while (first != last) { @@ -176,9 +161,9 @@ namespace ETLSTD } template - typename ETLSTD::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::forward_iterator_tag) + ETL_CONSTEXPR17 typename etlstd::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_FORWARD_ITERATOR_TAG) { - typename ETLSTD::iterator_traits::difference_type d = 0; + typename etlstd::iterator_traits::difference_type d = 0; while (first != last) { @@ -190,9 +175,9 @@ namespace ETLSTD } template - typename ETLSTD::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::bidirectional_iterator_tag) + ETL_CONSTEXPR17 typename etlstd::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_BIDIRECTIONAL_ITERATOR_TAG) { - typename ETLSTD::iterator_traits::difference_type d = 0; + typename etlstd::iterator_traits::difference_type d = 0; while (first != last) { @@ -204,122 +189,134 @@ namespace ETLSTD } template - typename ETLSTD::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::random_access_iterator_tag) + ETL_CONSTEXPR17 typename etlstd::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_RANDOM_ACCESS_ITERATOR_TAG) { return last - first; } + template + ETL_CONSTEXPR17 typename etlstd::iterator_traits::difference_type distance(TIterator first, TIterator last) + { + typedef typename etlstd::iterator_traits::iterator_category tag; + + return distance_helper(first, last, tag()); + } + //*************************************************************************** // reverse_iterator template - struct reverse_iterator + class reverse_iterator { public: - typedef typename ETLSTD::iterator_traits::difference_type difference_type; - typedef typename ETLSTD::iterator_traits::value_type value_type; - typedef typename ETLSTD::iterator_traits::pointer pointer; - typedef typename ETLSTD::iterator_traits::reference reference; - typedef typename ETLSTD::iterator_traits::iterator_category iterator_category; + typedef typename iterator_traits::iterator_category iterator_category; + typedef typename iterator_traits::value_type value_type; + typedef typename iterator_traits::difference_type difference_type; + typedef typename iterator_traits::pointer pointer; + typedef typename iterator_traits::reference reference; - reverse_iterator() + typedef TIterator iterator_type; + + ETL_CONSTEXPR17 reverse_iterator() + : current() { } - explicit reverse_iterator(TIterator itr) : current(--itr) + ETL_CONSTEXPR17 explicit reverse_iterator(TIterator itr) + : current(itr) { } - reverse_iterator(const reverse_iterator& itr) - : current(itr.current) + template + ETL_CONSTEXPR17 reverse_iterator(const reverse_iterator& other) + : current(other.base()) { } - template - reverse_iterator(const reverse_iterator& itr) - : current(itr.base()) + template + ETL_CONSTEXPR17 reverse_iterator& operator=(const reverse_iterator& other) { + current = other.base(); + + return (*this); } - reverse_iterator& operator = (const reverse_iterator& itr) - { - current = itr.base(); - return *this; - } - - template - reverse_iterator& operator = (const reverse_iterator& itr) - { - current = itr.base(); - return *this; - } - - TIterator base() const + ETL_CONSTEXPR17 TIterator base() const { return current; } - reference operator *() const + ETL_NODISCARD ETL_CONSTEXPR17 reference operator*() const { - return *current; + TIterator temp = current; + + return *(--temp); } - pointer operator ->() const + ETL_NODISCARD ETL_CONSTEXPR17 pointer operator->() const { - return &(*current); + TIterator temp = current; + + return &(*--temp); } - reverse_iterator& operator ++() + ETL_CONSTEXPR17 reverse_iterator& operator++() { --current; + return *this; } - reverse_iterator operator ++(int) + ETL_CONSTEXPR17 reverse_iterator operator++(int) { - reverse_iterator temp = *this; + reverse_iterator temp = *this; --current; + return temp; } - reverse_iterator& operator --() + ETL_CONSTEXPR17 reverse_iterator& operator--() { ++current; - return *this; + + return (*this); } - reverse_iterator operator --(int) + ETL_CONSTEXPR17 reverse_iterator operator--(int) { - reverse_iterator temp = *this; + reverse_iterator temp = *this; ++current; + return temp; } - reverse_iterator operator +(difference_type n) const + ETL_CONSTEXPR17 reverse_iterator& operator+=(const difference_type offset) { - return reverse_iterator(current - n); + current -= offset; + + return (*this); } - reverse_iterator& operator +=(difference_type n) + ETL_CONSTEXPR17 reverse_iterator& operator-=(const difference_type offset) { - current -= n; - return *this; + current += offset; + + return (*this); } - reverse_iterator operator -(difference_type n) const + ETL_NODISCARD ETL_CONSTEXPR17 reverse_iterator operator+(const difference_type offset) const { - return reverse_iterator(current + n); + return reverse_iterator(current - offset); } - reverse_iterator& operator -=(difference_type n) + ETL_NODISCARD ETL_CONSTEXPR17 reverse_iterator operator-(const difference_type offset) const { - current += n; - return *this; + return (reverse_iterator(current + offset)); } - reference operator [](difference_type n) const + ETL_NODISCARD ETL_CONSTEXPR17 reference operator[](const difference_type offset) const { - return *(current - n); + return (*(*this + offset)); } protected: @@ -328,49 +325,49 @@ namespace ETLSTD }; template - inline bool operator ==(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator ==(const reverse_iterator& lhs, const reverse_iterator& rhs) { return lhs.base() == rhs.base(); } template - inline bool operator !=(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator !=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(lhs == rhs); } template - inline bool operator <(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator <(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs.base() < lhs.base(); } template - inline bool operator >(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator >(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs < lhs; } template - inline bool operator <=(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator <=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(rhs < lhs); } template - inline bool operator >=(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 bool operator >=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(lhs < rhs); } template - inline typename reverse_iterator::difference_type operator -(const reverse_iterator& lhs, const reverse_iterator& rhs) + inline ETL_CONSTEXPR17 typename reverse_iterator::difference_type operator -(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs.base() - lhs.base(); } template - inline reverse_iterator operator +(TDifference n, const reverse_iterator& itr) + inline ETL_CONSTEXPR17 reverse_iterator operator +(TDifference n, const reverse_iterator& itr) { return itr.operator +(n); } @@ -378,18 +375,18 @@ namespace ETLSTD //*************************************************************************** // Previous template - TIterator prev(TIterator itr, typename ETLSTD::iterator_traits::difference_type n = 1) + ETL_CONSTEXPR17 TIterator prev(TIterator itr, typename etlstd::iterator_traits::difference_type n = 1) { - ETLSTD::advance(itr, -n); + etlstd::advance(itr, -n); return itr; } //*************************************************************************** // Next template - TIterator next(TIterator itr, typename ETLSTD::iterator_traits::difference_type n = 1) + ETL_CONSTEXPR17 TIterator next(TIterator itr, typename etlstd::iterator_traits::difference_type n = 1) { - ETLSTD::advance(itr, n); + etlstd::advance(itr, n); return itr; } } diff --git a/include/etl/stl/alternate/limits.h b/include/etl/stl/alternate/limits.h index f8e7cac2..dc0f9a21 100644 --- a/include/etl/stl/alternate/limits.h +++ b/include/etl/stl/alternate/limits.h @@ -36,7 +36,8 @@ SOFTWARE. #include "../../char_traits.h" #include "../../integral_limits.h" -#include "choose_namespace.h" +#include "../../private/choose_tag_types.h" +#include "../../private/choose_pair_types.h" #include #include @@ -44,7 +45,7 @@ SOFTWARE. #define ETL_LOG2(x) (((x) * 301) / 1000) -namespace ETLSTD +namespace etlstd { template class numeric_limits; @@ -70,70 +71,70 @@ namespace ETLSTD class etl_integral_type { public: - static const bool is_specialized; + static ETL_CONST bool is_specialized = true; - static const int max_digits10; + static ETL_CONST int max_digits10 = 0; - static const bool is_integer; - static const bool is_exact; + static ETL_CONST bool is_integer = true; + static ETL_CONST bool is_exact = true; - static const int radix; + static ETL_CONST int radix = 2; static ETL_CONSTEXPR T epsilon() { return 0; } static ETL_CONSTEXPR T round_error() { return 0; } - static const int digits; - static const int digits10; + static ETL_CONST int digits = (CHAR_BIT * sizeof(T)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONST int digits10 = ETL_LOG2(digits); - static const bool is_signed; + static ETL_CONST bool is_signed = etl::is_signed::value; - static const int min_exponent; - static const int min_exponent10; - static const int max_exponent; - static const int max_exponent10; + static ETL_CONST int min_exponent = 0; + static ETL_CONST int min_exponent10 = 0; + static ETL_CONST int max_exponent = 0; + static ETL_CONST int max_exponent10 = 0; - static const bool has_infinity; - static const bool has_quiet_NaN; - static const bool has_signaling_NaN; - static const float_denorm_style has_denorm; - static const bool has_denorm_loss; + static ETL_CONST bool has_infinity = false; + static ETL_CONST bool has_quiet_NaN = false; + static ETL_CONST bool has_signaling_NaN = false; + static ETL_CONST float_denorm_style has_denorm = denorm_absent; + static ETL_CONST bool has_denorm_loss = false; static ETL_CONSTEXPR T infinity() { return 0; } static ETL_CONSTEXPR T quiet_NaN() { return 0; } static ETL_CONSTEXPR T signaling_NaN() { return 0; } static ETL_CONSTEXPR T denorm_min() { return 0; } - static const bool is_iec559; - static const bool is_bounded; - static const bool is_modulo; + static ETL_CONST bool is_iec559 = false; + static ETL_CONST bool is_bounded = true; + static ETL_CONST bool is_modulo = etl::is_unsigned::value; - static const bool traps; - static const bool tinyness_before; - static const float_round_style round_style; + static ETL_CONST bool traps = false; + static ETL_CONST bool tinyness_before = false; + static ETL_CONST float_round_style round_style = round_toward_zero; }; - template const bool etl_integral_type::is_specialized = true; - template const int etl_integral_type::digits = (CHAR_BIT * sizeof(T)) - (etl::is_signed::value ? 1 : 0); - template const int etl_integral_type::digits10 = ETL_LOG2(digits); - template const int etl_integral_type::max_digits10 = 0; - template const bool etl_integral_type::is_signed = etl::is_signed::value; - template const bool etl_integral_type::is_integer = true; - template const bool etl_integral_type::is_exact = true; - template const int etl_integral_type::radix = 2; - template const int etl_integral_type::min_exponent = 0; - template const int etl_integral_type::min_exponent10 = 0; - template const int etl_integral_type::max_exponent = 0; - template const int etl_integral_type::max_exponent10 = 0; - template const bool etl_integral_type::has_infinity = false; - template const bool etl_integral_type::has_quiet_NaN = false; - template const bool etl_integral_type::has_signaling_NaN = false; - template const float_denorm_style etl_integral_type::has_denorm = denorm_absent; - template const bool etl_integral_type::has_denorm_loss = false; - template const bool etl_integral_type::is_iec559 = false; - template const bool etl_integral_type::is_bounded = true; - template const bool etl_integral_type::is_modulo = etl::is_unsigned::value; - template const bool etl_integral_type::traps = false; - template const bool etl_integral_type::tinyness_before = false; - template const float_round_style etl_integral_type::round_style = round_toward_zero; + template ETL_CONST bool etl_integral_type::is_specialized; + template ETL_CONST int etl_integral_type::digits; + template ETL_CONST int etl_integral_type::digits10; + template ETL_CONST int etl_integral_type::max_digits10; + template ETL_CONST bool etl_integral_type::is_signed; + template ETL_CONST bool etl_integral_type::is_integer; + template ETL_CONST bool etl_integral_type::is_exact; + template ETL_CONST int etl_integral_type::radix; + template ETL_CONST int etl_integral_type::min_exponent; + template ETL_CONST int etl_integral_type::min_exponent10; + template ETL_CONST int etl_integral_type::max_exponent; + template ETL_CONST int etl_integral_type::max_exponent10; + template ETL_CONST bool etl_integral_type::has_infinity; + template ETL_CONST bool etl_integral_type::has_quiet_NaN; + template ETL_CONST bool etl_integral_type::has_signaling_NaN; + template ETL_CONST float_denorm_style etl_integral_type::has_denorm; + template ETL_CONST bool etl_integral_type::has_denorm_loss; + template ETL_CONST bool etl_integral_type::is_iec559; + template ETL_CONST bool etl_integral_type::is_bounded; + template ETL_CONST bool etl_integral_type::is_modulo; + template ETL_CONST bool etl_integral_type::traps; + template ETL_CONST bool etl_integral_type::tinyness_before; + template ETL_CONST float_round_style etl_integral_type::round_style; //*************************************************************************** // Base for floating point types. @@ -141,50 +142,50 @@ namespace ETLSTD class etl_floating_point_type { public: - static const bool is_specialized; + static ETL_CONST bool is_specialized = true; - static const bool is_signed; - static const bool is_integer; - static const bool is_exact; + static ETL_CONST bool is_signed = true; + static ETL_CONST bool is_integer = false; + static ETL_CONST bool is_exact = false; - static const int radix; + static ETL_CONST int radix = 2; - static const bool has_infinity; - static const bool has_quiet_NaN; - static const bool has_signaling_NaN; - static const float_denorm_style has_denorm; - static const bool has_denorm_loss; + static ETL_CONST bool has_infinity = false; + static ETL_CONST bool has_quiet_NaN = false; + static ETL_CONST bool has_signaling_NaN = false; + static ETL_CONST float_denorm_style has_denorm = denorm_present; + static ETL_CONST bool has_denorm_loss = true; - static const bool is_iec559; - static const bool is_bounded; - static const bool is_modulo; + static ETL_CONST bool is_iec559 = true; + static ETL_CONST bool is_bounded = true; + static ETL_CONST bool is_modulo = false; static ETL_CONSTEXPR T round_error() { return T(0.5); } static ETL_CONSTEXPR T infinity() { return 0; } static ETL_CONSTEXPR T quiet_NaN() { return 0; } static ETL_CONSTEXPR T signaling_NaN() { return 0; } - static const bool traps; - static const bool tinyness_before; - static const float_round_style round_style; + static ETL_CONST bool traps = false; + static ETL_CONST bool tinyness_before = true; + static ETL_CONST float_round_style round_style = round_to_nearest; }; - template const bool etl_floating_point_type::is_specialized = true; - template const bool etl_floating_point_type::is_signed = true; - template const bool etl_floating_point_type::is_integer = false; - template const bool etl_floating_point_type::is_exact = false; - template const int etl_floating_point_type::radix = 2; - template const bool etl_floating_point_type::has_infinity = false; - template const bool etl_floating_point_type::has_quiet_NaN = false; - template const bool etl_floating_point_type::has_signaling_NaN = false; - template const float_denorm_style etl_floating_point_type::has_denorm = denorm_present; - template const bool etl_floating_point_type::has_denorm_loss = true; - template const bool etl_floating_point_type::is_iec559 = true; - template const bool etl_floating_point_type::is_bounded = true; - template const bool etl_floating_point_type::is_modulo = false; - template const bool etl_floating_point_type::traps = false; - template const bool etl_floating_point_type::tinyness_before = true; - template const float_round_style etl_floating_point_type::round_style = round_to_nearest; + template ETL_CONST bool etl_floating_point_type::is_specialized; + template ETL_CONST bool etl_floating_point_type::is_signed; + template ETL_CONST bool etl_floating_point_type::is_integer; + template ETL_CONST bool etl_floating_point_type::is_exact; + template ETL_CONST int etl_floating_point_type::radix; + template ETL_CONST bool etl_floating_point_type::has_infinity; + template ETL_CONST bool etl_floating_point_type::has_quiet_NaN; + template ETL_CONST bool etl_floating_point_type::has_signaling_NaN; + template ETL_CONST float_denorm_style etl_floating_point_type::has_denorm; + template ETL_CONST bool etl_floating_point_type::has_denorm_loss; + template ETL_CONST bool etl_floating_point_type::is_iec559; + template ETL_CONST bool etl_floating_point_type::is_bounded; + template ETL_CONST bool etl_floating_point_type::is_modulo; + template ETL_CONST bool etl_floating_point_type::traps; + template ETL_CONST bool etl_floating_point_type::tinyness_before; + template ETL_CONST float_round_style etl_floating_point_type::round_style; //*************************************************************************** // Default @@ -198,72 +199,72 @@ namespace ETLSTD { public: - static const bool is_specialized; + static ETL_CONST bool is_specialized = true; static ETL_CONSTEXPR bool min() { return false; } static ETL_CONSTEXPR bool max() { return true; } static ETL_CONSTEXPR bool lowest() { return false; } - static const int digits; - static const int digits10; - static const int max_digits10; + static ETL_CONST int digits = 1; + static ETL_CONST int digits10 = 0; + static ETL_CONST int max_digits10 = 0; - static const bool is_signed; - static const bool is_integer; - static const bool is_exact; + static ETL_CONST bool is_signed = false; + static ETL_CONST bool is_integer = true; + static ETL_CONST bool is_exact = true; - static const int radix; - static const bool epsilon() { return 0; } - static const bool round_error() { return 0; } + static ETL_CONST int radix = 2; + static ETL_CONST bool epsilon() { return 0; } + static ETL_CONST bool round_error() { return 0; } - static const int min_exponent; - static const int min_exponent10; - static const int max_exponent; - static const int max_exponent10; + static ETL_CONST int min_exponent = 0; + static ETL_CONST int min_exponent10 = 0; + static ETL_CONST int max_exponent = 0; + static ETL_CONST int max_exponent10 = 0; - static const bool has_infinity; - static const bool has_quiet_NaN; - static const bool has_signaling_NaN; - static const float_denorm_style has_denorm; - static const bool has_denorm_loss; + static ETL_CONST bool has_infinity = false; + static ETL_CONST bool has_quiet_NaN = false; + static ETL_CONST bool has_signaling_NaN = false; + static ETL_CONST float_denorm_style has_denorm = denorm_absent; + static ETL_CONST bool has_denorm_loss = false; static ETL_CONSTEXPR bool infinity() { return 0; } static ETL_CONSTEXPR bool quiet_NaN() { return 0; } static ETL_CONSTEXPR bool signaling_NaN() { return 0; } static ETL_CONSTEXPR bool denorm_min() { return 0; } - static const bool is_iec559; - static const bool is_bounded; - static const bool is_modulo; + static ETL_CONST bool is_iec559 = false; + static ETL_CONST bool is_bounded = true; + static ETL_CONST bool is_modulo = false; - static const bool traps; - static const bool tinyness_before; - static const float_round_style round_style; + static ETL_CONST bool traps = false; + static ETL_CONST bool tinyness_before = false; + static ETL_CONST float_round_style round_style = round_toward_zero; }; - const bool numeric_limits::is_specialized = true; - const int numeric_limits::digits = 1; - const int numeric_limits::digits10 = 0; - const int numeric_limits::max_digits10 = 0; - const bool numeric_limits::is_signed = false; - const bool numeric_limits::is_integer = true; - const bool numeric_limits::is_exact = true; - const int numeric_limits::radix = 2; - const int numeric_limits::min_exponent = 0; - const int numeric_limits::min_exponent10 = 0; - const int numeric_limits::max_exponent = 0; - const int numeric_limits::max_exponent10 = 0; - const bool numeric_limits::has_infinity = false; - const bool numeric_limits::has_quiet_NaN = false; - const bool numeric_limits::has_signaling_NaN = false; - const float_denorm_style numeric_limits::has_denorm = denorm_absent; - const bool numeric_limits::has_denorm_loss = false; - const bool numeric_limits::is_iec559 = false; - const bool numeric_limits::is_bounded = true; - const bool numeric_limits::is_modulo = false; - const bool numeric_limits::traps = false; - const bool numeric_limits::tinyness_before = false; - const float_round_style numeric_limits::round_style = round_toward_zero; + ETL_CONST bool numeric_limits::is_specialized; + ETL_CONST int numeric_limits::digits; + ETL_CONST int numeric_limits::digits10; + ETL_CONST int numeric_limits::max_digits10; + ETL_CONST bool numeric_limits::is_signed; + ETL_CONST bool numeric_limits::is_integer; + ETL_CONST bool numeric_limits::is_exact; + ETL_CONST int numeric_limits::radix; + ETL_CONST int numeric_limits::min_exponent; + ETL_CONST int numeric_limits::min_exponent10; + ETL_CONST int numeric_limits::max_exponent; + ETL_CONST int numeric_limits::max_exponent10; + ETL_CONST bool numeric_limits::has_infinity; + ETL_CONST bool numeric_limits::has_quiet_NaN; + ETL_CONST bool numeric_limits::has_signaling_NaN; + ETL_CONST float_denorm_style numeric_limits::has_denorm; + ETL_CONST bool numeric_limits::has_denorm_loss; + ETL_CONST bool numeric_limits::is_iec559; + ETL_CONST bool numeric_limits::is_bounded; + ETL_CONST bool numeric_limits::is_modulo; + ETL_CONST bool numeric_limits::traps; + ETL_CONST bool numeric_limits::tinyness_before; + ETL_CONST float_round_style numeric_limits::round_style; //*************************************************************************** // char @@ -446,23 +447,23 @@ namespace ETLSTD static ETL_CONSTEXPR float epsilon() { return FLT_EPSILON; } static ETL_CONSTEXPR float denorm_min() { return FLT_MIN; } - static const int digits; - static const int digits10; - static const int max_digits10; + static ETL_CONST int digits = FLT_MANT_DIG; + static ETL_CONST int digits10 = FLT_DIG; + static ETL_CONST int max_digits10 = ETL_LOG2(FLT_MANT_DIG) + 2; - static const int min_exponent; - static const int min_exponent10; - static const int max_exponent; - static const int max_exponent10; + static ETL_CONST int min_exponent = FLT_MIN_EXP; + static ETL_CONST int min_exponent10 = FLT_MIN_10_EXP; + static ETL_CONST int max_exponent = FLT_MAX_EXP; + static ETL_CONST int max_exponent10 = FLT_MAX_10_EXP; }; - const int numeric_limits::digits = FLT_MANT_DIG; - const int numeric_limits::max_digits10 = ETL_LOG2(FLT_MANT_DIG) + 2; - const int numeric_limits::digits10 = FLT_DIG; - const int numeric_limits::min_exponent = FLT_MIN_EXP; - const int numeric_limits::min_exponent10 = FLT_MIN_10_EXP; - const int numeric_limits::max_exponent = FLT_MAX_EXP; - const int numeric_limits::max_exponent10 = FLT_MAX_10_EXP; + ETL_CONST int numeric_limits::digits; + ETL_CONST int numeric_limits::max_digits10; + ETL_CONST int numeric_limits::digits10; + ETL_CONST int numeric_limits::min_exponent; + ETL_CONST int numeric_limits::min_exponent10; + ETL_CONST int numeric_limits::max_exponent; + ETL_CONST int numeric_limits::max_exponent10; //*************************************************************************** // double @@ -477,23 +478,23 @@ namespace ETLSTD static ETL_CONSTEXPR double epsilon() { return DBL_EPSILON; } static ETL_CONSTEXPR double denorm_min() { return DBL_MIN; } - static const int digits; - static const int digits10; - static const int max_digits10; + static ETL_CONST int digits = DBL_MANT_DIG; + static ETL_CONST int digits10 = DBL_DIG; + static ETL_CONST int max_digits10 = ETL_LOG2(DBL_MANT_DIG) + 2; - static const int min_exponent; - static const int min_exponent10; - static const int max_exponent; - static const int max_exponent10; + static ETL_CONST int min_exponent = DBL_MIN_EXP; + static ETL_CONST int min_exponent10 = DBL_MIN_10_EXP; + static ETL_CONST int max_exponent = DBL_MAX_EXP; + static ETL_CONST int max_exponent10 = DBL_MAX_10_EXP; }; - const int numeric_limits::digits = DBL_MANT_DIG; - const int numeric_limits::max_digits10 = ETL_LOG2(DBL_MANT_DIG) + 2; - const int numeric_limits::digits10 = DBL_DIG; - const int numeric_limits::min_exponent = DBL_MIN_EXP; - const int numeric_limits::min_exponent10 = DBL_MIN_10_EXP; - const int numeric_limits::max_exponent = DBL_MAX_EXP; - const int numeric_limits::max_exponent10 = DBL_MAX_10_EXP; + ETL_CONST int numeric_limits::digits; + ETL_CONST int numeric_limits::max_digits10; + ETL_CONST int numeric_limits::digits10; + ETL_CONST int numeric_limits::min_exponent; + ETL_CONST int numeric_limits::min_exponent10; + ETL_CONST int numeric_limits::max_exponent; + ETL_CONST int numeric_limits::max_exponent10; //*************************************************************************** // long double @@ -508,23 +509,23 @@ namespace ETLSTD static ETL_CONSTEXPR long double epsilon() { return LDBL_EPSILON; } static ETL_CONSTEXPR long double denorm_min() { return LDBL_MIN; } - static const int digits; - static const int digits10; - static const int max_digits10; + static ETL_CONST int digits = LDBL_MANT_DIG; + static ETL_CONST int digits10 = LDBL_DIG; + static ETL_CONST int max_digits10 = ETL_LOG2(LDBL_MANT_DIG) + 2; - static const int min_exponent; - static const int min_exponent10; - static const int max_exponent; - static const int max_exponent10; + static ETL_CONST int min_exponent = LDBL_MIN_EXP; + static ETL_CONST int min_exponent10 = LDBL_MIN_10_EXP; + static ETL_CONST int max_exponent = LDBL_MAX_EXP; + static ETL_CONST int max_exponent10 = LDBL_MAX_10_EXP; }; - const int numeric_limits::digits = LDBL_MANT_DIG; - const int numeric_limits::max_digits10 = ETL_LOG2(LDBL_MANT_DIG) + 2; - const int numeric_limits::digits10 = LDBL_DIG; - const int numeric_limits::min_exponent = LDBL_MIN_EXP; - const int numeric_limits::min_exponent10 = LDBL_MIN_10_EXP; - const int numeric_limits::max_exponent = LDBL_MAX_EXP; - const int numeric_limits::max_exponent10 = LDBL_MAX_10_EXP; + ETL_CONST int numeric_limits::digits; + ETL_CONST int numeric_limits::max_digits10; + ETL_CONST int numeric_limits::digits10; + ETL_CONST int numeric_limits::min_exponent; + ETL_CONST int numeric_limits::min_exponent10; + ETL_CONST int numeric_limits::max_exponent; + ETL_CONST int numeric_limits::max_exponent10; } #endif diff --git a/include/etl/stl/alternate/utility.h b/include/etl/stl/alternate/utility.h index 86af9e18..ac0bfc00 100644 --- a/include/etl/stl/alternate/utility.h +++ b/include/etl/stl/alternate/utility.h @@ -34,9 +34,10 @@ SOFTWARE. #include "../../platform.h" #include "../../type_traits.h" -#include "choose_namespace.h" +#include "../../private/choose_tag_types.h" +#include "../../private/choose_pair_types.h" -namespace ETLSTD +namespace etlstd { //****************************************************************************** template diff --git a/include/etl/stl/functional.h b/include/etl/stl/functional.h index f3fd0034..89052b39 100644 --- a/include/etl/stl/functional.h +++ b/include/etl/stl/functional.h @@ -4,6 +4,10 @@ #include "../platform.h" +#include "../private/choose_namespace.h" +#include "../private/choose_tag_types.h" +#include "../private/choose_pair_types.h" + #if defined(ETL_NO_STL) #include "alternate/functional.h" #else diff --git a/include/etl/stl/iterator.h b/include/etl/stl/iterator.h index 56f2e5d6..60e157ec 100644 --- a/include/etl/stl/iterator.h +++ b/include/etl/stl/iterator.h @@ -34,6 +34,10 @@ SOFTWARE. #include "../platform.h" +#include "../private/choose_namespace.h" +#include "../private/choose_tag_types.h" +#include "../private/choose_pair_types.h" + #if defined(ETL_NO_STL) #include "alternate/iterator.h" #else diff --git a/include/etl/stl/limits.h b/include/etl/stl/limits.h index 6a0ce1d4..477f5244 100644 --- a/include/etl/stl/limits.h +++ b/include/etl/stl/limits.h @@ -33,6 +33,10 @@ SOFTWARE. #include "../platform.h" +#include "../private/choose_namespace.h" +#include "../private/choose_tag_types.h" +#include "../private/choose_pair_types.h" + #if defined(ETL_NO_STL) #include "alternate/limits.h" #else diff --git a/include/etl/stl/utility.h b/include/etl/stl/utility.h index 24a5990f..eb8e99b8 100644 --- a/include/etl/stl/utility.h +++ b/include/etl/stl/utility.h @@ -33,6 +33,10 @@ SOFTWARE. #include "../platform.h" +#include "../private/choose_namespace.h" +#include "../private/choose_tag_types.h" +#include "../private/choose_pair_types.h" + #if defined(ETL_NO_STL) #include "alternate/utility.h" #else diff --git a/include/etl/string_view.h b/include/etl/string_view.h index a7c46232..413b56d0 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -109,7 +109,7 @@ namespace etl typedef const T& const_reference; typedef const T* const_pointer; typedef const T* const_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; enum { @@ -313,7 +313,7 @@ namespace etl void assign(TIterator begin_, TIterator end_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + std::distance(begin_, end_); + mend = etl::addressof(*begin_) + ETL_STD::distance(begin_, end_); } //************************************************************************* @@ -351,8 +351,8 @@ namespace etl //************************************************************************* void swap(basic_string_view& other) { - std::swap(mbegin, other.mbegin); - std::swap(mend, other.mend); + ETL_STD::swap(mbegin, other.mbegin); + ETL_STD::swap(mend, other.mend); } //************************************************************************* @@ -364,9 +364,9 @@ namespace etl if (position < size()) { - n = std::min(count, size() - position); + n = ETL_STD::min(count, size() - position); - std::copy(mbegin + position, mbegin + position + n, destination); + ETL_STD::copy(mbegin + position, mbegin + position + n, destination); } return n; @@ -381,7 +381,7 @@ namespace etl if (position < size()) { - size_t n = std::min(count, size() - position); + size_t n = ETL_STD::min(count, size() - position); view = basic_string_view(mbegin + position, mbegin + position + n); } @@ -495,7 +495,7 @@ namespace etl return npos; } - const_iterator iposition = std::search(begin() + position, end(), view.begin(), view.end()); + const_iterator iposition = ETL_STD::search(begin() + position, end(), view.begin(), view.end()); if (iposition == end()) { @@ -503,7 +503,7 @@ namespace etl } else { - return std::distance(begin(), iposition); + return ETL_STD::distance(begin(), iposition); } } @@ -532,12 +532,12 @@ namespace etl return npos; } - position = std::min(position, size()); + position = ETL_STD::min(position, size()); - const_iterator iposition = std::find_end(begin(), - begin() + position, - view.begin(), - view.end()); + const_iterator iposition = ETL_STD::find_end(begin(), + begin() + position, + view.begin(), + view.end()); if (iposition == end()) { @@ -545,7 +545,7 @@ namespace etl } else { - return std::distance(begin(), iposition); + return ETL_STD::distance(begin(), iposition); } } @@ -615,7 +615,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -711,7 +711,7 @@ namespace etl return npos; } - position = std::min(position, size() - 1); + position = ETL_STD::min(position, size() - 1); const_reverse_iterator it = rbegin() + size() - position - 1; @@ -762,7 +762,7 @@ namespace etl friend bool operator == (const etl::basic_string_view& lhs, const etl::basic_string_view& rhs) { return (lhs.size() == rhs.size()) && - std::equal(lhs.begin(), lhs.end(), rhs.begin()); + ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //************************************************************************* @@ -778,7 +778,7 @@ namespace etl //************************************************************************* friend bool operator < (const etl::basic_string_view& lhs, const etl::basic_string_view& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //************************************************************************* diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 03d97f56..4ef1d146 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -180,7 +180,7 @@ namespace etl { ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); new_string.assign(buffer + position, buffer + position + length_); } diff --git a/include/etl/u32string.h b/include/etl/u32string.h index a8f9b769..64112c49 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -180,7 +180,7 @@ namespace etl { ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); new_string.assign(buffer + position, buffer + position + length_); } diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 355173ed..8f27ffaf 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -54,6 +54,7 @@ SOFTWARE. #include "error_handler.h" #include "exception.h" #include "debug_count.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "16" @@ -126,12 +127,12 @@ namespace etl /// Can be used as a reference type for all unordered_map containing a specific type. ///\ingroup unordered_map //*************************************************************************** - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class iunordered_map { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; typedef TKey key_type; typedef T mapped_type; @@ -171,7 +172,7 @@ namespace etl typedef typename bucket_t::const_iterator local_const_iterator; //********************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -331,7 +332,7 @@ namespace etl }; //********************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -481,7 +482,7 @@ namespace etl local_iterator inode; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the unordered_map. @@ -608,7 +609,7 @@ namespace etl { size_t index = bucket(key); - return std::distance(pbuckets[index].begin(), pbuckets[index].end()); + return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end()); } //********************************************************************* @@ -751,7 +752,7 @@ namespace etl void assign(TIterator first_, TIterator last_) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first_, last_); + difference_type d = ETL_STD::distance(first_, last_); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_map_iterator)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_map_full)); #endif @@ -769,9 +770,9 @@ namespace etl /// If asserts or exceptions are enabled, emits unordered_map_full if the unordered_map is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const value_type& key_value_pair) + ETL_PAIR insert(const value_type& key_value_pair) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); ETL_ASSERT(!full(), ETL_ERROR(unordered_map_full)); @@ -1081,7 +1082,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { iterator f = find(key); iterator l = f; @@ -1091,7 +1092,7 @@ namespace etl ++l; } - return std::pair(f, l); + return ETL_PAIR(f, l); } //********************************************************************* @@ -1102,7 +1103,7 @@ namespace etl ///\param key The key to search for. ///\return A const iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { const_iterator f = find(key); const_iterator l = f; @@ -1112,7 +1113,7 @@ namespace etl ++l; } - return std::pair(f, l); + return ETL_PAIR(f, l); } //************************************************************************* @@ -1369,7 +1370,7 @@ namespace etl template bool operator ==(const etl::iunordered_map& lhs, const etl::iunordered_map& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1388,7 +1389,7 @@ namespace etl //************************************************************************* /// A templated unordered_map implementation that uses a fixed size buffer. //************************************************************************* - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class unordered_map : public etl::iunordered_map { private: diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 8eb08512..7a4edc26 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -54,6 +54,7 @@ SOFTWARE. #include "error_handler.h" #include "exception.h" #include "debug_count.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "25" @@ -126,12 +127,12 @@ namespace etl /// Can be used as a reference type for all unordered_multimap containing a specific type. ///\ingroup unordered_multimap //*************************************************************************** - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class iunordered_multimap { public: - typedef std::pair value_type; + typedef ETL_PAIR value_type; typedef TKey key_type; typedef T mapped_type; @@ -170,7 +171,7 @@ namespace etl typedef typename bucket_t::const_iterator local_const_iterator; //********************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -330,7 +331,7 @@ namespace etl }; //********************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -481,7 +482,7 @@ namespace etl local_iterator inode; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the unordered_multimap. @@ -608,7 +609,7 @@ namespace etl { size_t index = bucket(key); - return std::distance(pbuckets[index].begin(), pbuckets[index].end()); + return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end()); } //********************************************************************* @@ -640,7 +641,7 @@ namespace etl void assign(TIterator first_, TIterator last_) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first_, last_); + difference_type d = ETL_STD::distance(first_, last_); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multimap_iterator)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multimap_full)); #endif @@ -981,7 +982,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { iterator f = find(key); iterator l = f; @@ -996,7 +997,7 @@ namespace etl } } - return std::pair(f, l); + return ETL_PAIR(f, l); } //********************************************************************* @@ -1007,7 +1008,7 @@ namespace etl ///\param key The key to search for. ///\return A const iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { const_iterator f = find(key); const_iterator l = f; @@ -1022,7 +1023,7 @@ namespace etl } } - return std::pair(f, l); + return ETL_PAIR(f, l); } //************************************************************************* @@ -1278,7 +1279,7 @@ namespace etl template bool operator ==(const etl::iunordered_multimap& lhs, const etl::iunordered_multimap& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1297,7 +1298,7 @@ namespace etl //************************************************************************* /// A templated unordered_multimap implementation that uses a fixed size buffer. //************************************************************************* - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class unordered_multimap : public etl::iunordered_multimap { private: diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index b40c415e..3b634a7b 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -53,6 +53,7 @@ SOFTWARE. #include "error_handler.h" #include "exception.h" #include "debug_count.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "26" @@ -125,7 +126,7 @@ namespace etl /// Can be used as a reference type for all unordered_multiset containing a specific type. ///\ingroup unordered_multiset //*************************************************************************** - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class iunordered_multiset { public: @@ -167,7 +168,7 @@ namespace etl typedef typename bucket_t::const_iterator local_const_iterator; //********************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -326,7 +327,7 @@ namespace etl }; //********************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -476,7 +477,7 @@ namespace etl local_iterator inode; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the unordered_multiset. @@ -603,7 +604,7 @@ namespace etl { size_t index = bucket(key); - return std::distance(pbuckets[index].begin(), pbuckets[index].end()); + return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end()); } //********************************************************************* @@ -635,7 +636,7 @@ namespace etl void assign(TIterator first_, TIterator last_) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first_, last_); + difference_type d = ETL_STD::distance(first_, last_); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multiset_iterator)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multiset_full)); #endif @@ -653,9 +654,9 @@ namespace etl /// If asserts or exceptions are enabled, emits unordered_multiset_full if the unordered_multiset is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const value_type& key) + ETL_PAIR insert(const value_type& key) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); ETL_ASSERT(!full(), ETL_ERROR(unordered_multiset_full)); @@ -976,7 +977,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { iterator f = find(key); iterator l = f; @@ -991,7 +992,7 @@ namespace etl } } - return std::pair(f, l); + return ETL_PAIR(f, l); } //********************************************************************* @@ -1002,7 +1003,7 @@ namespace etl ///\param key The key to search for. ///\return A const iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { const_iterator f = find(key); const_iterator l = f; @@ -1017,7 +1018,7 @@ namespace etl } } - return std::pair(f, l); + return ETL_PAIR(f, l); } //************************************************************************* @@ -1273,7 +1274,7 @@ namespace etl template bool operator ==(const etl::iunordered_multiset& lhs, const etl::iunordered_multiset& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1292,7 +1293,7 @@ namespace etl //************************************************************************* /// A templated unordered_multiset implementation that uses a fixed size buffer. //************************************************************************* - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class unordered_multiset : public etl::iunordered_multiset { private: diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 49313116..1babd690 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -54,6 +54,7 @@ SOFTWARE. #include "exception.h" #include "error_handler.h" #include "debug_count.h" +#include "iterator.h" #undef ETL_FILE #define ETL_FILE "23" @@ -126,7 +127,7 @@ namespace etl /// Can be used as a reference type for all unordered_set containing a specific type. ///\ingroup unordered_set //*************************************************************************** - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class iunordered_set { public: @@ -168,7 +169,7 @@ namespace etl typedef typename bucket_t::const_iterator local_const_iterator; //********************************************************************* - class iterator : public std::iterator + class iterator : public etl::iterator { public: @@ -327,7 +328,7 @@ namespace etl }; //********************************************************************* - class const_iterator : public std::iterator + class const_iterator : public etl::iterator { public: @@ -477,7 +478,7 @@ namespace etl local_iterator inode; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; //********************************************************************* /// Returns an iterator to the beginning of the unordered_set. @@ -604,7 +605,7 @@ namespace etl { size_t index = bucket(key); - return std::distance(pbuckets[index].begin(), pbuckets[index].end()); + return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end()); } //********************************************************************* @@ -636,7 +637,7 @@ namespace etl void assign(TIterator first_, TIterator last_) { #if defined(ETL_DEBUG) - difference_type d = std::distance(first_, last_); + difference_type d = ETL_STD::distance(first_, last_); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_set_iterator)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_set_full)); #endif @@ -654,9 +655,9 @@ namespace etl /// If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set is already full. ///\param value The value to insert. //********************************************************************* - std::pair insert(const value_type& key) + ETL_PAIR insert(const value_type& key) { - std::pair result(end(), false); + ETL_PAIR result(end(), false); ETL_ASSERT(!full(), ETL_ERROR(unordered_set_full)); @@ -963,7 +964,7 @@ namespace etl ///\param key The key to search for. ///\return An iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) + ETL_PAIR equal_range(key_parameter_t key) { iterator f = find(key); iterator l = f; @@ -973,7 +974,7 @@ namespace etl ++l; } - return std::pair(f, l); + return ETL_PAIR(f, l); } //********************************************************************* @@ -984,7 +985,7 @@ namespace etl ///\param key The key to search for. ///\return A const iterator pair to the range of elements if the key exists, otherwise end(). //********************************************************************* - std::pair equal_range(key_parameter_t key) const + ETL_PAIR equal_range(key_parameter_t key) const { const_iterator f = find(key); const_iterator l = f; @@ -994,7 +995,7 @@ namespace etl ++l; } - return std::pair(f, l); + return ETL_PAIR(f, l); } //************************************************************************* @@ -1250,7 +1251,7 @@ namespace etl template bool operator ==(const etl::iunordered_set& lhs, const etl::iunordered_set& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1269,7 +1270,7 @@ namespace etl //************************************************************************* /// A templated unordered_set implementation that uses a fixed size buffer. //************************************************************************* - template , typename TKeyEqual = std::equal_to > + template , typename TKeyEqual = ETL_STD::equal_to > class unordered_set : public etl::iunordered_set { private: diff --git a/include/etl/variant.h b/include/etl/variant.h index bde656f6..dd84fc72 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -723,7 +723,7 @@ namespace etl ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); - ::new (static_cast(data)) T(std::forward(args)...); + ::new (static_cast(data)) T(ETL_STD::forward(args)...); type_id = Type_Id_Lookup::type_id; return *static_cast(data); diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index e5b6f295..f9823f6c 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -31,7 +31,7 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** //*************************************************************************** @@ -54,9 +54,6 @@ SOFTWARE. #include #include "platform.h" - -#include "stl/utility.h" - #include "error_handler.h" #include "exception.h" #include "largest.h" @@ -66,6 +63,8 @@ SOFTWARE. #include "type_lookup.h" #include "pool.h" +#include "stl/utility.h" + #undef ETL_FILE #define ETL_FILE "40" @@ -135,7 +134,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) || defined(ETL_NO_STL) +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* @@ -291,7 +290,7 @@ namespace etl if (p != nullptr) { - new (p) T(std::forward(args)...); + new (p) T(ETL_STD::forward(args)...); } } diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 62a2f923..47d305e7 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -357,7 +357,7 @@ namespace etl if (p != nullptr) { - new (p) T(std::forward(args)...); + new (p) T(ETL_STD::forward(args)...); } } diff --git a/include/etl/vector.h b/include/etl/vector.h index ac05ce40..4cc0f656 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -92,10 +92,10 @@ namespace etl typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef ETL_STD::reverse_iterator reverse_iterator; + typedef ETL_STD::reverse_iterator const_reverse_iterator; typedef size_t size_type; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename ETL_STD::iterator_traits::difference_type difference_type; protected: @@ -365,17 +365,17 @@ namespace etl template void assign(TIterator first, TIterator last) { - ETL_STATIC_ASSERT((etl::is_same::type, typename etl::remove_cv::value_type>::type>::value), "Iterator type does not match container type"); + ETL_STATIC_ASSERT((etl::is_same::type, typename etl::remove_cv::value_type>::type>::value), "Iterator type does not match container type"); #if defined(ETL_DEBUG) - difference_type d = std::distance(first, last); + difference_type d = ETL_STD::distance(first, last); ETL_ASSERT(static_cast(d) <= CAPACITY, ETL_ERROR(vector_full)); #endif initialise(); p_end = etl::uninitialized_copy(first, last, p_buffer); - ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last))) + ETL_ADD_DEBUG_COUNT(uint32_t(ETL_STD::distance(first, last))) } //********************************************************************* @@ -426,7 +426,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); #endif - create_back(std::move(value)); + create_back(ETL_STD::move(value)); } #endif @@ -442,7 +442,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); #endif - ::new (p_end) T(std::forward(args)...); + ::new (p_end) T(ETL_STD::forward(args)...); ++p_end; ETL_INCREMENT_DEBUG_COUNT } @@ -541,7 +541,7 @@ namespace etl else { create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); *position = value; } @@ -561,13 +561,13 @@ namespace etl if (position == end()) { - create_back(std::move(value)); + create_back(ETL_STD::move(value)); } else { - create_back(std::move(back())); - std::move_backward(position, p_end - 2, p_end - 1); - *position = std::move(value); + create_back(ETL_STD::move(back())); + ETL_STD::move_backward(position, p_end - 2, p_end - 1); + *position = ETL_STD::move(value); } return position; @@ -594,11 +594,11 @@ namespace etl { p = etl::addressof(*position); create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); (*position).~T(); } - ::new (p) T(std::forward(args)...); + ::new (p) T(ETL_STD::forward(args)...); return position; } @@ -619,7 +619,7 @@ namespace etl { p = etl::addressof(*position); create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); (*position).~T(); } @@ -644,7 +644,7 @@ namespace etl { p = etl::addressof(*position); create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); (*position).~T(); } @@ -669,7 +669,7 @@ namespace etl { p = etl::addressof(*position); create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); (*position).~T(); } @@ -694,7 +694,7 @@ namespace etl { p = etl::addressof(*position); create_back(back()); - std::copy_backward(position, p_end - 2, p_end - 1); + ETL_STD::copy_backward(position, p_end - 2, p_end - 1); (*position).~T(); } @@ -716,7 +716,7 @@ namespace etl ETL_ASSERT((size() + n) <= CAPACITY, ETL_ERROR(vector_full)); size_t insert_n = n; - size_t insert_begin = std::distance(begin(), position); + size_t insert_begin = ETL_STD::distance(begin(), position); size_t insert_end = insert_begin + insert_n; // Copy old data. @@ -745,14 +745,14 @@ namespace etl ETL_ADD_DEBUG_COUNT(construct_old_n) // Copy old. - std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); + ETL_STD::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); // Construct new. etl::uninitialized_fill_n(p_end, construct_new_n, value); ETL_ADD_DEBUG_COUNT(construct_new_n) // Copy new. - std::fill_n(p_buffer + insert_begin, copy_new_n, value); + ETL_STD::fill_n(p_buffer + insert_begin, copy_new_n, value); p_end += n; } @@ -768,12 +768,12 @@ namespace etl template void insert(iterator position, TIterator first, TIterator last) { - size_t count = std::distance(first, last); + size_t count = ETL_STD::distance(first, last); ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); size_t insert_n = count; - size_t insert_begin = std::distance(begin(), position); + size_t insert_begin = ETL_STD::distance(begin(), position); size_t insert_end = insert_begin + insert_n; // Copy old data. @@ -802,7 +802,7 @@ namespace etl ETL_ADD_DEBUG_COUNT(construct_old_n) // Copy old. - std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); + ETL_STD::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); // Construct new. etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end); @@ -821,7 +821,7 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { - std::copy(i_element + 1, end(), i_element); + ETL_STD::copy(i_element + 1, end(), i_element); destroy_back(); return i_element; @@ -843,8 +843,8 @@ namespace etl } else { - std::copy(last, end(), first); - size_t n_delete = std::distance(first, last); + ETL_STD::copy(last, end(), first); + size_t n_delete = ETL_STD::distance(first, last); // Destroy the elements left over at the end. etl::destroy(p_end - n_delete, p_end); @@ -880,7 +880,7 @@ namespace etl iterator itr = rhs.begin(); while (itr != rhs.end()) { - push_back(std::move(*itr)); + push_back(ETL_STD::move(*itr)); ++itr; } @@ -952,7 +952,7 @@ namespace etl void initialise() { etl::destroy(p_buffer, p_end); - ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) p_end = p_buffer; } @@ -962,7 +962,7 @@ namespace etl //********************************************************************* void initialise_source_external_buffer_after_move() { - ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) p_end = p_buffer; } @@ -972,7 +972,7 @@ namespace etl //********************************************************************* void initialise_destination_external_buffer_after_move() { - ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) + ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end))) } //************************************************************************* @@ -1018,7 +1018,7 @@ namespace etl //********************************************************************* inline void create_back(rvalue_reference value) { - etl::create_copy_at(p_end, std::move(value)); + etl::create_copy_at(p_end, ETL_STD::move(value)); ETL_INCREMENT_DEBUG_COUNT ++p_end; @@ -1065,7 +1065,7 @@ namespace etl template bool operator ==(const etl::ivector& lhs, const etl::ivector& rhs) { - return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); + return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin()); } //*************************************************************************** @@ -1091,7 +1091,7 @@ namespace etl template bool operator <(const etl::ivector& lhs, const etl::ivector& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } //*************************************************************************** @@ -1243,7 +1243,7 @@ namespace etl typename etl::ivector::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -1262,7 +1262,7 @@ namespace etl typename etl::ivector::iterator itr = rhs.begin(); while (itr != rhs.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -1290,7 +1290,7 @@ namespace etl void repair() { #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - ETL_ASSERT(std::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); + ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); #endif etl::ivector::repair_buffer(buffer); @@ -1445,7 +1445,7 @@ namespace etl void repair() { #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - ETL_ASSERT(std::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); + ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); #endif etl::ivector::repair_buffer(this->p_buffer); @@ -1560,7 +1560,7 @@ namespace etl typename etl::ivector::iterator itr = other.begin(); while (itr != other.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } @@ -1579,7 +1579,7 @@ namespace etl typename etl::ivector::iterator itr = rhs.begin(); while (itr != rhs.end()) { - this->push_back(std::move(*itr)); + this->push_back(ETL_STD::move(*itr)); ++itr; } diff --git a/include/etl/version.h b/include/etl/version.h index eddca2d1..7f310e09 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,9 +37,9 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION_MAJOR 14 -#define ETL_VERSION_MINOR 38 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MAJOR 15 +#define ETL_VERSION_MINOR 0 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 16d59ae4..6eab06a6 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -181,7 +181,7 @@ namespace etl { ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); - length_ = std::min(length_, size() - position); + length_ = ETL_STD::min(length_, size() - position); new_string.assign(buffer + position, buffer + position + length_); } diff --git a/library.json b/library.json index e0ed9cdc..bce97949 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "14.38.2", + "version": "15.0.0", "authors": { "name": "John Wellbelove", "email": "" diff --git a/library.properties b/library.properties index ee58bd62..1a7492f1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=14.38.2 +version=15.0.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index d44f9448..8873de5f 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +15.0.0 +Unit tests and library code updated so that the ETL may be compiled and tested +with and without STL support. + =============================================================================== 14.38.2 Added alternate 'No STL' reverse_iterator unit tests. diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index e0b2ee4a..3ce6a93c 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -25,6 +25,26 @@ + + -