From 37d2d9e08498f5c81ba30bc54b327a85264872c5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 29 Apr 2018 20:23:22 +0100 Subject: [PATCH 01/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/private/minmax_pop.h --- include/etl/algorithm.h | 4 +- include/etl/alignment.h | 10 +- include/etl/array.h | 4 +- include/etl/array_view.h | 8 +- include/etl/array_wrapper.h | 6 +- include/etl/atomic.h | 4 +- include/etl/atomic/atomic_arm.h | 4 +- include/etl/atomic/atomic_gcc_sync.h | 4 +- include/etl/atomic/atomic_std.h | 4 +- include/etl/basic_string.h | 20 +- include/etl/binary.h | 233 ++++++++-- include/etl/bitset.h | 12 +- include/etl/bloom_filter.h | 12 +- include/etl/c/ecl_timer.h | 4 +- include/etl/callback_timer.h | 8 +- include/etl/char_traits.h | 4 +- include/etl/checksum.h | 4 +- include/etl/combinations.h | 4 +- include/etl/compare.h | 4 +- include/etl/constant.h | 4 +- include/etl/container.h | 4 +- include/etl/crc16.h | 4 +- include/etl/crc16_ccitt.h | 4 +- include/etl/crc16_kermit.h | 4 +- include/etl/crc32.h | 4 +- include/etl/crc64_ecma.h | 4 +- include/etl/crc8_ccitt.h | 4 +- include/etl/cstring.h | 16 +- include/etl/cyclic_value.h | 4 +- include/etl/debounce.h | 14 +- include/etl/debug_count.h | 64 +-- include/etl/deque.h | 68 ++- include/etl/endianness.h | 4 +- include/etl/enum_type.h | 4 +- include/etl/error_handler.h | 4 +- include/etl/exception.h | 4 +- include/etl/factorial.h | 4 +- include/etl/fibonacci.h | 4 +- include/etl/file_error_numbers.txt | 4 +- include/etl/fixed_iterator.h | 4 +- include/etl/flat_map.h | 28 +- include/etl/flat_multimap.h | 24 +- include/etl/flat_multiset.h | 22 +- include/etl/flat_set.h | 26 +- include/etl/fnv_1.h | 4 +- include/etl/forward_list.h | 42 +- include/etl/fsm.h | 12 +- include/etl/fsm_generator.h | 14 +- include/etl/function.h | 4 +- include/etl/functional.h | 4 +- include/etl/generate.bat | 3 +- include/etl/generate_type_select.bat | 1 + include/etl/hash.h | 22 +- include/etl/ihash.h | 4 +- include/etl/instance_count.h | 4 +- include/etl/integral_limits.h | 14 +- include/etl/intrusive_forward_list.h | 12 +- include/etl/intrusive_links.h | 4 +- include/etl/intrusive_list.h | 12 +- include/etl/intrusive_queue.h | 4 +- include/etl/intrusive_stack.h | 4 +- include/etl/io_port.h | 4 +- include/etl/iterator.h | 4 +- include/etl/jenkins.h | 4 +- include/etl/largest.h | 4 +- include/etl/largest_generator.h | 6 +- include/etl/list.h | 50 +-- include/etl/log.h | 4 +- include/etl/map.h | 20 +- include/etl/memory.h | 4 +- include/etl/memory_model.h | 46 ++ include/etl/message.h | 4 +- include/etl/message_bus.h | 4 +- include/etl/message_router.h | 4 +- include/etl/message_router_generator.h | 6 +- include/etl/message_timer.h | 8 +- include/etl/message_types.h | 4 +- include/etl/multimap.h | 20 +- include/etl/multiset.h | 20 +- include/etl/murmur3.h | 4 +- include/etl/mutex.h | 4 +- include/etl/mutex/mutex_arm.h | 4 +- include/etl/mutex/mutex_gcc_sync.h | 4 +- include/etl/mutex/mutex_std.h | 4 +- include/etl/null_type.h | 50 +++ include/etl/nullptr.h | 4 +- include/etl/numeric.h | 4 +- include/etl/observer.h | 4 +- include/etl/optional.h | 4 +- include/etl/packet.h | 4 +- include/etl/parameter_type.h | 4 +- include/etl/pearson.h | 4 +- include/etl/permutations.h | 4 +- include/etl/platform.h | 4 +- include/etl/pool.h | 4 +- include/etl/power.h | 4 +- include/etl/priority_queue.h | 4 +- include/etl/private/ivectorpointer.h | 6 +- include/etl/private/minmax_pop.h | 39 ++ include/etl/private/minmax_push.h | 41 ++ include/etl/private/pvoidvector.h | 16 +- include/etl/private/vector_base.h | 10 +- include/etl/profiles/arduino_arm.h | 4 +- include/etl/profiles/armv5.h | 4 +- include/etl/profiles/armv6.h | 4 +- include/etl/profiles/cpp03.h | 4 +- include/etl/profiles/cpp11.h | 4 +- include/etl/profiles/cpp14.h | 4 +- include/etl/profiles/gcc_generic.h | 4 +- include/etl/profiles/gcc_linux_x86.h | 4 +- include/etl/profiles/gcc_windows_x86.h | 4 +- include/etl/profiles/msvc_x86.h | 4 +- include/etl/profiles/ticc.h | 4 +- include/etl/queue.h | 24 +- include/etl/queue_mpmc_mutex.h | 8 +- include/etl/queue_spsc_atomic.h | 8 +- include/etl/queue_spsc_isr.h | 8 +- include/etl/radix.h | 4 +- include/etl/random.h | 4 +- include/etl/reference_flat_map.h | 4 +- include/etl/reference_flat_multimap.h | 4 +- include/etl/reference_flat_multiset.h | 4 +- include/etl/reference_flat_set.h | 4 +- include/etl/scheduler.h | 4 +- include/etl/set.h | 20 +- include/etl/smallest.h | 14 +- include/etl/smallest_generator.h | 16 +- include/etl/sqrt.h | 4 +- include/etl/stack.h | 18 +- include/etl/static_assert.h | 4 +- include/etl/string_view.h | 22 +- include/etl/task.h | 4 +- include/etl/timer.h | 4 +- include/etl/type_def.h | 4 +- include/etl/type_lookup.h | 121 +++-- include/etl/type_lookup_generator.h | 29 +- include/etl/type_select.h | 590 +++++++++++++++++++++++++ include/etl/type_select_generator.h | 134 ++++++ include/etl/type_traits.h | 4 +- include/etl/type_traits_generator.h | 6 +- include/etl/u16string.h | 16 +- include/etl/u32string.h | 16 +- include/etl/unordered_map.h | 20 +- include/etl/unordered_multimap.h | 18 +- include/etl/unordered_multiset.h | 18 +- include/etl/unordered_set.h | 18 +- include/etl/user_type.h | 4 +- include/etl/utility.h | 4 +- include/etl/variant.h | 36 +- include/etl/variant_pool.h | 4 +- include/etl/variant_pool_generator.h | 6 +- include/etl/vector.h | 101 ++--- include/etl/version.h | 8 +- include/etl/visitor.h | 4 +- include/etl/wstring.h | 16 +- support/Release notes.txt | 14 + test/codeblocks/ETL.cbp | 3 + test/data.h | 4 +- test/ecl_user.h | 4 +- test/etl_profile.h | 5 +- test/test_array_view.cpp | 2 +- test/test_array_wrapper.cpp | 2 +- test/test_binary.cpp | 210 ++++++++- test/test_bitset.cpp | 3 - test/test_constant.cpp | 2 - test/test_integral_limits.cpp | 3 - test/test_queue_mpmc_mutex.cpp | 38 +- test/test_string_char.cpp | 4 +- test/test_string_u16.cpp | 4 +- test/test_string_u32.cpp | 4 +- test/test_string_wchar_t.cpp | 4 +- test/test_type_select.cpp | 116 +++++ test/vs2017/etl.vcxproj | 5 + test/vs2017/etl.vcxproj.filters | 15 + 174 files changed, 2202 insertions(+), 936 deletions(-) create mode 100644 include/etl/generate_type_select.bat create mode 100644 include/etl/memory_model.h create mode 100644 include/etl/null_type.h create mode 100644 include/etl/private/minmax_pop.h create mode 100644 include/etl/private/minmax_push.h create mode 100644 include/etl/type_select.h create mode 100644 include/etl/type_select_generator.h create mode 100644 test/test_type_select.cpp diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 463dfd32..67917e26 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ALGORITHM__ -#define __ETL_ALGORITHM__ +#ifndef ETL_ALGORITHM_INCLUDED +#define ETL_ALGORITHM_INCLUDED ///\defgroup algorithm algorithm /// Reverse engineered algorithms from C++ 0x11 diff --git a/include/etl/alignment.h b/include/etl/alignment.h index 39565c3a..1867874b 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ALIGNEMENT__ -#define __ETL_ALIGNEMENT__ +#ifndef ETL_ALIGNEMENT_INCLUDED +#define ETL_ALIGNEMENT_INCLUDED #include @@ -43,7 +43,7 @@ SOFTWARE. namespace etl { - namespace __private_alignment__ + namespace private_alignment { //*************************************************************************** // Matcher. @@ -99,7 +99,7 @@ namespace etl { public: - typedef typename __private_alignment__::type_with_alignment_helper::type type; + typedef typename private_alignment::type_with_alignment_helper::type type; }; //*************************************************************************** @@ -183,7 +183,7 @@ namespace etl union { char data[LENGTH]; - typename etl::type_with_alignment::type __etl_alignment_type__; // A POD type that has the same alignment as ALIGNMENT. + typename etl::type_with_alignment::type etl_alignment_type; // A POD type that has the same alignment as ALIGNMENT. }; }; }; diff --git a/include/etl/array.h b/include/etl/array.h index d36af55b..06c096a7 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY__ -#define __ETL_ARRAY__ +#ifndef ETL_ARRAY_INCLUDED +#define ETL_ARRAY_INCLUDED #include #include diff --git a/include/etl/array_view.h b/include/etl/array_view.h index c3e1ff46..7a9722c7 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY_VIEW__ -#define __ETL_ARRAY_VIEW__ +#ifndef ETL_ARRAY_VIEW_INCLUDED +#define ETL_ARRAY_VIEW_INCLUDED #include "platform.h" #include "memory.h" @@ -832,7 +832,7 @@ namespace etl { size_t operator()(const etl::array_view& view) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&view[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), reinterpret_cast(&view[view.size()])); } }; @@ -842,7 +842,7 @@ namespace etl { size_t operator()(const etl::const_array_view& view) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&view[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), reinterpret_cast(&view[view.size()])); } }; diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index ba839c38..ec840350 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY_WRAPPER__ -#define __ETL_ARRAY_WRAPPER__ +#ifndef ETL_ARRAY_WRAPPER_INCLUDED +#define ETL_ARRAY_WRAPPER_INCLUDED #include "platform.h" #include "iterator.h" @@ -396,7 +396,7 @@ namespace etl { size_t operator()(const etl::array_wrapper& aw) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&aw[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&aw[0]), reinterpret_cast(&aw[aw.size()])); } }; diff --git a/include/etl/atomic.h b/include/etl/atomic.h index 98a11efd..166c3e0b 100644 --- a/include/etl/atomic.h +++ b/include/etl/atomic.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC__ -#define __ETL_ATOMIC__ +#ifndef ETL_ATOMIC_INCLUDED +#define ETL_ATOMIC_INCLUDED #include "platform.h" diff --git a/include/etl/atomic/atomic_arm.h b/include/etl/atomic/atomic_arm.h index 9a21ac25..9893fee2 100644 --- a/include/etl/atomic/atomic_arm.h +++ b/include/etl/atomic/atomic_arm.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_ARM__ -#define __ETL_ATOMIC_ARM__ +#ifndef ETL_ATOMIC_ARM_INCLUDED +#define ETL_ATOMIC_ARM_INCLUDED #include "atomic_gcc_sync.h" diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index 493b9803..d77046c2 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_GCC_SYNC__ -#define __ETL_ATOMIC_GCC_SYNC__ +#ifndef ETL_ATOMIC_GCC_SYNC_INCLUDED +#define ETL_ATOMIC_GCC_SYNC_INCLUDED #include "../platform.h" #include "../type_traits.h" diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index 3970a290..7c957cab 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_STD__ -#define __ETL_ATOMIC_STD__ +#ifndef ETL_ATOMIC_STD_INCLUDED +#define ETL_ATOMIC_STD_INCLUDED #include "../platform.h" #include "../nullptr.h" diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index f6741eea..17ee2480 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BASIC_STRING__ -#define __ETL_BASIC_STRING__ +#ifndef ETL_BASIC_STRING_INCLUDED +#define ETL_BASIC_STRING_INCLUDED #include #include @@ -55,13 +55,7 @@ SOFTWARE. #pragma GCC diagnostic ignored "-Wunused-variable" #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif - -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" //***************************************************************************** ///\defgroup basic_string basic_string @@ -2234,13 +2228,7 @@ namespace etl } } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/binary.h b/include/etl/binary.h index df7f73b9..c54bc1fc 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -28,15 +28,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BINARY__ -#define __ETL_BINARY__ +#ifndef ETL_BINARY_INCLUDED +#define ETL_BINARY_INCLUDED ///\defgroup binary binary /// Binary utilities ///\ingroup utilities #include -#include #include "platform.h" #include "type_traits.h" @@ -45,10 +44,42 @@ SOFTWARE. #include "log.h" #include "power.h" #include "smallest.h" -#include "platform.h" +#include "exception.h" +#include "error_handler.h" + +#undef ETL_FILE +#define ETL_FILE "50" namespace etl { + //*************************************************************************** + /// Exception for binary functions. + ///\ingroup binary + //*************************************************************************** + class binary_exception : public etl::exception + { + public: + + binary_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// Full exception 'for out of range' errors. + ///\ingroup binary + //*************************************************************************** + class binary_out_of_range : public etl::binary_exception + { + public: + + binary_out_of_range(string_type file_name_, numeric_type line_number_) + : etl::binary_exception(ETL_ERROR_TEXT("binary:out of range", ETL_FILE"A"), file_name_, line_number_) + { + } + }; + //*************************************************************************** /// Maximum value that can be contained in N bits. //*************************************************************************** @@ -270,16 +301,12 @@ namespace etl STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = value & ((1 << NBITS) - 1); - - if ((signed_value & negative) != 0) + struct S { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + signed value : NBITS; + } s; - return signed_value; + return (s.value = value); } //*************************************************************************** @@ -290,22 +317,18 @@ namespace etl template TReturn sign_extend(TValue value) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); + STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); + STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); STATIC_ASSERT(SHIFT <= std::numeric_limits::digits, "SHIFT too large"); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = (value >> SHIFT) & ((1 << NBITS) - 1); - - if ((signed_value & negative) != 0) + struct S { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + signed value : NBITS; + } s; - return signed_value; + return (s.value = (value >> SHIFT)); } //*************************************************************************** @@ -318,18 +341,13 @@ namespace etl STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - assert(NBITS <= std::numeric_limits::digits); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = value & ((1 << NBITS) - 1); + ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); - if ((signed_value & negative) != 0) - { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + TReturn mask = TReturn(1U) << (NBITS - 1); + value = value & ((1U << NBITS) - 1); - return signed_value; + return TReturn((value ^ mask) - mask); } //*************************************************************************** @@ -340,21 +358,16 @@ namespace etl template TReturn sign_extend(TValue value, const size_t NBITS, const size_t SHIFT) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); + STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - assert(NBITS <= std::numeric_limits::digits); + STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = (value >> SHIFT) & ((1 << NBITS) - 1); + ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); - if ((signed_value & negative) != 0) - { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + TReturn mask = TReturn(1U) << (NBITS - 1); + value = (value >> SHIFT) & ((1U << NBITS) - 1); - return signed_value; + return TReturn((value ^ mask) - mask); } //*************************************************************************** @@ -422,6 +435,140 @@ namespace etl template const typename bit::value_type bit::value; + //*************************************************************************** + /// Fills a value with a bit pattern. Compile time. + //*************************************************************************** + template + class binary_fill + { + private: + + STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + STATIC_ASSERT(VALUE <= etl::integral_limits::type>::max, "Value is too large for specified type"); + + typedef typename etl::make_unsigned::type unsigned_r_t; + typedef typename etl::make_unsigned::type unsigned_v_t; + + public: + + static const TResult value = TResult(unsigned_v_t(VALUE) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); + }; + + template + const TResult binary_fill::value; + + //*************************************************************************** + /// Fills a value with a bit pattern. Run time. + //*************************************************************************** + template + class binary_fill + { + private: + + typedef typename etl::make_unsigned::type unsigned_r_t; + + public: + + template + static TResult value(TValue value) + { + STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + + typedef typename etl::make_unsigned::type unsigned_v_t; + + return TResult(unsigned_v_t(value) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); + } + }; + +#if ETL_8BIT_SUPPORT + //*************************************************************************** + /// Detects the presence of zero bytes. Compile time. + //*************************************************************************** + template + class has_zero_byte + { + private: + + typedef typename etl::make_unsigned::type unsigned_t; + + static const unsigned_t mask = etl::binary_fill::value; + + public: + + static const bool test = unsigned_t(~((((unsigned_t(VALUE) & mask) + mask) | unsigned_t(VALUE)) | mask)) != 0U; + }; + + template + const typename etl::make_unsigned::type has_zero_byte::mask; + + template + const bool has_zero_byte::test; + + //*************************************************************************** + /// Detects the presence of zero bytes. Run time. + //*************************************************************************** + template <> + class has_zero_byte + { + public: + + template + static bool test(TValue value) + { + typedef typename etl::make_unsigned::type unsigned_t; + static const unsigned_t mask = etl::binary_fill::value; + + const unsigned_t temp = unsigned_t(~((((unsigned_t(value) & mask) + mask) | unsigned_t(value)) | mask)); + + return (temp != 0U); + } + }; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Compile time. + //*************************************************************************** + template + class has_byte_n + { + public: + + static const bool test = etl::has_zero_byte::value)>::test; + }; + + template + const bool has_byte_n::test; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Partial run time. + //*************************************************************************** + template + class has_byte_n + { + public: + + template + static bool test(TValue value) + { + return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::value)); + } + }; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Run time. + //*************************************************************************** + template <> + class has_byte_n<0, void*, (void*)0> + { + public: + + template + static bool test(TValue value, uint8_t n) + { + return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::template value(n))); + } + }; +#endif + //*************************************************************************** /// 8 bit binary constants. //*************************************************************************** @@ -722,4 +869,6 @@ namespace etl }; } +#undef ETL_FILE + #endif diff --git a/include/etl/bitset.h b/include/etl/bitset.h index bb61db38..ae328129 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BITSET__ -#define __ETL_BITSET__ +#ifndef ETL_BITSET_INCLUDED +#define ETL_BITSET_INCLUDED #include #include @@ -46,9 +46,7 @@ SOFTWARE. #include "integral_limits.h" #include "binary.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include "error_handler.h" @@ -1018,8 +1016,6 @@ void swap(etl::bitset& lhs, etl::bitset& rhs) lhs.swap(rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/bloom_filter.h b/include/etl/bloom_filter.h index cb2cb48a..0ec97c38 100644 --- a/include/etl/bloom_filter.h +++ b/include/etl/bloom_filter.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BLOOM_FILTER__ -#define __ETL_BLOOM_FILTER__ +#ifndef ETL_BLOOM_FILTER_INCLUDED +#define ETL_BLOOM_FILTER_INCLUDED #include "platform.h" #include "parameter_type.h" @@ -45,7 +45,7 @@ SOFTWARE. namespace etl { - namespace __private_bloom_filter__ + namespace private_bloom_filter { // Placeholder null hash for defaulted template parameters. struct null_hash @@ -71,14 +71,14 @@ namespace etl //*************************************************************************** template + typename THash2 = private_bloom_filter::null_hash, + typename THash3 = private_bloom_filter::null_hash> class bloom_filter { private: typedef typename etl::parameter_type::type parameter_t; - typedef __private_bloom_filter__::null_hash null_hash; + typedef private_bloom_filter::null_hash null_hash; public: diff --git a/include/etl/c/ecl_timer.h b/include/etl/c/ecl_timer.h index 0d5e33e9..d2c48dc8 100644 --- a/include/etl/c/ecl_timer.h +++ b/include/etl/c/ecl_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_C_TIMER_FRAMEWORK__ -#define __ETL_C_TIMER_FRAMEWORK__ +#ifndef ETL_C_TIMER_FRAMEWORK_INCLUDED +#define ETL_C_TIMER_FRAMEWORK_INCLUDED #include diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 5634b37a..c0b4c72d 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CALLBACK_TIMER__ -#define __ETL_CALLBACK_TIMER__ +#ifndef ETL_CALLBACK_TIMER_INCLUDED +#define ETL_CALLBACK_TIMER_INCLUDED #include #include @@ -153,7 +153,7 @@ namespace etl callback_timer_data& operator =(const callback_timer_data& other); }; - namespace __private_callback_timer__ + namespace private_callback_timer { //************************************************************************* /// A specialised intrusive linked list for timer data. @@ -647,7 +647,7 @@ namespace etl callback_timer_data* const timer_array; // The list of active timers. - __private_callback_timer__::list active_list; + private_callback_timer::list active_list; volatile bool enabled; #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index 9470fa40..25ee662b 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CHAR_TRAITS__ -#define __ETL_CHAR_TRAITS__ +#ifndef ETL_CHAR_TRAITS_INCLUDED +#define ETL_CHAR_TRAITS_INCLUDED #include diff --git a/include/etl/checksum.h b/include/etl/checksum.h index 9a2a6069..4809f346 100644 --- a/include/etl/checksum.h +++ b/include/etl/checksum.h @@ -24,8 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CHECKSUM__ -#define __ETL_CHECKSUM__ +#ifndef ETL_CHECKSUM_INCLUDED +#define ETL_CHECKSUM_INCLUDED #include diff --git a/include/etl/combinations.h b/include/etl/combinations.h index 3ecb8a5e..ef868471 100644 --- a/include/etl/combinations.h +++ b/include/etl/combinations.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_COMBINATIONS__ -#define __ETL_COMBINATIONS__ +#ifndef ETL_COMBINATIONS_INCLUDED +#define ETL_COMBINATIONS_INCLUDED #include "platform.h" #include "permutations.h" diff --git a/include/etl/compare.h b/include/etl/compare.h index e6345e45..fdf864ce 100644 --- a/include/etl/compare.h +++ b/include/etl/compare.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_COMPARE__ -#define __ETL_COMPARE__ +#ifndef ETL_COMPARE_INCLUDED +#define ETL_COMPARE_INCLUDED #include diff --git a/include/etl/constant.h b/include/etl/constant.h index d9bb8302..633b5522 100644 --- a/include/etl/constant.h +++ b/include/etl/constant.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CONSTANT__ -#define __ETL_CONSTANT__ +#ifndef ETL_CONSTANT_INCLUDED +#define ETL_CONSTANT_INCLUDED #include "platform.h" diff --git a/include/etl/container.h b/include/etl/container.h index 5fffc7b7..51d66c30 100644 --- a/include/etl/container.h +++ b/include/etl/container.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CONTAINER__ -#define __ETL_CONTAINER__ +#ifndef ETL_CONTAINER_INCLUDED +#define ETL_CONTAINER_INCLUDED #include #include diff --git a/include/etl/crc16.h b/include/etl/crc16.h index 18dc88e6..1f535d1d 100644 --- a/include/etl/crc16.h +++ b/include/etl/crc16.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16__ -#define __ETL_CRC16__ +#ifndef ETL_CRC16_INCLUDED +#define ETL_CRC16_INCLUDED #include #include diff --git a/include/etl/crc16_ccitt.h b/include/etl/crc16_ccitt.h index 3cedd827..90ce365e 100644 --- a/include/etl/crc16_ccitt.h +++ b/include/etl/crc16_ccitt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16_CCITT__ -#define __ETL_CRC16_CCITT__ +#ifndef ETL_CRC16_CCITT_INCLUDED +#define ETL_CRC16_CCITT_INCLUDED #include #include diff --git a/include/etl/crc16_kermit.h b/include/etl/crc16_kermit.h index 146b8504..4691c9ab 100644 --- a/include/etl/crc16_kermit.h +++ b/include/etl/crc16_kermit.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16_KERMIT__ -#define __ETL_CRC16_KERMIT__ +#ifndef ETL_CRC16_KERMIT_INCLUDED +#define ETL_CRC16_KERMIT_INCLUDED #include #include diff --git a/include/etl/crc32.h b/include/etl/crc32.h index 477fdfa6..35af1545 100644 --- a/include/etl/crc32.h +++ b/include/etl/crc32.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC32__ -#define __ETL_CRC32__ +#ifndef ETL_CRC32_INCLUDED +#define ETL_CRC32_INCLUDED #include #include diff --git a/include/etl/crc64_ecma.h b/include/etl/crc64_ecma.h index c098d611..a1532ddc 100644 --- a/include/etl/crc64_ecma.h +++ b/include/etl/crc64_ecma.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC64_ECMA__ -#define __ETL_CRC64_ECMA__ +#ifndef ETL_CRC64_ECMA_INCLUDED +#define ETL_CRC64_ECMA_INCLUDED #include #include diff --git a/include/etl/crc8_ccitt.h b/include/etl/crc8_ccitt.h index 112b2945..61c3a140 100644 --- a/include/etl/crc8_ccitt.h +++ b/include/etl/crc8_ccitt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC8_CCITT__ -#define __ETL_CRC8_CCITT__ +#ifndef ETL_CRC8_CCITT_INCLUDED +#define ETL_CRC8_CCITT_INCLUDED #include #include diff --git a/include/etl/cstring.h b/include/etl/cstring.h index d9f69f16..0ddfc80a 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STRING__ -#define __ETL_STRING__ +#ifndef ETL_STRING_INCLUDED +#define ETL_STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) -#undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -210,7 +208,7 @@ namespace etl { size_t operator()(const etl::istring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -220,15 +218,13 @@ namespace etl { size_t operator()(const etl::string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; #endif } -#if defined(ETL_COMPILER_MICROSOFT) -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/cyclic_value.h b/include/etl/cyclic_value.h index e3f6ac66..9df9efb6 100644 --- a/include/etl/cyclic_value.h +++ b/include/etl/cyclic_value.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CYCLIC_VALUE__ -#define __ETL_CYCLIC_VALUE__ +#ifndef ETL_CYCLIC_VALUE_INCLUDED +#define ETL_CYCLIC_VALUE_INCLUDED #include diff --git a/include/etl/debounce.h b/include/etl/debounce.h index bb0db44a..ef0907c4 100644 --- a/include/etl/debounce.h +++ b/include/etl/debounce.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEBOUNCE__ -#define __ETL_DEBOUNCE__ +#ifndef ETL_DEBOUNCE_INCLUDED +#define ETL_DEBOUNCE_INCLUDED #include @@ -38,7 +38,7 @@ SOFTWARE. namespace etl { - namespace __private_debounce__ + namespace private_debounce { class debounce_base { @@ -431,7 +431,7 @@ namespace etl /// Fixed Valid/Hold/Repeating values. //*************************************************************************** template - class debounce : public __private_debounce__::debounce4 + class debounce : public private_debounce::debounce4 { public: @@ -460,7 +460,7 @@ namespace etl /// Fixed Valid/Hold values. //*************************************************************************** template - class debounce : public __private_debounce__::debounce3 + class debounce : public private_debounce::debounce3 { public: @@ -492,7 +492,7 @@ namespace etl /// Fixed Valid value. //*************************************************************************** template - class debounce : public __private_debounce__::debounce2 + class debounce : public private_debounce::debounce2 { public: @@ -523,7 +523,7 @@ namespace etl /// Variable Valid/Hold/Repeating values. //*************************************************************************** template <> - class debounce<0, 0, 0> : public __private_debounce__::debounce4 + class debounce<0, 0, 0> : public private_debounce::debounce4 { public: diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index 48ad3f97..3aeede54 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEBUG_COUNT__ -#define __ETL_DEBUG_COUNT__ +#ifndef ETL_DEBUG_COUNT_INCLUDED +#define ETL_DEBUG_COUNT_INCLUDED #include #include @@ -39,6 +39,15 @@ SOFTWARE. ///\defgroup debug_count debug count ///\ingroup utilities +#if defined(ETL_DEBUG_COUNT) + +#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count +#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count +#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count +#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n) +#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n) +#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear() + namespace etl { //*************************************************************************** @@ -51,8 +60,7 @@ namespace etl class debug_count { public: - -#if defined(ETL_DEBUG) + inline debug_count() : count(0) { @@ -113,46 +121,16 @@ namespace etl private: int32_t count; -#else - inline debug_count() - { - } - - inline ~debug_count() - { - } - - inline debug_count& operator ++() - { - return *this; - } - - inline debug_count& operator --() - { - return *this; - } - - inline debug_count& operator +=(int32_t /*n*/) - { - return *this; - } - - inline debug_count& operator -=(int32_t /*n*/) - { - return *this; - } - - inline operator int32_t() - { - return 0; - } - - inline void clear() - { - } - -#endif }; + +#else +#define ETL_DECLARE_DEBUG_COUNT +#define ETL_INCREMENT_DEBUG_COUNT +#define ETL_DECREMENT_DEBUG_COUNT +#define ETL_ADD_DEBUG_COUNT(n) +#define ETL_SUBTRACT_DEBUG_COUNT(n) +#define ETL_RESET_DEBUG_COUNT +#endif // ETL_DEBUG_COUNT } #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index dd487002..da898328 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEQUE__ -#define __ETL_DEQUE__ +#ifndef ETL_DEQUE_INCLUDED +#define ETL_DEQUE_INCLUDED #include #include @@ -52,9 +52,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "1" @@ -211,10 +209,10 @@ namespace etl { } - size_type current_size; ///< The current number of elements in the deque. - const size_type CAPACITY; ///< The maximum number of elements in the deque. - const size_type BUFFER_SIZE; ///< The number of elements in the buffer. - etl::debug_count construct_count; ///< Internal debugging. + size_type current_size; ///< The current number of elements in the deque. + const size_type CAPACITY; ///< The maximum number of elements in the deque. + const size_type BUFFER_SIZE; ///< The number of elements in the buffer. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -935,7 +933,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -943,7 +941,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1000,7 +998,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1008,7 +1006,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1065,7 +1063,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1073,7 +1071,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1130,7 +1128,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1138,7 +1136,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1538,7 +1536,7 @@ namespace etl ::new (&(*_end)) T(value1); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1555,7 +1553,7 @@ namespace etl ::new (&(*_end)) T(value1, value2); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1572,7 +1570,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1589,7 +1587,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3, value4); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1645,7 +1643,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1662,7 +1660,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1679,7 +1677,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1696,7 +1694,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3, value4); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1811,7 +1809,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { current_size = 0; - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1850,7 +1848,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1882,7 +1880,7 @@ namespace etl ::new (&(*item++)) T(*from); ++from; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } while (n-- != 0); } @@ -1894,7 +1892,7 @@ namespace etl ::new (&(*_end)) T(); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1905,7 +1903,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1916,7 +1914,7 @@ namespace etl ::new (&(*_end)) T(value); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1926,7 +1924,7 @@ namespace etl { (*_begin).~T(); --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; ++_begin; } @@ -1938,7 +1936,7 @@ namespace etl --_end; (*_end).~T(); --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2194,8 +2192,6 @@ bool operator >=(const etl::ideque& lhs, const etl::ideque& rhs) #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/endianness.h b/include/etl/endianness.h index 5dd3dcfc..f779b65e 100644 --- a/include/etl/endianness.h +++ b/include/etl/endianness.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ENDIAN__ -#define __ETL_ENDIAN__ +#ifndef ETL_ENDIAN_INCLUDED +#define ETL_ENDIAN_INCLUDED #include diff --git a/include/etl/enum_type.h b/include/etl/enum_type.h index 6f3da8d2..6a0bae8e 100644 --- a/include/etl/enum_type.h +++ b/include/etl/enum_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ENUM_TYPE__ -#define __ETL_ENUM_TYPE__ +#ifndef ETL_ENUM_TYPE_INCLUDED +#define ETL_ENUM_TYPE_INCLUDED #include "platform.h" diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index 421be222..12c9ff3e 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -29,8 +29,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ERROR_HANDLER__ -#define __ETL_ERROR_HANDLER__ +#ifndef ETL_ERROR_HANDLER_INCLUDED +#define ETL_ERROR_HANDLER_INCLUDED ///\defgroup error_handler error_handler /// Error handler for when throwing exceptions is not required. diff --git a/include/etl/exception.h b/include/etl/exception.h index 271139a4..d3c779b8 100644 --- a/include/etl/exception.h +++ b/include/etl/exception.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_EXCEPTION__ -#define __ETL_EXCEPTION__ +#ifndef ETL_EXCEPTION_INCLUDED +#define ETL_EXCEPTION_INCLUDED #include "platform.h" diff --git a/include/etl/factorial.h b/include/etl/factorial.h index 688ae817..c42342f0 100644 --- a/include/etl/factorial.h +++ b/include/etl/factorial.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FACTORIAL__ -#define __ETL_FACTORIAL__ +#ifndef ETL_FACTORIAL_INCLUDED +#define ETL_FACTORIAL_INCLUDED #include diff --git a/include/etl/fibonacci.h b/include/etl/fibonacci.h index 70930633..9e3a5656 100644 --- a/include/etl/fibonacci.h +++ b/include/etl/fibonacci.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FIBONACCI__ -#define __ETL_FIBONACCI__ +#ifndef ETL_FIBONACCI_INCLUDED +#define ETL_FIBONACCI_INCLUDED #include diff --git a/include/etl/file_error_numbers.txt b/include/etl/file_error_numbers.txt index 7680234f..4abc3060 100644 --- a/include/etl/file_error_numbers.txt +++ b/include/etl/file_error_numbers.txt @@ -1,4 +1,4 @@ - 1 + 1 deque 2 flat_map 3 flat_multimap 4 flat_multiset @@ -46,3 +46,5 @@ 46 queue_spsc_isr 47 queue_spsc_atomic 48 queue_mpmc_mutex +49 type_select +50 binary \ No newline at end of file diff --git a/include/etl/fixed_iterator.h b/include/etl/fixed_iterator.h index b09aba26..c981320b 100644 --- a/include/etl/fixed_iterator.h +++ b/include/etl/fixed_iterator.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FIXED_ITERATOR__ -#define __ETL_FIXED_ITERATOR__ +#ifndef ETL_FIXED_ITERATOR_INCLUDED +#define ETL_FIXED_ITERATOR_INCLUDED #include diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index abd423b4..2c7e2f99 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MAP__ -#define __ETL_FLAT_MAP__ +#ifndef ETL_FLAT_MAP_INCLUDED +#define ETL_FLAT_MAP_INCLUDED #include "platform.h" #include "reference_flat_map.h" @@ -234,7 +234,7 @@ namespace etl { value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; std::pair result = refmap_t::insert_at(i_element, *pvalue); i_element->second = result.first->second; @@ -306,7 +306,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } @@ -367,7 +367,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -399,7 +399,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -431,7 +431,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -463,7 +463,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -495,7 +495,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -525,7 +525,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -539,7 +539,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -558,7 +558,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refmap_t::erase(first, last); @@ -585,7 +585,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -765,7 +765,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 25b6a36d..210664ff 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MULTMAP__ -#define __ETL_FLAT_MULTMAP__ +#ifndef ETL_FLAT_MULTMAP_INCLUDED +#define ETL_FLAT_MULTMAP_INCLUDED #include "platform.h" #include "reference_flat_multimap.h" @@ -260,7 +260,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); return result; @@ -313,7 +313,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -331,7 +331,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -349,7 +349,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -367,7 +367,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -385,7 +385,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -420,7 +420,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -439,7 +439,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refmap_t::erase(first, last); @@ -466,7 +466,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -646,7 +646,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index c47dff0d..442f2f99 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MULTISET__ -#define __ETL_FLAT_MULTISET__ +#ifndef ETL_FLAT_MULTISET_INCLUDED +#define ETL_FLAT_MULTISET_INCLUDED #include "platform.h" #include "reference_flat_multiset.h" @@ -236,7 +236,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); return result; @@ -292,7 +292,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -310,7 +310,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -328,7 +328,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -346,7 +346,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -380,7 +380,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -399,7 +399,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refset_t::erase(first, last); @@ -426,7 +426,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -606,7 +606,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 5366c0e8..fe7590d6 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_SET__ -#define __ETL_FLAT_SET__ +#ifndef ETL_FLAT_SET_INCLUDED +#define ETL_FLAT_SET_INCLUDED #include "platform.h" #include "reference_flat_set.h" @@ -239,7 +239,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } @@ -300,7 +300,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -333,7 +333,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -366,7 +366,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -399,7 +399,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -431,7 +431,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -445,7 +445,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -464,7 +464,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refset_t::erase(first, last); @@ -488,11 +488,11 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -672,7 +672,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/fnv_1.h b/include/etl/fnv_1.h index c9799196..c5704454 100644 --- a/include/etl/fnv_1.h +++ b/include/etl/fnv_1.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FNV_1__ -#define __ETL_FNV_1__ +#ifndef ETL_FNV_1_INCLUDED +#define ETL_FNV_1_INCLUDED #include diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index eaf5fcd0..407380d3 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FORWARD_LIST__ -#define __ETL_FORWARD_LIST__ +#ifndef ETL_FORWARD_LIST_INCLUDED +#define ETL_FORWARD_LIST_INCLUDED #include #include @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "6" @@ -275,10 +273,10 @@ namespace etl left->next = right; } - node_t start_node; ///< The node that acts as the forward_list start. - etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. - const size_type MAX_SIZE; ///< The maximum size of the forward_list. - etl::debug_count construct_count; ///< Internal debugging. + node_t start_node; ///< The node that acts as the forward_list start. + etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. + const size_type MAX_SIZE; ///< The maximum size of the forward_list. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -658,7 +656,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -673,7 +671,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -688,7 +686,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -703,7 +701,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -793,7 +791,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -809,7 +807,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -825,7 +823,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -841,7 +839,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1247,7 +1245,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { p_node_pool->release_all(); - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1326,7 +1324,7 @@ namespace etl { data_node_t* p_node = p_node_pool->allocate(); ::new (&(p_node->value)) T(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return *p_node; } @@ -1338,7 +1336,7 @@ namespace etl { node.value.~T(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. @@ -1536,9 +1534,7 @@ bool operator >=(const etl::iforward_list& lhs, const etl::iforward_list& return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 179ee0b3..eeb343b9 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_FSM__ -#define __ETL_FSM__ +#ifndef ETL_FSM_INCLUDED +#define ETL_FSM_INCLUDED #include @@ -66,9 +66,7 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "34" -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -1215,8 +1213,6 @@ namespace etl #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 4f50006e..91997b63 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_FSM__ -#define __ETL_FSM__ +#ifndef ETL_FSM_INCLUDED +#define ETL_FSM_INCLUDED #include @@ -78,9 +78,7 @@ cog.outl("//******************************************************************** #undef ETL_FILE #define ETL_FILE "34" -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -538,8 +536,6 @@ namespace etl #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/function.h b/include/etl/function.h index 2e07390b..502efd8e 100644 --- a/include/etl/function.h +++ b/include/etl/function.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FUNCTION__ -#define __ETL_FUNCTION__ +#ifndef ETL_FUNCTION_INCLUDED +#define ETL_FUNCTION_INCLUDED #include "platform.h" diff --git a/include/etl/functional.h b/include/etl/functional.h index a2187d5c..eb0e85b4 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FUNCTIONAL__ -#define __ETL_FUNCTIONAL__ +#ifndef ETL_FUNCTIONAL_INCLUDED +#define ETL_FUNCTIONAL_INCLUDED #include "platform.h" diff --git a/include/etl/generate.bat b/include/etl/generate.bat index 3c6eea14..c121da9f 100644 --- a/include/etl/generate.bat +++ b/include/etl/generate.bat @@ -3,4 +3,5 @@ python -m cogapp -d -e -omessage_router.h -DHandlers=16 message_router_generator python -m cogapp -d -e -olargest.h -DNTypes=16 largest_generator.h python -m cogapp -d -e -osmallest.h -DNTypes=16 smallest_generator.h python -m cogapp -d -e -otype_traits.h -DIsOneOf=17 type_traits_generator.h -python -m cogapp -d -e -otype_lookup.h -DNTypes=16 type_lookup_generator.h \ No newline at end of file +python -m cogapp -d -e -otype_lookup.h -DNTypes=16 type_lookup_generator.h +python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h \ No newline at end of file diff --git a/include/etl/generate_type_select.bat b/include/etl/generate_type_select.bat new file mode 100644 index 00000000..89706ac8 --- /dev/null +++ b/include/etl/generate_type_select.bat @@ -0,0 +1 @@ +python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h diff --git a/include/etl/hash.h b/include/etl/hash.h index 891b8518..61b19b81 100644 --- a/include/etl/hash.h +++ b/include/etl/hash.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_HASH__ -#define __ETL_HASH__ +#ifndef ETL_HASH_INCLUDED +#define ETL_HASH_INCLUDED #include #include @@ -46,7 +46,7 @@ SOFTWARE. namespace etl { - namespace __private_hash__ + namespace private_hash { //************************************************************************* /// Hash to use when size_t is 16 bits. @@ -242,7 +242,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -264,7 +264,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -286,7 +286,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -308,7 +308,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -338,7 +338,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -368,7 +368,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -398,7 +398,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -428,7 +428,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; diff --git a/include/etl/ihash.h b/include/etl/ihash.h index db154233..e0ccf2b5 100644 --- a/include/etl/ihash.h +++ b/include/etl/ihash.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IHASH__ -#define __ETL_IHASH__ +#ifndef ETL_IHASH_INCLUDED +#define ETL_IHASH_INCLUDED #include #include diff --git a/include/etl/instance_count.h b/include/etl/instance_count.h index 262510df..2d94f317 100644 --- a/include/etl/instance_count.h +++ b/include/etl/instance_count.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INSTANCE_COUNT__ -#define __ETL_INSTANCE_COUNT__ +#ifndef ETL_INSTANCE_COUNT_INCLUDED +#define ETL_INSTANCE_COUNT_INCLUDED #include diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index f231bf48..4adf9fad 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTEGRAL_LIMITS__ -#define __ETL_INTEGRAL_LIMITS__ +#ifndef ETL_INTEGRAL_LIMITS_INCLUDED +#define ETL_INTEGRAL_LIMITS_INCLUDED #include #include @@ -37,10 +37,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#undef max -#endif +#include "private/minmax_push.h" //***************************************************************************** ///\defgroup integral_limits integral_limits @@ -213,9 +210,6 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 1ac767dd..bcc24ddd 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -28,14 +28,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_FORWARD_LIST__ -#define __ETL_INTRUSIVE_FORWARD_LIST__ +#ifndef ETL_INTRUSIVE_FORWARD_LIST_INCLUDED +#define ETL_INTRUSIVE_FORWARD_LIST_INCLUDED #include "platform.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include #include @@ -1046,9 +1044,7 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/intrusive_links.h b/include/etl/intrusive_links.h index d4a19cf5..65353e7b 100644 --- a/include/etl/intrusive_links.h +++ b/include/etl/intrusive_links.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_LINKS__ -#define __ETL_INTRUSIVE_LINKS__ +#ifndef ETL_INTRUSIVE_LINKS_INCLUDED +#define ETL_INTRUSIVE_LINKS_INCLUDED #include #include diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index e78a2669..6e4494d0 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -28,14 +28,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_LIST__ -#define __ETL_INTRUSIVE_LIST__ +#ifndef ETL_INTRUSIVE_LIST_INCLUDED +#define ETL_INTRUSIVE_LIST_INCLUDED #include "platform.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include #include @@ -1078,9 +1076,7 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/intrusive_queue.h b/include/etl/intrusive_queue.h index 315e25ee..48885fac 100644 --- a/include/etl/intrusive_queue.h +++ b/include/etl/intrusive_queue.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_QUEUE__ -#define __ETL_INTRUSIVE_QUEUE__ +#ifndef ETL_INTRUSIVE_QUEUE_INCLUDED +#define ETL_INTRUSIVE_QUEUE_INCLUDED #include diff --git a/include/etl/intrusive_stack.h b/include/etl/intrusive_stack.h index 9ead1175..8f7bfe40 100644 --- a/include/etl/intrusive_stack.h +++ b/include/etl/intrusive_stack.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_STACK__ -#define __ETL_INTRUSIVE_STACK__ +#ifndef ETL_INTRUSIVE_STACK_INCLUDED +#define ETL_INTRUSIVE_STACK_INCLUDED #include diff --git a/include/etl/io_port.h b/include/etl/io_port.h index 2577162b..053a1f78 100644 --- a/include/etl/io_port.h +++ b/include/etl/io_port.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IO_PORT__ -#define __ETL_IO_PORT__ +#ifndef ETL_IO_PORT_INCLUDED +#define ETL_IO_PORT_INCLUDED ///\defgroup io_port io port /// IO port access diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 7b17e0cc..3e1e2a0b 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ITERATOR__ -#define __ETL_ITERATOR__ +#ifndef ETL_ITERATOR_INCLUDED +#define ETL_ITERATOR_INCLUDED #include diff --git a/include/etl/jenkins.h b/include/etl/jenkins.h index c9daa4e5..7135b685 100644 --- a/include/etl/jenkins.h +++ b/include/etl/jenkins.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_JENKINS__ -#define __ETL_JENKINS__ +#ifndef ETL_JENKINS_INCLUDED +#define ETL_JENKINS_INCLUDED #include #include diff --git a/include/etl/largest.h b/include/etl/largest.h index 616594f7..0bb51c11 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_LARGEST__ -#define __ETL_LARGEST__ +#ifndef ETL_LARGEST_INCLUDED +#define ETL_LARGEST_INCLUDED ///\defgroup largest largest ///\ingroup utilities diff --git a/include/etl/largest_generator.h b/include/etl/largest_generator.h index b701a70c..7ac3db53 100644 --- a/include/etl/largest_generator.h +++ b/include/etl/largest_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_LARGEST__ -#define __ETL_LARGEST__ +#ifndef ETL_LARGEST_INCLUDED +#define ETL_LARGEST_INCLUDED ///\defgroup largest largest ///\ingroup utilities diff --git a/include/etl/list.h b/include/etl/list.h index 8ed4e267..d48a6f5d 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_LIST__ -#define __ETL_LIST__ +#ifndef ETL_LIST_INCLUDED +#define ETL_LIST_INCLUDED #include #include @@ -51,9 +51,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "7" @@ -317,10 +315,10 @@ namespace etl { } - etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. - node_t terminal_node; ///< The node that acts as the list start and end. - const size_type MAX_SIZE; ///< The maximum size of the list. - etl::debug_count construct_count; ///< Internal debugging. + etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. + node_t terminal_node; ///< The node that acts as the list start and end. + const size_type MAX_SIZE; ///< The maximum size of the list. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -789,7 +787,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -804,7 +802,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -819,7 +817,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -834,7 +832,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -880,7 +878,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -895,7 +893,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -910,7 +908,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -925,7 +923,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -964,7 +962,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -980,7 +978,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -996,7 +994,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1012,7 +1010,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1456,7 +1454,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { p_node_pool->release_all(); - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1549,7 +1547,7 @@ namespace etl { data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return *p_data_node; } @@ -1561,7 +1559,7 @@ namespace etl { node.value.~T(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. @@ -1768,9 +1766,7 @@ bool operator >=(const etl::ilist& lhs, const etl::ilist& rhs) } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/log.h b/include/etl/log.h index bf9aa7ab..0971d515 100644 --- a/include/etl/log.h +++ b/include/etl/log.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_LOG__ -#define __ETL_LOG__ +#ifndef ETL_LOG_INCLUDED +#define ETL_LOG_INCLUDED #include diff --git a/include/etl/map.h b/include/etl/map.h index 19e04f43..4e7476fb 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MAP__ -#define __ETL_MAP__ +#ifndef ETL_MAP_INCLUDED +#define ETL_MAP_INCLUDED #include #include @@ -51,9 +51,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "8" @@ -342,7 +340,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G @@ -453,7 +451,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the map root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1263,7 +1261,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new (&node.value) const value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1274,7 +1272,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2186,9 +2184,7 @@ bool operator >=(const etl::imap& lhs, const etl::im return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/memory.h b/include/etl/memory.h index 1f1e0ad5..9a886af3 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MEMORY__ -#define __ETL_MEMORY__ +#ifndef ETL_MEMORY_INCLUDED +#define ETL_MEMORY_INCLUDED #include #include diff --git a/include/etl/memory_model.h b/include/etl/memory_model.h new file mode 100644 index 00000000..07bfc73f --- /dev/null +++ b/include/etl/memory_model.h @@ -0,0 +1,46 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_MEMORY_MODEL_INCLUDED +#define ETL_MEMORY_MODEL_INCLUDED + +#include "user_type.h" + +namespace etl +{ + ETL_DECLARE_USER_TYPE(memory_model, int) + ETL_USER_TYPE(MM_SMALL, 0) + ETL_USER_TYPE(MM_MEDIUM, 1) + ETL_USER_TYPE(MM_LARGE, 2) + ETL_END_USER_TYPE(memory_model) +} + +#endif + diff --git a/include/etl/message.h b/include/etl/message.h index 4d83fb7b..64d1bb96 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE__ -#define __ETL_MESSAGE__ +#ifndef ETL_MESSAGE_INCLUDED +#define ETL_MESSAGE_INCLUDED #include diff --git a/include/etl/message_bus.h b/include/etl/message_bus.h index 11031a8f..25046dda 100644 --- a/include/etl/message_bus.h +++ b/include/etl/message_bus.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_BUS_ -#define __ETL_MESSAGE_BUS_ +#ifndef ETL_MESSAGE_BUS_ +#define ETL_MESSAGE_BUS_ #include #include diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 0cf4a4f7..62f591df 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_MESSAGE_ROUTER__ -#define __ETL_MESSAGE_ROUTER__ +#ifndef ETL_MESSAGE_ROUTER_INCLUDED +#define ETL_MESSAGE_ROUTER_INCLUDED #include diff --git a/include/etl/message_router_generator.h b/include/etl/message_router_generator.h index 9b43caec..cc503cca 100644 --- a/include/etl/message_router_generator.h +++ b/include/etl/message_router_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_MESSAGE_ROUTER__ -#define __ETL_MESSAGE_ROUTER__ +#ifndef ETL_MESSAGE_ROUTER_INCLUDED +#define ETL_MESSAGE_ROUTER_INCLUDED #include diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 4a570ae2..9ec27add 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_TIMER__ -#define __ETL_MESSAGE_TIMER__ +#ifndef ETL_MESSAGE_TIMER_INCLUDED +#define ETL_MESSAGE_TIMER_INCLUDED #include #include @@ -148,7 +148,7 @@ namespace etl message_timer_data& operator =(const message_timer_data& other); }; - namespace __private_message_timer__ + namespace private_message_timer { //************************************************************************* /// A specialised intrusive linked list for timer data. @@ -623,7 +623,7 @@ namespace etl message_timer_data* const timer_array; // The list of active timers. - __private_message_timer__::list active_list; + private_message_timer::list active_list; volatile bool enabled; diff --git a/include/etl/message_types.h b/include/etl/message_types.h index 2e5f7b05..b5824bb7 100644 --- a/include/etl/message_types.h +++ b/include/etl/message_types.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_DEFS__ -#define __ETL_MESSAGE_DEFS__ +#ifndef ETL_MESSAGE_DEFS_INCLUDED +#define ETL_MESSAGE_DEFS_INCLUDED #include diff --git a/include/etl/multimap.h b/include/etl/multimap.h index fa032c0a..e08e65dd 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MULTIMAP__ -#define __ETL_MULTIMAP__ +#ifndef ETL_MULTIMAP_INCLUDED +#define ETL_MULTIMAP_INCLUDED #include #include @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "9" @@ -347,7 +345,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G @@ -609,7 +607,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the multimap root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1356,7 +1354,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new (&node.value) const value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1367,7 +1365,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2071,9 +2069,7 @@ bool operator >=(const etl::imultimap& lhs, const et return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 7bb0fff2..47673ee5 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MULTISET__ -#define __ETL_MULTISET__ +#ifndef ETL_MULTISET_INCLUDED +#define ETL_MULTISET_INCLUDED #include #include @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "10" @@ -555,7 +553,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G @@ -609,7 +607,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the set. Node* root_node; ///< The node that acts as the multiset root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1337,7 +1335,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new ((void*)&node.value) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1348,7 +1346,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2051,9 +2049,7 @@ bool operator >=(const etl::imultiset& lhs, const etl::imultiset diff --git a/include/etl/mutex.h b/include/etl/mutex.h index 87ea68a8..0fb1ec10 100644 --- a/include/etl/mutex.h +++ b/include/etl/mutex.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX__ -#define __ETL_MUTEX__ +#ifndef ETL_MUTEX_INCLUDED +#define ETL_MUTEX_INCLUDED #include "platform.h" diff --git a/include/etl/mutex/mutex_arm.h b/include/etl/mutex/mutex_arm.h index 4b33bb77..c548b059 100644 --- a/include/etl/mutex/mutex_arm.h +++ b/include/etl/mutex/mutex_arm.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_ARM__ -#define __ETL_MUTEX_ARM__ +#ifndef ETL_MUTEX_ARM_INCLUDED +#define ETL_MUTEX_ARM_INCLUDED #include "mutex_gcc_sync.h" diff --git a/include/etl/mutex/mutex_gcc_sync.h b/include/etl/mutex/mutex_gcc_sync.h index e61e08b8..3d70097f 100644 --- a/include/etl/mutex/mutex_gcc_sync.h +++ b/include/etl/mutex/mutex_gcc_sync.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_GCC_SYNC__ -#define __ETL_MUTEX_GCC_SYNC__ +#ifndef ETL_MUTEX_GCC_SYNC_INCLUDED +#define ETL_MUTEX_GCC_SYNC_INCLUDED #include "../platform.h" diff --git a/include/etl/mutex/mutex_std.h b/include/etl/mutex/mutex_std.h index 35df0ed9..30908f8c 100644 --- a/include/etl/mutex/mutex_std.h +++ b/include/etl/mutex/mutex_std.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_STD__ -#define __ETL_MUTEX_STD__ +#ifndef ETL_MUTEX_STD_INCLUDED +#define ETL_MUTEX_STD_INCLUDED #include "../platform.h" diff --git a/include/etl/null_type.h b/include/etl/null_type.h new file mode 100644 index 00000000..6b610ced --- /dev/null +++ b/include/etl/null_type.h @@ -0,0 +1,50 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_NULL_TYPE_INCLUDED +#define ETL_NULL_TYPE_INCLUDED + +#undef ETL_FILE +#define ETL_FILE "50" + +namespace etl +{ + template + class null_type + { + private: + + null_type(); + null_type(const null_type&); + null_type& operator=(const null_type&); + }; +} + +#undef ETL_FILE + +#endif diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index ccac5f68..07de981b 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_NULLPTR__ -#define __ETL_NULLPTR__ +#ifndef ETL_NULLPTR_INCLUDED +#define ETL_NULLPTR_INCLUDED #include "platform.h" diff --git a/include/etl/numeric.h b/include/etl/numeric.h index ed3a4c08..f13f7f9c 100644 --- a/include/etl/numeric.h +++ b/include/etl/numeric.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_NUMERIC__ -#define __ETL_NUMERIC__ +#ifndef ETL_NUMERIC_INCLUDED +#define ETL_NUMERIC_INCLUDED #include "platform.h" diff --git a/include/etl/observer.h b/include/etl/observer.h index c48dc7f0..b9c0dbfa 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_OBSERVER__ -#define __ETL_OBSERVER__ +#ifndef ETL_OBSERVER_INCLUDED +#define ETL_OBSERVER_INCLUDED //***************************************************************************** ///\defgroup observer observer diff --git a/include/etl/optional.h b/include/etl/optional.h index 08cf7805..47f84004 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_OPTIONAL__ -#define __ETL_OPTIONAL__ +#ifndef ETL_OPTIONAL_INCLUDED +#define ETL_OPTIONAL_INCLUDED #include "platform.h" #include "alignment.h" diff --git a/include/etl/packet.h b/include/etl/packet.h index ef0e2d79..bd9f28f7 100644 --- a/include/etl/packet.h +++ b/include/etl/packet.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PACKET__ -#define __ETL_PACKET__ +#ifndef ETL_PACKET_INCLUDED +#define ETL_PACKET_INCLUDED #include "platform.h" #include "static_assert.h" diff --git a/include/etl/parameter_type.h b/include/etl/parameter_type.h index 75203c53..7d5e0dc6 100644 --- a/include/etl/parameter_type.h +++ b/include/etl/parameter_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PARAMETER__ -#define __ETL_PARAMETER__ +#ifndef ETL_PARAMETER_INCLUDED +#define ETL_PARAMETER_INCLUDED #include "platform.h" #include "type_traits.h" diff --git a/include/etl/pearson.h b/include/etl/pearson.h index 7e779f44..aef15302 100644 --- a/include/etl/pearson.h +++ b/include/etl/pearson.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PEARSON__ -#define __ETL_PEARSON__ +#ifndef ETL_PEARSON_INCLUDED +#define ETL_PEARSON_INCLUDED #include diff --git a/include/etl/permutations.h b/include/etl/permutations.h index 9a1feba4..8101f8a7 100644 --- a/include/etl/permutations.h +++ b/include/etl/permutations.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PERMUTATIONS__ -#define __ETL_PERMUTATIONS__ +#ifndef ETL_PERMUTATIONS_INCLUDED +#define ETL_PERMUTATIONS_INCLUDED #include "platform.h" diff --git a/include/etl/platform.h b/include/etl/platform.h index dd787607..655f78bb 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -30,8 +30,8 @@ SOFTWARE. #include -#ifndef __ETL_PLATFORM__ -#define __ETL_PLATFORM__ +#ifndef ETL_PLATFORM_INCLUDED +#define ETL_PLATFORM_INCLUDED // Some targets do not support 8bit types. #define ETL_8BIT_SUPPORT (CHAR_BIT == 8) diff --git a/include/etl/pool.h b/include/etl/pool.h index 36bf99b6..8ce26fe1 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_POOL__ -#define __ETL_POOL__ +#ifndef ETL_POOL_INCLUDED +#define ETL_POOL_INCLUDED #include "platform.h" #include "error_handler.h" diff --git a/include/etl/power.h b/include/etl/power.h index dd2435d3..aaa144d9 100644 --- a/include/etl/power.h +++ b/include/etl/power.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_POW__ -#define __ETL_POW__ +#ifndef ETL_POW_INCLUDED +#define ETL_POW_INCLUDED #include #include diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index c48ba358..42df8261 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PRIORITY_QUEUE__ -#define __ETL_PRIORITY_QUEUE__ +#ifndef ETL_PRIORITY_QUEUE_INCLUDED +#define ETL_PRIORITY_QUEUE_INCLUDED #include #include diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index 0ba80810..6dcda8f3 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IVECTOR_POINTER__ -#define __ETL_IVECTOR_POINTER__ +#ifndef ETL_IVECTOR_POINTER_INCLUDED +#define ETL_IVECTOR_POINTER_INCLUDED -#ifndef __ETL_IN_VECTOR_H__ +#ifndef ETL_IN_VECTOR_H #error This header is a private element of etl::ivector #endif diff --git a/include/etl/private/minmax_pop.h b/include/etl/private/minmax_pop.h new file mode 100644 index 00000000..778f63b4 --- /dev/null +++ b/include/etl/private/minmax_pop.h @@ -0,0 +1,39 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +/* + * The header include guard has been intentionally omitted. + * This file is intended to evaluated multiple times by design. + */ + +#ifdef ETL_COMPILER_MICROSOFT +#pragma pop_macro("min") +#pragma pop_macro("max") +#endif diff --git a/include/etl/private/minmax_push.h b/include/etl/private/minmax_push.h new file mode 100644 index 00000000..4b009771 --- /dev/null +++ b/include/etl/private/minmax_push.h @@ -0,0 +1,41 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +/* + * The header include guard has been intentionally omitted. + * This file is intended to evaluated multiple times by design. + */ + +#ifdef ETL_COMPILER_MICROSOFT +#pragma push_macro("min") +#pragma push_macro("max") +#undef min +#undef max +#endif diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 664eb563..4cef3c8e 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PVOIDVECTOR__ -#define __ETL_PVOIDVECTOR__ +#ifndef ETL_PVOIDVECTOR_INCLUDED +#define ETL_PVOIDVECTOR_INCLUDED -#define __ETL_IN_PVOIDVECTOR__ +#define ETL_IN_PVOIDVECTOR #include #include @@ -48,9 +48,7 @@ SOFTWARE. #pragma GCC diagnostic ignored "-Wunused-variable" #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "minmax_push.h" namespace etl { @@ -594,10 +592,8 @@ namespace etl bool operator >=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "minmax_pop.h" -#undef __ETL_IN_PVOIDVECTOR__ +#undef ETL_IN_PVOIDVECTOR #endif diff --git a/include/etl/private/vector_base.h b/include/etl/private/vector_base.h index bcd131ab..d34b4f68 100644 --- a/include/etl/private/vector_base.h +++ b/include/etl/private/vector_base.h @@ -28,12 +28,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#if !defined(__ETL_IN_VECTOR_H__) && !defined(__ETL_IN_PVOIDVECTOR__) +#if !defined(ETL_IN_VECTOR_H) && !defined(ETL_IN_PVOIDVECTOR) #error This header is a private element of etl::vector & etl::pvoidvector #endif -#ifndef __ETL_VECTOR_BASE__ -#define __ETL_VECTOR_BASE__ +#ifndef ETL_VECTOR_BASE_INCLUDED +#define ETL_VECTOR_BASE_INCLUDED #include @@ -161,8 +161,8 @@ namespace etl { } - const size_type CAPACITY; /// #include @@ -119,7 +119,7 @@ namespace etl //************************************************************************* /// Returns the maximum number of items that can be queued. //************************************************************************* - ETL_CONSTEXPR size_type max_size() const + size_type max_size() const { return CAPACITY; } @@ -127,7 +127,7 @@ namespace etl //************************************************************************* /// Returns the maximum number of items that can be queued. //************************************************************************* - ETL_CONSTEXPR size_type capacity() const + size_type capacity() const { return CAPACITY; } @@ -190,7 +190,7 @@ namespace etl } ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -203,7 +203,7 @@ namespace etl out = 0; } --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -214,14 +214,14 @@ namespace etl in = 0; out = 0; current_size = 0; - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } - size_type in; ///< Where to input new data. - size_type out; ///< Where to get the oldest data. - size_type current_size; ///< The number of items in the queue. - const size_type CAPACITY; ///< The maximum number of items in the queue. - etl::debug_count construct_count; ///< For internal debugging purposes. + size_type in; ///< Where to input new data. + size_type out; ///< Where to get the oldest data. + size_type current_size; ///< The number of items in the queue. + const size_type CAPACITY; ///< The maximum number of items in the queue. + ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. }; diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index d3426cb2..f6951406 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MPMC_QUEUE_MUTEX__ -#define __ETL_MPMC_QUEUE_MUTEX__ +#ifndef ETL_MPMC_QUEUE_MUTEX_INCLUDED +#define ETL_MPMC_QUEUE_MUTEX_INCLUDED #include #include @@ -51,7 +51,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return MAX_SIZE; } @@ -59,7 +59,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return MAX_SIZE; } diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index a7f7e588..dfe32fc0 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SPSC_QUEUE_ATOMIC__ -#define __ETL_SPSC_QUEUE_ATOMIC__ +#ifndef ETL_SPSC_QUEUE_ATOMIC_INCLUDED +#define ETL_SPSC_QUEUE_ATOMIC_INCLUDED #include #include @@ -105,7 +105,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return RESERVED - 1; } @@ -113,7 +113,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return RESERVED - 1; } diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 68dfb9ec..2b89603d 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SPSC_QUEUE_ISR__ -#define __ETL_SPSC_QUEUE_ISR__ +#ifndef ETL_SPSC_QUEUE_ISR_INCLUDED +#define ETL_SPSC_QUEUE_ISR_INCLUDED #include #include @@ -131,7 +131,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return MAX_SIZE; } @@ -139,7 +139,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return MAX_SIZE; } diff --git a/include/etl/radix.h b/include/etl/radix.h index 2e830341..a4ba926b 100644 --- a/include/etl/radix.h +++ b/include/etl/radix.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_RADIX__ -#define __ETL_RADIX__ +#ifndef ETL_RADIX_INCLUDED +#define ETL_RADIX_INCLUDED #include diff --git a/include/etl/random.h b/include/etl/random.h index f47212f4..f94774f2 100644 --- a/include/etl/random.h +++ b/include/etl/random.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_RANDOM__ -#define __ETL_RANDOM__ +#ifndef ETL_RANDOM_INCLUDED +#define ETL_RANDOM_INCLUDED #include diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 0963e77f..e76ccfd6 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MAP__ -#define __ETL_REFERENCE_FLAT_MAP__ +#ifndef ETL_REFERENCE_FLAT_MAP_INCLUDED +#define ETL_REFERENCE_FLAT_MAP_INCLUDED #include diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 1b428e11..3088aa75 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MULTIMAP_BASE__ -#define __ETL_REFERENCE_FLAT_MULTIMAP_BASE__ +#ifndef ETL_REFERENCE_FLAT_MULTIMAP_BASE_INCLUDED +#define ETL_REFERENCE_FLAT_MULTIMAP_BASE_INCLUDED #include diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index bd72dc1e..4a502e65 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MULTISET__ -#define __ETL_REFERENCE_FLAT_MULTISET__ +#ifndef ETL_REFERENCE_FLAT_MULTISET_INCLUDED +#define ETL_REFERENCE_FLAT_MULTISET_INCLUDED #include #include diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 3f4f7cb5..c7c866b8 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_SET__ -#define __ETL_REFERENCE_FLAT_SET__ +#ifndef ETL_REFERENCE_FLAT_SET_INCLUDED +#define ETL_REFERENCE_FLAT_SET_INCLUDED #include #include diff --git a/include/etl/scheduler.h b/include/etl/scheduler.h index 3bbe8295..21085459 100644 --- a/include/etl/scheduler.h +++ b/include/etl/scheduler.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SCHEDULER__ -#define __ETL_SCHEDULER__ +#ifndef ETL_SCHEDULER_INCLUDED +#define ETL_SCHEDULER_INCLUDED #include diff --git a/include/etl/set.h b/include/etl/set.h index 0db42f38..e405de30 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SET__ -#define __ETL_SET__ +#ifndef ETL_SET_INCLUDED +#define ETL_SET_INCLUDED #include #include @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "14" @@ -409,7 +407,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G @@ -447,7 +445,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the set. Node* root_node; ///< The node that acts as the set root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; @@ -1186,7 +1184,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new ((void*)&node.value) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1197,7 +1195,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2109,9 +2107,7 @@ bool operator >=(const etl::iset& lhs, const etl::iset return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/smallest.h b/include/etl/smallest.h index f6c8c36c..33eaaf6a 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_SMALLEST__ -#define __ETL_SMALLEST__ +#ifndef ETL_SMALLEST_INCLUDED +#define ETL_SMALLEST_INCLUDED #include @@ -132,7 +132,7 @@ namespace etl }; }; - namespace __private_smallest__ + namespace private_smallest { //************************************************************************* // Determine the type to hold the number of bits based on the index. @@ -237,7 +237,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -258,7 +258,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; //*************************************************************************** @@ -279,7 +279,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -300,7 +300,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; } diff --git a/include/etl/smallest_generator.h b/include/etl/smallest_generator.h index 99923b5e..dcc955a2 100644 --- a/include/etl/smallest_generator.h +++ b/include/etl/smallest_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_SMALLEST__ -#define __ETL_SMALLEST__ +#ifndef ETL_SMALLEST_INCLUDED +#define ETL_SMALLEST_INCLUDED #include @@ -162,7 +162,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - namespace __private_smallest__ + namespace private_smallest { //************************************************************************* // Determine the type to hold the number of bits based on the index. @@ -267,7 +267,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -288,7 +288,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; //*************************************************************************** @@ -309,7 +309,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -330,7 +330,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; } diff --git a/include/etl/sqrt.h b/include/etl/sqrt.h index cbfdb2ce..9fda08bf 100644 --- a/include/etl/sqrt.h +++ b/include/etl/sqrt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SQRT__ -#define __ETL_SQRT__ +#ifndef ETL_SQRT_INCLUDED +#define ETL_SQRT_INCLUDED #include diff --git a/include/etl/stack.h b/include/etl/stack.h index e4a36702..3f9e1612 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STACK__ -#define __ETL_STACK__ +#ifndef ETL_STACK_INCLUDED +#define ETL_STACK_INCLUDED #include #include @@ -178,7 +178,7 @@ namespace etl void add_in() { top_index = current_size++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -188,7 +188,7 @@ namespace etl { --top_index; --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -198,13 +198,13 @@ namespace etl { top_index = 0; current_size = 0; - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } - size_type top_index; ///< The index of the top of the stack. - size_type current_size; ///< The number of items in the stack. - const size_type CAPACITY; ///< The maximum number of items in the stack. - etl::debug_count construct_count; ///< For internal debugging purposes. + size_type top_index; ///< The index of the top of the stack. + size_type current_size; ///< The number of items in the stack. + const size_type CAPACITY; ///< The maximum number of items in the stack. + ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. }; //*************************************************************************** diff --git a/include/etl/static_assert.h b/include/etl/static_assert.h index f6f9e28b..af3d76a1 100644 --- a/include/etl/static_assert.h +++ b/include/etl/static_assert.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STATIC_ASSERT__ -#define __ETL_STATIC_ASSERT__ +#ifndef ETL_STATIC_ASSERT_INCLUDED +#define ETL_STATIC_ASSERT_INCLUDED #include "platform.h" diff --git a/include/etl/string_view.h b/include/etl/string_view.h index c5e95603..5402cda6 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STRING_VIEW__ -#define __ETL_STRING_VIEW__ +#ifndef ETL_STRING_VIEW_INCLUDED +#define ETL_STRING_VIEW_INCLUDED #include "platform.h" #include "memory.h" @@ -49,10 +49,7 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "42" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -818,7 +815,7 @@ namespace etl { size_t operator()(const etl::string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -828,7 +825,7 @@ namespace etl { size_t operator()(const etl::wstring_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -838,7 +835,7 @@ namespace etl { size_t operator()(const etl::u16string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -848,7 +845,7 @@ namespace etl { size_t operator()(const etl::u32string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -864,10 +861,7 @@ void swap(etl::basic_string_view& lhs, etl::basic_string_view (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/task.h b/include/etl/task.h index 693575fe..1e25336d 100644 --- a/include/etl/task.h +++ b/include/etl/task.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TASK__ -#define __ETL_TASK__ +#ifndef ETL_TASK_INCLUDED +#define ETL_TASK_INCLUDED #include diff --git a/include/etl/timer.h b/include/etl/timer.h index e91d1f5e..9fdc4bdb 100644 --- a/include/etl/timer.h +++ b/include/etl/timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TIMER__ -#define __ETL_TIMER__ +#ifndef ETL_TIMER_INCLUDED +#define ETL_TIMER_INCLUDED #include diff --git a/include/etl/type_def.h b/include/etl/type_def.h index f3c0907d..15065525 100644 --- a/include/etl/type_def.h +++ b/include/etl/type_def.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_DEF__ -#define __ETL_TYPE_DEF__ +#ifndef ETL_TYPE_DEF_INCLUDED +#define ETL_TYPE_DEF_INCLUDED #include "platform.h" diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index 994809db..30e4932e 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -26,14 +26,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_LOOKUP__ -#define __ETL_TYPE_LOOKUP__ +#ifndef ETL_TYPE_LOOKUP_INCLUDED +#define ETL_TYPE_LOOKUP_INCLUDED #include #include "platform.h" #include "type_traits.h" #include "static_assert.h" +#include "null_type.h" #undef ETL_FILE #define ETL_FILE "45" @@ -43,13 +44,11 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** namespace etl { - struct null_type {}; - //*************************************************************************** /// The type/id pair type to use for type/id lookup template parameters. //*************************************************************************** @@ -78,21 +77,21 @@ namespace etl // For 16 types. //*************************************************************************** template , - typename T3 = etl::type_id_pair, - typename T4 = etl::type_id_pair, - typename T5 = etl::type_id_pair, - typename T6 = etl::type_id_pair, - typename T7 = etl::type_id_pair, - typename T8 = etl::type_id_pair, - typename T9 = etl::type_id_pair, - typename T10 = etl::type_id_pair, - typename T11 = etl::type_id_pair, - typename T12 = etl::type_id_pair, - typename T13 = etl::type_id_pair, - typename T14 = etl::type_id_pair, - typename T15 = etl::type_id_pair, - typename T16 = etl::type_id_pair > + typename T2 = etl::type_id_pair, -2>, + typename T3 = etl::type_id_pair, -3>, + typename T4 = etl::type_id_pair, -4>, + typename T5 = etl::type_id_pair, -5>, + typename T6 = etl::type_id_pair, -6>, + typename T7 = etl::type_id_pair, -7>, + typename T8 = etl::type_id_pair, -8>, + typename T9 = etl::type_id_pair, -9>, + typename T10 = etl::type_id_pair, -10>, + typename T11 = etl::type_id_pair, -11>, + typename T12 = etl::type_id_pair, -12>, + typename T13 = etl::type_id_pair, -13>, + typename T14 = etl::type_id_pair, -14>, + typename T15 = etl::type_id_pair, -15>, + typename T16 = etl::type_id_pair, -16> > struct type_id_lookup { public: @@ -101,7 +100,7 @@ namespace etl template struct type_from_id { - typedef + typedef typename etl::conditional::type>::type>::type>::type> - ::type>::type>::type>::type> - ::type>::type>::type>::type> - ::type>::type>::type>::type type; + etl::null_type<0>>::type>::type>::type>::type> + ::type>::type>::type>::type> + ::type>::type>::type>::type> + ::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same::value), "Invalid id"); + STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid id"); }; //************************************ @@ -138,22 +137,22 @@ namespace etl enum { value = - (unsigned int) etl::is_same::value ? (unsigned int)T1::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T2::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T3::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T4::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T5::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T6::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T7::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T8::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T9::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T10::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T11::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T12::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T13::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T14::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T15::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T16::ID : + (unsigned int) etl::is_same::value ? T1::ID : + (unsigned int) etl::is_same::value ? T2::ID : + (unsigned int) etl::is_same::value ? T3::ID : + (unsigned int) etl::is_same::value ? T4::ID : + (unsigned int) etl::is_same::value ? T5::ID : + (unsigned int) etl::is_same::value ? T6::ID : + (unsigned int) etl::is_same::value ? T7::ID : + (unsigned int) etl::is_same::value ? T8::ID : + (unsigned int) etl::is_same::value ? T9::ID : + (unsigned int) etl::is_same::value ? T10::ID : + (unsigned int) etl::is_same::value ? T11::ID : + (unsigned int) etl::is_same::value ? T12::ID : + (unsigned int) etl::is_same::value ? T13::ID : + (unsigned int) etl::is_same::value ? T14::ID : + (unsigned int) etl::is_same::value ? T15::ID : + (unsigned int) etl::is_same::value ? T16::ID : (unsigned int) UNKNOWN }; @@ -179,21 +178,21 @@ namespace etl // For 16 types. //*************************************************************************** template , - typename T3 = etl::type_type_pair, - typename T4 = etl::type_type_pair, - typename T5 = etl::type_type_pair, - typename T6 = etl::type_type_pair, - typename T7 = etl::type_type_pair, - typename T8 = etl::type_type_pair, - typename T9 = etl::type_type_pair, - typename T10 = etl::type_type_pair, - typename T11 = etl::type_type_pair, - typename T12 = etl::type_type_pair, - typename T13 = etl::type_type_pair, - typename T14 = etl::type_type_pair, - typename T15 = etl::type_type_pair, - typename T16 = etl::type_type_pair > + typename T2 = etl::type_type_pair, etl::null_type<0>>, + typename T3 = etl::type_type_pair, etl::null_type<0>>, + typename T4 = etl::type_type_pair, etl::null_type<0>>, + typename T5 = etl::type_type_pair, etl::null_type<0>>, + typename T6 = etl::type_type_pair, etl::null_type<0>>, + typename T7 = etl::type_type_pair, etl::null_type<0>>, + typename T8 = etl::type_type_pair, etl::null_type<0>>, + typename T9 = etl::type_type_pair, etl::null_type<0>>, + typename T10 = etl::type_type_pair, etl::null_type<0>>, + typename T11 = etl::type_type_pair, etl::null_type<0>>, + typename T12 = etl::type_type_pair, etl::null_type<0>>, + typename T13 = etl::type_type_pair, etl::null_type<0>>, + typename T14 = etl::type_type_pair, etl::null_type<0>>, + typename T15 = etl::type_type_pair, etl::null_type<0>>, + typename T16 = etl::type_type_pair, etl::null_type<0>> > struct type_type_lookup { public: @@ -202,7 +201,7 @@ namespace etl template struct type_from_type { - typedef + typedef typename etl::conditional::value, typename T1::type2, typename etl::conditional::value, typename T2::type2, typename etl::conditional::value, typename T3::type2, @@ -219,10 +218,10 @@ namespace etl typename etl::conditional::value, typename T14::type2, typename etl::conditional::value, typename T15::type2, typename etl::conditional::value, typename T16::type2, - etl::null_type>::type>::type>::type>::type>::type>::type>::type>::type> - ::type>::type>::type>::type>::type>::type>::type>::type type; + etl::null_type<0>>::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same::value), "Invalid type"); + STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid type"); }; }; } diff --git a/include/etl/type_lookup_generator.h b/include/etl/type_lookup_generator.h index da849c5b..398773bd 100644 --- a/include/etl/type_lookup_generator.h +++ b/include/etl/type_lookup_generator.h @@ -26,14 +26,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_LOOKUP__ -#define __ETL_TYPE_LOOKUP__ +#ifndef ETL_TYPE_LOOKUP_INCLUDED +#define ETL_TYPE_LOOKUP_INCLUDED #include #include "platform.h" #include "type_traits.h" #include "static_assert.h" +#include "null_type.h" #undef ETL_FILE #define ETL_FILE "45" @@ -53,15 +54,13 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ namespace etl { - struct null_type {}; - //*************************************************************************** /// The type/id pair type to use for type/id lookup template parameters. //*************************************************************************** @@ -93,8 +92,8 @@ namespace etl cog.outl("//***************************************************************************") cog.outl("template ," %(n, n)) - cog.outl(" typename T%s = etl::type_id_pair >" %(NTypes, NTypes)) + cog.outl(" typename T%s = etl::type_id_pair, -%s>," %(n, n)) + cog.outl(" typename T%s = etl::type_id_pair, -%s> >" %(NTypes, NTypes)) cog.outl("struct type_id_lookup") cog.outl("{") cog.outl("public:") @@ -106,7 +105,7 @@ namespace etl cog.outl(" typedef ") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional") + cog.out(" etl::null_type<0>>") for n in range(1, int(NTypes) + 1): if n == int(NTypes): cog.outl("::type type;") @@ -115,9 +114,9 @@ namespace etl if n % 4 == 0: if n != int(NTypes): cog.outl("") - cog.out(" ") + cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same::value), \"Invalid id\");") + cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid id\");") cog.outl(" };") cog.outl("") cog.outl(" //************************************") @@ -160,8 +159,8 @@ namespace etl cog.outl("//***************************************************************************") cog.outl("template ," %n) - cog.outl(" typename T%s = etl::type_type_pair >" %NTypes) + cog.outl(" typename T%s = etl::type_type_pair, etl::null_type<0>>," %n) + cog.outl(" typename T%s = etl::type_type_pair, etl::null_type<0>> >" %NTypes) cog.outl("struct type_type_lookup") cog.outl("{") cog.outl("public:") @@ -173,7 +172,7 @@ namespace etl cog.outl(" typedef ") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional::value, typename T%s::type2," %(n, n)) - cog.out(" etl::null_type>") + cog.out(" etl::null_type<0>>") for n in range(1, int(NTypes) + 1): if n == int(NTypes): cog.outl("::type type;") @@ -182,9 +181,9 @@ namespace etl if n % 8 == 0: if n != int(NTypes): cog.outl("") - cog.out(" ") + cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same::value), \"Invalid type\");") + cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid type\");") cog.outl(" };") cog.outl("};") ]]]*/ diff --git a/include/etl/type_select.h b/include/etl/type_select.h new file mode 100644 index 00000000..52c8f5f5 --- /dev/null +++ b/include/etl/type_select.h @@ -0,0 +1,590 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_TYPE_SELECT_INCLUDED +#define ETL_TYPE_SELECT_INCLUDED + +#include "platform.h" +#include "static_assert.h" +#include "type_traits.h" +#include "null_type.h" + +#undef ETL_FILE +#define ETL_FILE "49" + +#if 0 +#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE. +#endif + +//*************************************************************************** +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. +//*************************************************************************** + +namespace etl +{ + //*************************************************************************** + // For 16 types. + //*************************************************************************** + template + struct type_select + { + public: + + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 16, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 15 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 15, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 14 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 14, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 13 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 13, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 12 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 12, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 11 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type type; + + STATIC_ASSERT(ID < 11, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 10 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type type; + + STATIC_ASSERT(ID < 10, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 9 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type type; + + STATIC_ASSERT(ID < 9, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 8 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 8, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 7 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 7, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 6 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 6, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 5 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 5, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 4 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 4, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 3 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type type; + + STATIC_ASSERT(ID < 3, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 2 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type type; + + STATIC_ASSERT(ID < 2, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 1 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type type; + + STATIC_ASSERT(ID < 1, "Invalid ID"); + }; + }; +} + +#undef ETL_FILE + +#endif diff --git a/include/etl/type_select_generator.h b/include/etl/type_select_generator.h new file mode 100644 index 00000000..e804360b --- /dev/null +++ b/include/etl/type_select_generator.h @@ -0,0 +1,134 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_TYPE_SELECT_INCLUDED +#define ETL_TYPE_SELECT_INCLUDED + +#include "platform.h" +#include "static_assert.h" +#include "type_traits.h" +#include "null_type.h" + +#undef ETL_FILE +#define ETL_FILE "49" + +/*[[[cog +import cog +cog.outl("#if 0") +]]]*/ +/*[[[end]]]*/ +#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE. +/*[[[cog +import cog +cog.outl("#endif") +]]]*/ +/*[[[end]]]*/ + +/*[[[cog +import cog +cog.outl("//***************************************************************************") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") +cog.outl("//***************************************************************************") +]]]*/ +/*[[[end]]]*/ + +namespace etl +{ + /*[[[cog + import cog + cog.outl("//***************************************************************************") + cog.outl("// For %s types." % int(NTypes)) + cog.outl("//***************************************************************************") + cog.outl("template " %(int(NTypes) - 1)) + cog.outl("struct type_select") + cog.outl("{") + cog.outl("public:") + cog.outl("") + cog.outl(" template ") + cog.outl(" struct select") + cog.outl(" {") + cog.outl(" typedef typename etl::conditional >") + cog.out(" ") + for n in range(1, int(NTypes)) : + cog.out("::type>") + if n % 8 == 0: + cog.outl("") + cog.out(" ") + cog.outl("::type type;") + cog.outl(""); + cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % int(NTypes)); + cog.outl(" };") + cog.outl("};") + + for s in range(int(NTypes) - 1, 0, -1): + cog.outl("") + cog.outl("//***************************************************************************") + cog.outl("// For %s types." % int(s)) + cog.outl("//***************************************************************************") + cog.out("template <") + for n in range(0, s - 1): + cog.outl("typename T%s, " % n) + cog.out(" ") + cog.outl("typename T%s>" % (s - 1)) + cog.out("struct type_select<") + for n in range(0, s - 1): + cog.out("T%s, " % n) + cog.outl("T%s>" % (s - 1)) + cog.outl("{") + cog.outl("public:") + cog.outl(" template ") + cog.outl(" struct select") + cog.outl(" {") + cog.outl(" typedef typename etl::conditional >") + cog.out(" ") + for n in range(1, s) : + cog.out("::type>") + if n % 8 == 0: + cog.outl("") + cog.out(" ") + cog.outl("::type type;") + cog.outl(""); + cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % s); + cog.outl(" };") + cog.outl("};") + ]]]*/ + /*[[[end]]]*/ +} + +#undef ETL_FILE + +#endif diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 127ee6ee..a28a2065 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_TYPE_TRAITS__ -#define __ETL_TYPE_TRAITS__ +#ifndef ETL_TYPE_TRAITS_INCLUDED +#define ETL_TYPE_TRAITS_INCLUDED #include #include diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index b4d488de..c993d746 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_TYPE_TRAITS__ -#define __ETL_TYPE_TRAITS__ +#ifndef ETL_TYPE_TRAITS_INCLUDED +#define ETL_TYPE_TRAITS_INCLUDED #include #include diff --git a/include/etl/u16string.h b/include/etl/u16string.h index b9d81f04..f9c5d22f 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_U16STRING__ -#define __ETL_U16STRING__ +#ifndef ETL_U16STRING_INCLUDED +#define ETL_U16STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -214,7 +212,7 @@ namespace etl { size_t operator()(const etl::iu16string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -224,15 +222,13 @@ namespace etl { size_t operator()(const etl::u16string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 8df0ccd6..23554cf4 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_U32STRING__ -#define __ETL_U32STRING__ +#ifndef ETL_U32STRING_INCLUDED +#define ETL_U32STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -214,7 +212,7 @@ namespace etl { size_t operator()(const etl::iu32string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -224,15 +222,13 @@ namespace etl { size_t operator()(const etl::u32string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index c1d4d331..0f757b0e 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MAP__ -#define __ETL_UNORDERED_MAP__ +#ifndef ETL_UNORDERED_MAP_INCLUDED +#define ETL_UNORDERED_MAP_INCLUDED #include #include @@ -658,7 +658,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key, T()); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; pbucket->insert_after(pbucket->before_begin(), node); @@ -788,7 +788,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -822,7 +822,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -892,7 +892,7 @@ namespace etl icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. n = 1; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } return n; @@ -921,7 +921,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -956,7 +956,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1224,7 +1224,7 @@ namespace etl { // Destroy the value contents. it->key_value_pair.~value_type(); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; ++it; } @@ -1282,7 +1282,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index ea8c5792..25257d39 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MULTIMAP__ -#define __ETL_UNORDERED_MULTIMAP__ +#ifndef ETL_UNORDERED_MULTIMAP_INCLUDED +#define ETL_UNORDERED_MULTIMAP_INCLUDED #include #include @@ -677,7 +677,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -707,7 +707,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -770,7 +770,7 @@ namespace etl pnodepool->release(&*icurrent); // Release it back to the pool. ++n; icurrent = iprevious; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } else { @@ -806,7 +806,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -841,7 +841,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1136,7 +1136,7 @@ namespace etl // Destroy the value contents. it->key_value_pair.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1192,7 +1192,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 829849da..11cbc07a 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MULTISET__ -#define __ETL_UNORDERED_MULTISET__ +#ifndef ETL_UNORDERED_MULTISET_INCLUDED +#define ETL_UNORDERED_MULTISET_INCLUDED #include #include @@ -669,7 +669,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -700,7 +700,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -764,7 +764,7 @@ namespace etl pnodepool->release(&*icurrent); // Release it back to the pool. ++n; icurrent = iprevious; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } else { @@ -800,7 +800,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -835,7 +835,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1130,7 +1130,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1186,7 +1186,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 5cf2bc86..94473567 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_SET__ -#define __ETL_UNORDERED_SET__ +#ifndef ETL_UNORDERED_SET_INCLUDED +#define ETL_UNORDERED_SET_INCLUDED #include #include @@ -670,7 +670,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -704,7 +704,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -774,7 +774,7 @@ namespace etl icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. n = 1; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } return n; @@ -803,7 +803,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -838,7 +838,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1107,7 +1107,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1163,7 +1163,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/user_type.h b/include/etl/user_type.h index 49adae7b..5b7c3e32 100644 --- a/include/etl/user_type.h +++ b/include/etl/user_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_USER_TYPE__ -#define __ETL_USER_TYPE__ +#ifndef ETL_USER_TYPE_INCLUDED +#define ETL_USER_TYPE_INCLUDED #include "platform.h" diff --git a/include/etl/utility.h b/include/etl/utility.h index 8c96f1be..05e4a569 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UTILITY__ -#define __ETL_UTILITY__ +#ifndef ETL_UTILITY_INCLUDED +#define ETL_UTILITY_INCLUDED #include "platform.h" #include "type_traits.h" diff --git a/include/etl/variant.h b/include/etl/variant.h index 429ad708..182e19c8 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VARIANT__ -#define __ETL_VARIANT__ +#ifndef ETL_VARIANT_INCLUDED +#define ETL_VARIANT_INCLUDED #include @@ -59,7 +59,7 @@ SOFTWARE. namespace etl { - namespace __private_variant__ + namespace private_variant { //************************************************************************* /// Placeholder for unused template parameters. @@ -103,13 +103,13 @@ namespace etl ///\ingroup variant //*************************************************************************** template , - typename T3 = __private_variant__::no_type<3>, - typename T4 = __private_variant__::no_type<4>, - typename T5 = __private_variant__::no_type<5>, - typename T6 = __private_variant__::no_type<6>, - typename T7 = __private_variant__::no_type<7>, - typename T8 = __private_variant__::no_type<8> > + typename T2 = private_variant::no_type<2>, + typename T3 = private_variant::no_type<3>, + typename T4 = private_variant::no_type<4>, + typename T5 = private_variant::no_type<5>, + typename T6 = private_variant::no_type<6>, + typename T7 = private_variant::no_type<7>, + typename T8 = private_variant::no_type<8> > class variant { public: @@ -148,13 +148,13 @@ namespace etl //*************************************************************************** /// Short form of no_type placeholders. //*************************************************************************** - typedef __private_variant__::no_type<2> no_type2; - typedef __private_variant__::no_type<3> no_type3; - typedef __private_variant__::no_type<4> no_type4; - typedef __private_variant__::no_type<5> no_type5; - typedef __private_variant__::no_type<6> no_type6; - typedef __private_variant__::no_type<7> no_type7; - typedef __private_variant__::no_type<8> no_type8; + typedef private_variant::no_type<2> no_type2; + typedef private_variant::no_type<3> no_type3; + typedef private_variant::no_type<4> no_type4; + typedef private_variant::no_type<5> no_type5; + typedef private_variant::no_type<6> no_type6; + typedef private_variant::no_type<7> no_type7; + typedef private_variant::no_type<8> no_type8; //*************************************************************************** /// Lookup the id of type. @@ -912,7 +912,7 @@ namespace etl //*************************************************************************** /// Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID //*************************************************************************** - ETL_CONSTEXPR size_t index() const + size_t index() const { return type_id; } diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index 55e1a45a..c08dac50 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_VARIANT_POOL__ -#define __ETL_VARIANT_POOL__ +#ifndef ETL_VARIANT_POOL_INCLUDED +#define ETL_VARIANT_POOL_INCLUDED #include #include diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 6ca24891..5c117bdf 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_VARIANT_POOL__ -#define __ETL_VARIANT_POOL__ +#ifndef ETL_VARIANT_POOL_INCLUDED +#define ETL_VARIANT_POOL_INCLUDED #include #include diff --git a/include/etl/vector.h b/include/etl/vector.h index 4a7a9e73..41683a93 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -5,7 +5,7 @@ The MIT License(MIT) Embedded Template Library. https://github.com/ETLCPP/etl -http://www.etlcpp.com +https://www.etlcpp.com Copyright(c) 2014 jwellbelove @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VECTOR__ -#define __ETL_VECTOR__ +#ifndef ETL_VECTOR_INCLUDED +#define ETL_VECTOR_INCLUDED -#define __ETL_IN_VECTOR_H__ +#define ETL_IN_VECTOR_H #include #include @@ -233,16 +233,12 @@ namespace etl if (current_size < new_size) { etl::uninitialized_fill_n(p_end, delta, value); -#if defined(ETL_DEBUG) - construct_count += delta; -#endif + ETL_ADD_DEBUG_COUNT(delta); } else { etl::destroy_n(p_end - delta, delta); -#if defined(ETL_DEBUG) - construct_count -= delta; -#endif + ETL_SUBTRACT_DEBUG_COUNT(delta); } p_end = p_buffer + new_size; @@ -372,11 +368,8 @@ namespace etl initialise(); -#if defined(ETL_DEBUG) - p_end = etl::uninitialized_copy(first, last, p_buffer, construct_count); -#else p_end = etl::uninitialized_copy(first, last, p_buffer); -#endif + ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last))); } //********************************************************************* @@ -391,11 +384,8 @@ namespace etl initialise(); -#if defined(ETL_DEBUG) - p_end = etl::uninitialized_fill_n(p_buffer, n, value, construct_count); -#else p_end = etl::uninitialized_fill_n(p_buffer, n, value); -#endif + ETL_ADD_DEBUG_COUNT(uint32_t(n)); } //************************************************************************* @@ -445,7 +435,7 @@ namespace etl #endif ::new (p_end) T(value1); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -461,7 +451,7 @@ namespace etl #endif ::new (p_end) T(value1, value2); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -477,7 +467,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -493,7 +483,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3, value4); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -545,7 +535,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -573,7 +563,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -601,7 +591,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -629,7 +619,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -680,31 +670,19 @@ namespace etl size_t copy_new_n = construct_old_n; size_t construct_new_n = insert_n - copy_new_n; -#if defined(ETL_DEBUG) - // Construct old. - etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count); - - // Copy old. - etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); - - // Construct new. - etl::uninitialized_fill_n(p_end, construct_new_n, value, construct_count); - - // Copy new. - std::fill_n(p_buffer + insert_begin, copy_new_n, value); -#else // Construct old. etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old); + ETL_ADD_DEBUG_COUNT(construct_old_n); // Copy old. etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); // 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); -#endif p_end += n; } @@ -749,31 +727,19 @@ namespace etl size_t copy_new_n = construct_old_n; size_t construct_new_n = insert_n - copy_new_n; -#if defined(ETL_DEBUG) - // Construct old. - etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count); - - // Copy old. - etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); - - // Construct new. - etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end, construct_count); - - // Copy new. - etl::copy_n(first, copy_new_n, p_buffer + insert_begin); -#else // Construct old. etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old); + ETL_ADD_DEBUG_COUNT(construct_old_n); // Copy old. etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); // Construct new. etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end); + ETL_ADD_DEBUG_COUNT(construct_new_n); // Copy new. etl::copy_n(first, copy_new_n, p_buffer + insert_begin); -#endif p_end += count; } @@ -811,11 +777,8 @@ namespace etl size_t n_delete = std::distance(first, last); // Destroy the elements left over at the end. -#if defined(ETL_DEBUG) - etl::destroy(p_end - n_delete, p_end, construct_count); -#else etl::destroy(p_end - n_delete, p_end); -#endif + ETL_SUBTRACT_DEBUG_COUNT(n_delete); p_end -= n_delete; } @@ -895,11 +858,8 @@ namespace etl //********************************************************************* void initialise() { -#if defined(ETL_DEBUG) - etl::destroy(p_buffer, p_end, construct_count); -#else etl::destroy(p_buffer, p_end); -#endif + ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))); p_end = p_buffer; } @@ -924,11 +884,9 @@ namespace etl //********************************************************************* inline void create_back() { -#if defined(ETL_DEBUG) - etl::create_value_at(p_end, construct_count); -#else etl::create_value_at(p_end); -#endif + ETL_INCREMENT_DEBUG_COUNT; + ++p_end; } @@ -937,11 +895,9 @@ namespace etl //********************************************************************* inline void create_back(parameter_t value) { -#if defined(ETL_DEBUG) - etl::create_copy_at(p_end, value, construct_count); -#else etl::create_copy_at(p_end, value); -#endif + ETL_INCREMENT_DEBUG_COUNT; + ++p_end; } @@ -952,11 +908,8 @@ namespace etl { --p_end; -#if defined(ETL_DEBUG) - etl::destroy_at(p_end, construct_count); -#else etl::destroy_at(p_end); -#endif + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/version.h b/include/etl/version.h index 56981517..c00eabc8 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VERSION__ -#define __ETL_VERSION__ +#ifndef ETL_VERSION_INCLUDED +#define ETL_VERSION_INCLUDED #include @@ -37,9 +37,9 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.6.0" +#define ETL_VERSION "11.8.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 6 +#define ETL_VERSION_MINOR 8 #define ETL_VERSION_PATCH 0 #endif diff --git a/include/etl/visitor.h b/include/etl/visitor.h index b6c412d0..70e58252 100644 --- a/include/etl/visitor.h +++ b/include/etl/visitor.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VISITOR__ -#define __ETL_VISITOR__ +#ifndef ETL_VISITOR_INCLUDED +#define ETL_VISITOR_INCLUDED #include "platform.h" diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 7a2a94ce..d3d6eb65 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_WSTRING__ -#define __ETL_WSTRING__ +#ifndef ETL_WSTRING_INCLUDED +#define ETL_WSTRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -215,7 +213,7 @@ namespace etl { size_t operator()(const etl::iwstring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -225,15 +223,13 @@ namespace etl { size_t operator()(const etl::wstring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index d86df051..26605032 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,17 @@ +=============================================================================== +11.8.0 +Added more binary utilities. +binary_fill +has_zero_byte +has_byte_n + +=============================================================================== +11.7.0 +Modified header guards. +Added etl::type_select +Added etl::null_type + +=============================================================================== 11.6.0 Added capacity() to etl::queue Prefixed max_size() and capacity() with ETL_CONSTEXPR in all queue types. diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 69583f71..65639955 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -157,6 +157,7 @@ + @@ -213,6 +214,7 @@ + @@ -406,6 +408,7 @@ + diff --git a/test/data.h b/test/data.h index 9db25ab4..0fbf9ed6 100644 --- a/test/data.h +++ b/test/data.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __test_data__ -#define __test_data__ +#ifndef ETL_TEST_DATA_INCLUDED +#define ETL_TEST_DATA_INCLUDED #include diff --git a/test/ecl_user.h b/test/ecl_user.h index 418bdee9..cc2c8f03 100644 --- a/test/ecl_user.h +++ b/test/ecl_user.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ECL_USER__ -#define __ECL_USER__ +#ifndef ECL_USER_INCLUDED +#define ECL_USER_INCLUDED #include diff --git a/test/etl_profile.h b/test/etl_profile.h index d2f02616..906660b9 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PROFILE_H__ -#define __ETL_PROFILE_H__ +#ifndef ETL_PROFILE_H_INCLUDED +#define ETL_PROFILE_H_INCLUDED #define ETL_THROW_EXCEPTIONS #define ETL_VERBOSE_ERRORS @@ -38,6 +38,7 @@ SOFTWARE. #define ETL_IVECTOR_REPAIR_ENABLE #define ETL_IDEQUE_REPAIR_ENABLE #define ETL_IN_UNIT_TEST +#define ETL_DEBUG_COUNT #define ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK #define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK diff --git a/test/test_array_view.cpp b/test/test_array_view.cpp index 9574cd23..875b4bb7 100644 --- a/test/test_array_view.cpp +++ b/test/test_array_view.cpp @@ -604,7 +604,7 @@ namespace View view(etldata.begin(), etldata.end()); CView cview(etldata.begin(), etldata.end()); - size_t hashdata = etl::__private_hash__::generic_hash(reinterpret_cast(&etldata[0]), + size_t hashdata = etl::private_hash::generic_hash(reinterpret_cast(&etldata[0]), reinterpret_cast(&etldata[etldata.size()])); size_t hashview = etl::hash()(view); diff --git a/test/test_array_wrapper.cpp b/test/test_array_wrapper.cpp index c084f72c..b803575a 100644 --- a/test/test_array_wrapper.cpp +++ b/test/test_array_wrapper.cpp @@ -559,7 +559,7 @@ namespace size_t hash = etl::hash()(aw5); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); CHECK_EQUAL(compare_hash, hash); diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 5689d400..fc5ecbc4 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -36,8 +36,6 @@ SOFTWARE. #include "fnv_1.h" #include "integral_limits.h" -#undef max - // Count bits the easy way. template size_t test_count(T value) @@ -1058,11 +1056,11 @@ namespace { uint8_t value8 = 0x2A; uint8_t value8mask = 0x3F; - + const uint32_t value_initial = 0x55555555; uint32_t value; - + // Shift 0 value = value_initial; value &= ~value8mask; @@ -1278,6 +1276,210 @@ namespace CHECK_EQUAL(N << 30, etl::b30); CHECK_EQUAL(N << 31, uint32_t(etl::b31)); } + + //************************************************************************* + TEST(test_binary_fill_compile_time) + { + CHECK_EQUAL(0x12U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212U, (etl::binary_fill::value)); + CHECK_EQUAL(0x12121212U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212, (etl::binary_fill::value)); + CHECK_EQUAL(0x12121212, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212121212121212, (etl::binary_fill::value)); + + CHECK_EQUAL(0x1234U, (etl::binary_fill::value)); + CHECK_EQUAL(0x12341234U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x1234, (etl::binary_fill::value)); + CHECK_EQUAL(0x12341234, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234123412341234, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12345678, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234567812345678, (etl::binary_fill::value)); + + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x123456789ABCDEF0, (etl::binary_fill::value)); + } + + //************************************************************************* + TEST(test_binary_fill_run_time) + { + CHECK_EQUAL(0x12U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x12121212U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill::value(0x12))); + + CHECK_EQUAL(0x12, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x12121212, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212121212121212, (etl::binary_fill::value(0x12))); + + CHECK_EQUAL(0x1234U, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x12341234U, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill::value(0x1234))); + + CHECK_EQUAL(0x1234, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x12341234, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x1234123412341234, (etl::binary_fill::value(0x1234))); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill::value(0x12345678))); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value(0x12345678))); + + CHECK_EQUAL(int32_t(0x12345678), int32_t(etl::binary_fill::value(0x12345678))); + CHECK_EQUAL(int64_t(0x1234567812345678), int64_t(etl::binary_fill::value(0x12345678))); + + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value(0x123456789ABCDEF0))); + + CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill::value(0x123456789ABCDEF0))); + } + + //************************************************************************* + TEST(test_has_zero_compile_time) + { + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + } + + //************************************************************************* + TEST(test_has_zero_run_time) + { + CHECK(!(etl::has_zero_byte<>::test(uint8_t(0x01)))); + CHECK((etl::has_zero_byte<>::test(uint8_t(0x00)))); + + CHECK(!(etl::has_zero_byte<>::test(int8_t(0x01)))); + CHECK((etl::has_zero_byte<>::test(int8_t(0x00)))); + + CHECK(!(etl::has_zero_byte<>::test(uint16_t(0x0123)))); + CHECK((etl::has_zero_byte<>::test(uint16_t(0x0100)))); + + CHECK(!(etl::has_zero_byte<>::test(int16_t(0x0123)))); + CHECK((etl::has_zero_byte<>::test(int16_t(0x0100)))); + + CHECK(!(etl::has_zero_byte<>::test(uint32_t(0x01234567)))); + CHECK((etl::has_zero_byte<>::test(uint32_t(0x01230067)))); + + CHECK(!(etl::has_zero_byte<>::test(int32_t(0x01234567)))); + CHECK((etl::has_zero_byte<>::test(int32_t(0x01230067)))); + + CHECK(!(etl::has_zero_byte<>::test(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte<>::test(uint64_t(0x012345678900CDEF)))); + + CHECK(!(etl::has_zero_byte<>::test(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte<>::test(int64_t(0x012345678900CDEF)))); + } + + //************************************************************************* + TEST(test_has_n_compile_time) + { + CHECK(!(etl::has_byte_n<0x12, uint8_t, 0x01>::test)); + CHECK((etl::has_byte_n<0x01, uint8_t, 0x01>::test)); + + CHECK(!(etl::has_byte_n<0x12, int8_t, 0x01>::test)); + CHECK((etl::has_byte_n<0x01, int8_t, 0x01>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint16_t, 0x0123>::test)); + CHECK((etl::has_byte_n<0x23, uint16_t, 0x0123>::test)); + + CHECK(!(etl::has_byte_n<0x12, int16_t, 0x0123>::test)); + CHECK((etl::has_byte_n<0x23, int16_t, 0x0123>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint32_t, 0x01234567>::test)); + CHECK((etl::has_byte_n<0x45, uint32_t, 0x01234567>::test)); + + CHECK(!(etl::has_byte_n<0x12, int32_t, 0x01234567>::test)); + CHECK((etl::has_byte_n<0x45, int32_t, 0x01234567>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint64_t, 0x0123456789ABCDEF>::test)); + CHECK((etl::has_byte_n<0xAB, uint64_t, 0x0123456789ABCDEF>::test)); + + CHECK(!(etl::has_byte_n<0x12, int64_t, 0x0123456789ABCDEF>::test)); + CHECK((etl::has_byte_n<0xAB, int64_t, 0x0123456789ABCDEF>::test)); + } + + //************************************************************************* + TEST(test_has_n_partial_run_time) + { + CHECK(!(etl::has_byte_n<0x12>::test(uint8_t(0x01)))); + CHECK((etl::has_byte_n<0x01>::test(uint8_t(0x01)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int8_t(0x01)))); + CHECK((etl::has_byte_n<0x01>::test(int8_t(0x01)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint16_t(0x0123)))); + CHECK((etl::has_byte_n<0x23>::test(uint16_t(0x0123)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int16_t(0x0123)))); + CHECK((etl::has_byte_n<0x23>::test(int16_t(0x0123)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint32_t(0x01234567)))); + CHECK((etl::has_byte_n<0x45>::test(uint32_t(0x01234567)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int32_t(0x01234567)))); + CHECK((etl::has_byte_n<0x45>::test(int32_t(0x01234567)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n<0xAB>::test(uint64_t(0x0123456789ABCDEF)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n<0xAB>::test(int64_t(0x0123456789ABCDEF)))); + } + + //************************************************************************* + TEST(test_has_n_run_time) + { + CHECK(!(etl::has_byte_n<>::test(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n<>::test(uint8_t(0x01), 0x01))); + + CHECK(!(etl::has_byte_n<>::test(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n<>::test(uint8_t(0x01), 0x01))); + + CHECK(!(etl::has_byte_n<>::test(uint16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n<>::test(uint16_t(0x0123), 0x23))); + + CHECK(!(etl::has_byte_n<>::test(int16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n<>::test(int16_t(0x0123), 0x23))); + + CHECK(!(etl::has_byte_n<>::test(uint32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n<>::test(uint32_t(0x01234567), 0x45))); + + CHECK(!(etl::has_byte_n<>::test(int32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n<>::test(int32_t(0x01234567), 0x45))); + + CHECK(!(etl::has_byte_n<>::test(uint64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n<>::test(uint64_t(0x0123456789ABCDEF), 0xAB))); + + CHECK(!(etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0xAB))); + } }; } diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index fa5b47ae..b3991918 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -34,9 +34,6 @@ SOFTWARE. #include "bitset.h" -#undef min -#undef max - namespace { SUITE(test_bitset) diff --git a/test/test_constant.cpp b/test/test_constant.cpp index f3c6dda9..6cd1587a 100644 --- a/test/test_constant.cpp +++ b/test/test_constant.cpp @@ -28,8 +28,6 @@ SOFTWARE. #include "UnitTest++.h" -#undef max - #include "constant.h" #include "integral_limits.h" diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index c48e6f37..8a23abf8 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -34,9 +34,6 @@ SOFTWARE. #include "integral_limits.h" -#undef min -#undef max - namespace { SUITE(test_integral_limits) diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index b9f39105..9b8b7bee 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -45,6 +45,42 @@ SOFTWARE. namespace { + struct Data + { + Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) + : a(a_), + b(b_), + c(c_), + d(d_) + { + } + + Data() + : a(0), + b(0), + c(0), + d(0) + { + } + + int a; + int b; + int c; + int d; + }; + + bool operator ==(const Data& lhs, const Data& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); + } + + std::ostream& operator <<(std::ostream& os, const Data& data) + { + os << data.a << " " << data.b << " " << data.c << " " << data.d; + + return os; + } + SUITE(test_queue_mpmc_mutex) { //************************************************************************* @@ -371,7 +407,7 @@ namespace std::thread t2(push_thread2); std::thread t3(pop_thread1); std::thread t4(pop_thread2); - + start.store(true); // Join the threads with the main thread diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index bcf1f356..3d9aab80 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -35,8 +35,6 @@ SOFTWARE. #include "cstring.h" #include "fnv_1.h" -#undef min - #undef STR #define STR(x) x @@ -3032,7 +3030,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 0d1a2e5d..62de9237 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "u16string.h" -#undef min - #undef STR #define STR(x) u##x @@ -3031,7 +3029,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index eb4db72f..4cfd43f9 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "u32string.h" -#undef min - #undef STR #define STR(x) U##x @@ -3031,7 +3029,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 47e8ce9f..ff538896 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "wstring.h" -#undef min - #undef STR #define STR(x) L##x @@ -3031,7 +3029,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_type_select.cpp b/test/test_type_select.cpp new file mode 100644 index 00000000..7ea7ecff --- /dev/null +++ b/test/test_type_select.cpp @@ -0,0 +1,116 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +http://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" +#include "ExtraCheckMacros.h" + +#include "type_select.h" +#include "null_type.h" + +#include + +namespace +{ + typedef etl::type_select> Types1; + + typedef etl::type_select, etl::null_type<1>, etl::null_type<2>, etl::null_type<3>, + etl::null_type<4>, etl::null_type<5>, etl::null_type<6>, etl::null_type<7>> Types8; + + typedef etl::type_select, etl::null_type<1>, etl::null_type<2>, etl::null_type<3>, + etl::null_type<4>, etl::null_type<5>, etl::null_type<6>, etl::null_type<7>, + etl::null_type<8>, etl::null_type<9>, etl::null_type<10>, etl::null_type<11>, + etl::null_type<12>, etl::null_type<13>, etl::null_type<14>, etl::null_type<15>> Types16; + + SUITE(test_type_lookup) + { + //************************************************************************* + TEST(test_type_select1) + { + CHECK((std::is_same, typename Types1::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types1::select<0>::type>::value)); + } + + //************************************************************************* + TEST(test_type_select8) + { + CHECK((std::is_same, typename Types8::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<0>::type>::value)); + CHECK((std::is_same, typename Types8::select<1>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<1>::type>::value)); + CHECK((std::is_same, typename Types8::select<2>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<2>::type>::value)); + CHECK((std::is_same, typename Types8::select<3>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<3>::type>::value)); + CHECK((std::is_same, typename Types8::select<4>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<4>::type>::value)); + CHECK((std::is_same, typename Types8::select<5>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<5>::type>::value)); + CHECK((std::is_same, typename Types8::select<6>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<6>::type>::value)); + CHECK((std::is_same, typename Types8::select<7>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<7>::type>::value)); + } + + //************************************************************************* + TEST(test_type_select16) + { + CHECK((std::is_same, typename Types16::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<0>::type>::value)); + CHECK((std::is_same, typename Types16::select<1>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<1>::type>::value)); + CHECK((std::is_same, typename Types16::select<2>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<2>::type>::value)); + CHECK((std::is_same, typename Types16::select<3>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<3>::type>::value)); + CHECK((std::is_same, typename Types16::select<4>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<4>::type>::value)); + CHECK((std::is_same, typename Types16::select<5>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<5>::type>::value)); + CHECK((std::is_same, typename Types16::select<6>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<6>::type>::value)); + CHECK((std::is_same, typename Types16::select<7>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<7>::type>::value)); + CHECK((std::is_same, typename Types16::select<8>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<8>::type>::value)); + CHECK((std::is_same, typename Types16::select<9>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<9>::type>::value)); + CHECK((std::is_same, typename Types16::select<10>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<10>::type>::value)); + CHECK((std::is_same, typename Types16::select<11>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<11>::type>::value)); + CHECK((std::is_same, typename Types16::select<12>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<12>::type>::value)); + CHECK((std::is_same, typename Types16::select<13>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<13>::type>::value)); + CHECK((std::is_same, typename Types16::select<14>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<14>::type>::value)); + CHECK((std::is_same, typename Types16::select<15>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<15>::type>::value)); + } + }; +} diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 87c633a5..abb1b7a1 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -337,6 +337,7 @@ + @@ -371,6 +372,8 @@ + + @@ -702,6 +705,7 @@ + @@ -722,6 +726,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index d45f1a84..eb3e8c7a 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -621,6 +621,15 @@ ETL\Maths + + ETL\Utilities + + + ETL\Utilities\Generators + + + ETL\Utilities + @@ -1019,6 +1028,9 @@ Source Files + + Source Files + @@ -1057,6 +1069,9 @@ Resource Files\Images + + Resource Files\Generators + From dee811efd0e8ac70b3b83e457a40724067ebd654 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 5 May 2018 09:52:00 +0100 Subject: [PATCH 02/28] Merge remote-tracking branch 'origin/development' # Conflicts: # test/vs2017/etl.vcxproj.filters --- include/etl/crc32_c.h | 108 ++++++++++++++++++++++++++++++++ src/crc32_c.cpp | 80 +++++++++++++++++++++++ test/codeblocks/ETL.cbp | 2 + test/vs2017/etl.vcxproj | 2 + test/vs2017/etl.vcxproj.filters | 6 ++ 5 files changed, 198 insertions(+) create mode 100644 include/etl/crc32_c.h create mode 100644 src/crc32_c.cpp diff --git a/include/etl/crc32_c.h b/include/etl/crc32_c.h new file mode 100644 index 00000000..cd47c145 --- /dev/null +++ b/include/etl/crc32_c.h @@ -0,0 +1,108 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_CRC32_C_INCLUDED +#define ETL_CRC32_C_INCLUDED + +#include +#include + +#include "platform.h" +#include "frame_check_sequence.h" + +#if defined(ETL_COMPILER_KEIL) +#pragma diag_suppress 1300 +#endif + +///\defgroup crc32_c 32 bit CRC-C calculation (Castagnoli) +///\ingroup crc + +namespace etl +{ + //*************************************************************************** + /// CRC32_C table + /// \ingroup crc32_c + //*************************************************************************** + extern const uint32_t CRC32_C[]; + + //*************************************************************************** + /// CRC32_C policy. + /// Calculates CRC32_C using polynomial 0x1EDC6F41. + //*************************************************************************** + struct crc_policy_32_c + { + typedef uint32_t value_type; + + inline uint32_t initial() const + { + return 0xFFFFFFFF; + } + + inline uint32_t add(uint32_t crc, uint8_t value) const + { + return (crc >> 8) ^ CRC32_C[(crc ^ value) & 0xFF]; + } + + inline uint32_t final(uint32_t crc) const + { + return crc ^ 0xFFFFFFFF; + } + }; + + //************************************************************************* + /// CRC32_C + //************************************************************************* + class crc32_c : public etl::frame_check_sequence + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_c() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_c(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +} + +#endif diff --git a/src/crc32_c.cpp b/src/crc32_c.cpp new file mode 100644 index 00000000..22700a32 --- /dev/null +++ b/src/crc32_c.cpp @@ -0,0 +1,80 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include + +#include "platform.h" + +namespace etl +{ + //*************************************************************************** + /// CRC32_C table + /// \ingroup CRC32_C + //*************************************************************************** + extern const uint32_t CRC32_C[] = + { + 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, + 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, + 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, + 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, + 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, + 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, + 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, + 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, + 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, + 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, + 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, + 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, + 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, + 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, + 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, + 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, + 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, + 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, + 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, + 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, + 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, + 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, + 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, + 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, + 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, + 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, + 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, + 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, + 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, + 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, + 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, + 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, + 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, + 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, + 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, + 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L + }; +} diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 65639955..b4758871 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -100,6 +100,7 @@ + @@ -240,6 +241,7 @@ + diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index abb1b7a1..eee0ad5c 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -333,6 +333,7 @@ + @@ -515,6 +516,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index eb3e8c7a..7ba6c7d5 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -630,6 +630,9 @@ ETL\Utilities + + ETL\Maths + @@ -1031,6 +1034,9 @@ Source Files + + ETL\Maths + From 09b769a8ba966e8c453807c58b0aa2127471b7be Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 9 May 2018 23:15:16 +0100 Subject: [PATCH 03/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # support/Release notes.txt --- include/etl/callback_timer.h | 19 +++++++------- include/etl/message_timer.h | 19 +++++++------- include/etl/version.h | 6 ++--- src/c/ecl_timer.c | 19 +++++++------- support/Release notes.txt | 8 ++++++ test/test_c_timer_framework.cpp | 46 +++++++++++++++++++++++++++++++++ test/test_callback_timer.cpp | 46 +++++++++++++++++++++++++++++++++ test/test_message_timer.cpp | 46 +++++++++++++++++++++++++++++++++ 8 files changed, 179 insertions(+), 30 deletions(-) diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index c0b4c72d..2547e346 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -423,13 +423,13 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - - // Reset in-place. - new (&timer) callback_timer_data(); - --registered_timers; - - result = true; } + + // Reset in-place. + new (&timer) callback_timer_data(); + --registered_timers; + + result = true; } } @@ -588,8 +588,9 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - result = true; } + + result = true; } } @@ -604,7 +605,7 @@ namespace etl if (stop(id_)) { timer_array[id_].period = period_; - return start(id_); + return true; } return false; @@ -618,7 +619,7 @@ namespace etl if (stop(id_)) { timer_array[id_].repeating = repeating_; - return start(id_); + return true; } return false; diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 9ec27add..9dab4780 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -392,13 +392,13 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, true); ETL_ENABLE_TIMER_UPDATES; - - // Reset in-place. - new (&timer) message_timer_data(); - --registered_timers; - - result = true; } + + // Reset in-place. + new (&timer) message_timer_data(); + --registered_timers; + + result = true; } } @@ -557,8 +557,9 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - result = true; } + + result = true; } } @@ -573,7 +574,7 @@ namespace etl if (stop(id_)) { timer_array[id_].period = period_; - return start(id_); + return true; } return false; @@ -587,7 +588,7 @@ namespace etl if (stop(id_)) { timer_array[id_].repeating = repeating_; - return start(id_); + return true; } return false; diff --git a/include/etl/version.h b/include/etl/version.h index c00eabc8..21282bce 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.8.0" +#define ETL_VERSION "11.9.1" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 8 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_MINOR 9 +#define ETL_VERSION_PATCH 1 #endif diff --git a/src/c/ecl_timer.c b/src/c/ecl_timer.c index 004ee669..145cb3e3 100644 --- a/src/c/ecl_timer.c +++ b/src/c/ecl_timer.c @@ -340,13 +340,13 @@ ecl_timer_result_t ecl_timer_unregister(ecl_timer_id_t id_) ECL_TIMER_DISABLE_PROCESSING; ecl_timer_list_remove(ptimer->id, 0); ECL_TIMER_ENABLE_PROCESSING; - - // Reset in-place. - ecl_timer_data_init_default(ptimer); - --ecl.registered_timers; - - result = ECL_TIMER_PASS; } + + // Reset in-place. + ecl_timer_data_init_default(ptimer); + --ecl.registered_timers; + + result = ECL_TIMER_PASS; } } @@ -506,8 +506,9 @@ ecl_timer_result_t ecl_timer_stop(ecl_timer_id_t id_) ECL_TIMER_DISABLE_PROCESSING; ecl_timer_list_remove(ptimer->id, 0); ECL_TIMER_ENABLE_PROCESSING; - result = ECL_TIMER_PASS; } + + result = ECL_TIMER_PASS; } } @@ -524,7 +525,7 @@ ecl_timer_result_t ecl_timer_set_period(ecl_timer_id_t id_, ecl_timer_time_t per if (ecl_timer_stop(id_)) { ecl.ptimers[id_].period = period_; - return ecl_timer_start(id_, 0); + return ECL_TIMER_PASS; } return ECL_TIMER_FAIL; @@ -540,7 +541,7 @@ ecl_timer_result_t ecl_timer_set_mode(ecl_timer_id_t id_, ecl_timer_mode_t repea if (ecl_timer_stop(id_)) { ecl.ptimers[id_].repeating = repeating_; - return ecl_timer_start(id_, 0); + return ECL_TIMER_PASS; } return ECL_TIMER_FAIL; diff --git a/support/Release notes.txt b/support/Release notes.txt index 26605032..7fec4cc5 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,11 @@ +=============================================================================== +11.9.1 +Fix Github issue #73 (Timers) + +=============================================================================== +11.9.0 +Added CRC32-C (Castagnoli) + =============================================================================== 11.8.0 Added more binary utilities. diff --git a/test/test_c_timer_framework.cpp b/test/test_c_timer_framework.cpp index 47aa0aa9..ec03f140 100644 --- a/test/test_c_timer_framework.cpp +++ b/test/test_c_timer_framework.cpp @@ -149,6 +149,52 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), callback_list3.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + ecl_timer_init(timers, NTIMERS); + + ecl_timer_id_t id1 = ecl_timer_register(callback1, 37, ECL_TIMER_SINGLE_SHOT); + callback_list1.clear(); + + ecl_timer_enable(ECL_TIMER_ENABLED); + ecl_timer_start(id1, ECL_TIMER_START_DELAYED); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + ecl_timer_tick(step); + } + + // Timer should have timed out. + + CHECK(ecl_timer_set_period(id1, 50)); + ecl_timer_start(id1, ECL_TIMER_START_DELAYED); + + callback_list1.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + ecl_timer_tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *callback_list1.data()); + + CHECK(ecl_timer_unregister(id1)); + CHECK(!ecl_timer_unregister(id1)); + CHECK(!ecl_timer_start(id1, ECL_TIMER_START_DELAYED)); + CHECK(!ecl_timer_stop(id1)); + } + //========================================================================= TEST(ecl_timer_repeating) { diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index eed41124..5cf31bb4 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -169,6 +169,52 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), free_tick_list2.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + etl::callback_timer<1> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); + test.tick_list.clear(); + + timer_controller.start(id1); + timer_controller.enable(true); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK(timer_controller.set_period(id1, 50)); + timer_controller.start(id1); + + test.tick_list.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *test.tick_list.data()); + + CHECK(timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.start(id1)); + CHECK(!timer_controller.stop(id1)); + } + //========================================================================= TEST(callback_timer_repeating) { diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index b8b3488c..e7659d80 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -191,6 +191,52 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), router1.message3.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + etl::message_timer<1> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + router1.clear(); + + timer_controller.start(id1); + timer_controller.enable(true); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK(timer_controller.set_period(id1, 50)); + timer_controller.start(id1); + + router1.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *router1.message1.data()); + + CHECK(timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.start(id1)); + CHECK(!timer_controller.stop(id1)); + } + //========================================================================= TEST(message_timer_repeating) { From c1a2213a58ddbbc02ba62975af5b65294e305470 Mon Sep 17 00:00:00 2001 From: mchodzikiewicz <33954140+mchodzikiewicz@users.noreply.github.com> Date: Thu, 10 May 2018 17:07:22 +0200 Subject: [PATCH 04/28] Fixed endif and namespace ending mismatch (#74) --- include/etl/debug_count.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index beebe6a7..b603b00c 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -123,14 +123,6 @@ namespace etl int32_t count; }; -#else -#define ETL_DECLARE_DEBUG_COUNT -#define ETL_INCREMENT_DEBUG_COUNT -#define ETL_DECREMENT_DEBUG_COUNT -#define ETL_ADD_DEBUG_COUNT(n) -#define ETL_SUBTRACT_DEBUG_COUNT(n) -#define ETL_RESET_DEBUG_COUNT -#endif // ETL_DEBUG_COUNT } #else From 54d04ce1d835ada9338c3214c7e744da1ded5e8f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 12 May 2018 09:24:48 +0100 Subject: [PATCH 05/28] Merge remote-tracking branch 'origin/development' --- include/etl/fsm.h | 98 ++++++++++++++++++--------------- include/etl/fsm_generator.h | 16 +++++- test/test_c_timer_framework.cpp | 2 +- test/test_callback_timer.cpp | 20 +++---- test/test_message_timer.cpp | 2 +- 5 files changed, 79 insertions(+), 59 deletions(-) diff --git a/include/etl/fsm.h b/include/etl/fsm.h index eeb343b9..d350467d 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.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. //*************************************************************************** //*************************************************************************** @@ -238,8 +238,9 @@ namespace etl /// Starts the FSM. /// Can only be called once. /// Subsequent calls will do nothing. + ///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true. //******************************************* - void start() + void start(bool call_on_enter_state = true) { // Can only be started once. if (p_state == nullptr) @@ -247,7 +248,10 @@ namespace etl p_state = state_list[0]; ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - p_state->on_enter_state(); + if (call_on_enter_state) + { + p_state->on_enter_state(); + } } } @@ -335,9 +339,15 @@ namespace etl //******************************************* /// Reset the FSM to pre-started state. + ///\param call_on_exit_state If true will call on_exit_state() for the current state. Default = false. //******************************************* - void reset() + void reset(bool call_on_exit_state = false) { + if ((p_state != nullptr) && call_on_exit_state) + { + p_state->on_exit_state(); + } + p_state = nullptr; } @@ -351,10 +361,10 @@ namespace etl //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -412,10 +422,10 @@ namespace etl //*************************************************************************** // Specialisation for 15 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -472,10 +482,10 @@ namespace etl //*************************************************************************** // Specialisation for 14 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -531,10 +541,10 @@ namespace etl //*************************************************************************** // Specialisation for 13 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -589,9 +599,9 @@ namespace etl //*************************************************************************** // Specialisation for 12 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -645,9 +655,9 @@ namespace etl //*************************************************************************** // Specialisation for 11 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -700,9 +710,9 @@ namespace etl //*************************************************************************** // Specialisation for 10 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -754,9 +764,9 @@ namespace etl //*************************************************************************** // Specialisation for 9 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -807,8 +817,8 @@ namespace etl //*************************************************************************** // Specialisation for 8 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -858,8 +868,8 @@ namespace etl //*************************************************************************** // Specialisation for 7 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -908,8 +918,8 @@ namespace etl //*************************************************************************** // Specialisation for 6 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -957,8 +967,8 @@ namespace etl //*************************************************************************** // Specialisation for 5 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -1005,7 +1015,7 @@ namespace etl //*************************************************************************** // Specialisation for 4 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -1051,7 +1061,7 @@ namespace etl //*************************************************************************** // Specialisation for 3 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -1096,7 +1106,7 @@ namespace etl //*************************************************************************** // Specialisation for 2 message types. //*************************************************************************** - template class fsm_state : public ifsm_state { @@ -1140,7 +1150,7 @@ namespace etl //*************************************************************************** // Specialisation for 1 message type. //*************************************************************************** - template class fsm_state : public ifsm_state { diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 91997b63..37007900 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -250,8 +250,9 @@ namespace etl /// Starts the FSM. /// Can only be called once. /// Subsequent calls will do nothing. + ///\param call_on_enter_state If true will call on_enter_state() for the first state. Default = true. //******************************************* - void start() + void start(bool call_on_enter_state = true) { // Can only be started once. if (p_state == nullptr) @@ -259,7 +260,10 @@ namespace etl p_state = state_list[0]; ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - p_state->on_enter_state(); + if (call_on_enter_state) + { + p_state->on_enter_state(); + } } } @@ -347,9 +351,15 @@ namespace etl //******************************************* /// Reset the FSM to pre-started state. + ///\param call_on_exit_state If true will call on_exit_state() for the current state. Default = false. //******************************************* - void reset() + void reset(bool call_on_exit_state = false) { + if ((p_state != nullptr) && call_on_exit_state) + { + p_state->on_exit_state(); + } + p_state = nullptr; } diff --git a/test/test_c_timer_framework.cpp b/test/test_c_timer_framework.cpp index ec03f140..00e98536 100644 --- a/test/test_c_timer_framework.cpp +++ b/test/test_c_timer_framework.cpp @@ -187,7 +187,7 @@ namespace // Timer should have timed out. - CHECK_EQUAL(50, *callback_list1.data()); + CHECK_EQUAL(50U, *callback_list1.data()); CHECK(ecl_timer_unregister(id1)); CHECK(!ecl_timer_unregister(id1)); diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index 5cf31bb4..d5197d3a 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -80,7 +80,7 @@ namespace etl::callback_timer<3>* p_controller; }; - + Test test; etl::function_imv member_callback; etl::function_imv member_callback2; @@ -147,7 +147,7 @@ namespace timer_controller.enable(true); ticks = 0; - + const uint32_t step = 1; while (ticks <= 100U) @@ -207,7 +207,7 @@ namespace // Timer should have timed out. - CHECK_EQUAL(50, *test.tick_list.data()); + CHECK_EQUAL(50U, *test.tick_list.data()); CHECK(timer_controller.unregister_timer(id1)); CHECK(!timer_controller.unregister_timer(id1)); @@ -346,7 +346,7 @@ namespace std::vector compare1 = { 77 }; std::vector compare2 = { 23 }; std::vector compare3 = { 11, 22, 33, 44, 55, 66, 77, 88, 99 }; - + CHECK(test.tick_list.size() != 0); CHECK(free_tick_list1.size() != 0); CHECK(free_tick_list2.size() != 0); @@ -442,7 +442,7 @@ namespace test.tick_list.clear(); free_tick_list1.clear(); free_tick_list2.clear(); - + timer_controller.start(id3); timer_controller.start(id2); @@ -455,7 +455,7 @@ namespace while (ticks <= 100U) { if (ticks == 40) - { + { timer_controller.unregister_timer(id2); id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); @@ -666,11 +666,11 @@ namespace RAISE_THREAD_PRIORITY; FIX_PROCESSOR_AFFINITY; - + while (ticks <= 1000) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); - + if (controller.tick(tick)) { tick = TICK; @@ -699,11 +699,11 @@ namespace controller.start(id1); controller.start(id2); //controller.start(id3); - + controller.enable(true); std::thread t1(timer_event); - + bool restart_1 = true; while (ticks <= 1000U) diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index e7659d80..392cd31a 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -229,7 +229,7 @@ namespace // Timer should have timed out. - CHECK_EQUAL(50, *router1.message1.data()); + CHECK_EQUAL(50U, *router1.message1.data()); CHECK(timer_controller.unregister_timer(id1)); CHECK(!timer_controller.unregister_timer(id1)); From eb36baedc7c2008247b06fabca589de2504722e6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 20 May 2018 10:29:28 +0100 Subject: [PATCH 06/28] Merge remote-tracking branch 'origin/development' --- include/etl/binary.h | 70 +++++++++++++++++++++++ src/binary.cpp | 128 +++++++++++++++++++++++++++++++++++++++++++ test/test_binary.cpp | 38 +++++++++++++ 3 files changed, 236 insertions(+) diff --git a/include/etl/binary.h b/include/etl/binary.h index c54bc1fc..c9fa2653 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -569,6 +569,76 @@ namespace etl }; #endif + //*************************************************************************** + /// Merges two values according to a mask. + /// Ones in the mask select bits from 'first', zeros select bits from second. + /// Mask is a function parameter. + //*************************************************************************** + template + T binary_merge(const T first, const T second, const T mask) + { + return second ^ ((second ^ first) & mask); + } + + //*************************************************************************** + /// Merges two values according to a mask. + /// Ones in the mask select bits from 'first', zeros select bits from second. + /// Mask is a template parameter. + //*************************************************************************** + template + T binary_merge(const T first, const T second) + { + return second ^ ((second ^ first) & MASK); + } + + //*************************************************************************** + /// Binary interleave + //*************************************************************************** +#if ETL_8BIT_SUPPORT + uint16_t binary_interleave(uint8_t first, uint8_t second); + inline int16_t binary_interleave(int8_t first, int8_t second) { return int16_t(binary_interleave(uint8_t(first), uint8_t(second))); } +#endif + uint32_t binary_interleave(uint16_t first, uint16_t second); + inline int32_t binary_interleave(int16_t first, int16_t second) { return int32_t(binary_interleave(uint16_t(first), uint16_t(second))); } + uint64_t binary_interleave(uint32_t first, uint32_t second); + inline int64_t binary_interleave(int32_t first, int32_t second) { return int64_t(binary_interleave(uint16_t(first), uint16_t(second))); } + + //*************************************************************************** + /// Checks if odd. + //*************************************************************************** + bool is_odd(const unsigned char value); + inline bool is_odd(const char value) { return is_odd((unsigned char)value); } + + bool is_odd(const unsigned short value); + inline bool is_odd(const short value) { return is_odd((unsigned short)value); } + + bool is_odd(const unsigned int value); + inline bool is_odd(const int value) { return is_odd((unsigned int)value); } + + bool is_odd(const unsigned long value); + inline bool is_odd(const long value) { return is_odd((unsigned long)value); } + + bool is_odd(const unsigned long long value); + inline bool is_odd(const long long value) { return is_odd((unsigned long long)value); } + + //*************************************************************************** + /// Checks if even. + //*************************************************************************** + bool is_even(const unsigned char value); + inline bool is_even(const char value) { return is_even((unsigned char)value); } + + bool is_even(const unsigned short value); + inline bool is_even(const short value) { return is_even((unsigned short)value); } + + bool is_even(const unsigned int value); + inline bool is_even(const int value) { return is_even((unsigned int)value); } + + bool is_even(const unsigned long value); + inline bool is_even(const long value) { return is_even((unsigned long)value); } + + bool is_even(const unsigned long long value); + inline bool is_even(const long long value) { return is_even((unsigned long long)value); } + //*************************************************************************** /// 8 bit binary constants. //*************************************************************************** diff --git a/src/binary.cpp b/src/binary.cpp index 52035a5c..7f676070 100644 --- a/src/binary.cpp +++ b/src/binary.cpp @@ -467,4 +467,132 @@ namespace etl return count; } + +#if ETL_8BIT_SUPPORT + //***************************************************************************** + /// Binary interleave + //***************************************************************************** + uint16_t binary_interleave(uint8_t first, uint8_t second) + { + static const uint16_t mask[] = { 0x5555, 0x3333, 0x0F0F }; + + uint16_t f = first; + uint16_t s = second; + + f = (f | (f << 4)) & mask[2]; + f = (f | (f << 2)) & mask[1]; + f = (f | (f << 1)) & mask[0]; + + s = (s | (s << 4)) & mask[2]; + s = (s | (s << 2)) & mask[1]; + s = (s | (s << 1)) & mask[0]; + + return (f | (s << 1)); + } +#endif + + //***************************************************************************** + /// Binary interleave + //***************************************************************************** + uint32_t binary_interleave(uint16_t first, uint16_t second) + { + static const uint32_t mask[] = { 0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF }; + + uint32_t f = first; + uint32_t s = second; + + f = (f | (f << 8)) & mask[3]; + f = (f | (f << 4)) & mask[2]; + f = (f | (f << 2)) & mask[1]; + f = (f | (f << 1)) & mask[0]; + + s = (s | (s << 8)) & mask[3]; + s = (s | (s << 4)) & mask[2]; + s = (s | (s << 2)) & mask[1]; + s = (s | (s << 1)) & mask[0]; + + return (f | (s << 1)); + } + + //***************************************************************************** + /// Binary interleave + //***************************************************************************** + uint64_t binary_interleave(uint32_t first, uint32_t second) + { + static const uint64_t mask[] = { 0x5555555555555555, 0x3333333333333333, 0x0F0F0F0F0F0F0F0F, 0x00FF00FF00FF00FF, 0x0000FFFF0000FFFF }; + + uint64_t f = first; + uint64_t s = second; + + f = (f | (f << 16)) & mask[4]; + f = (f | (f << 8)) & mask[3]; + f = (f | (f << 4)) & mask[2]; + f = (f | (f << 2)) & mask[1]; + f = (f | (f << 1)) & mask[0]; + + s = (s | (s << 16)) & mask[4]; + s = (s | (s << 8)) & mask[3]; + s = (s | (s << 4)) & mask[2]; + s = (s | (s << 2)) & mask[1]; + s = (s | (s << 1)) & mask[0]; + + return (f | (s << 1)); + } + + //*************************************************************************** + /// Checks if odd. + //*************************************************************************** + bool is_odd(const unsigned char value) + { + return ((value & 1U) != 0U); + } + + bool is_odd(const unsigned short value) + { + return ((value & 1U) != 0U); + } + + bool is_odd(const unsigned int value) + { + return ((value & 1U) != 0U); + } + + bool is_odd(const unsigned long value) + { + return ((value & 1U) != 0U); + } + + bool is_odd(const unsigned long long value) + { + return ((value & 1U) != 0U); + } + + //*************************************************************************** + /// Checks if even. + //*************************************************************************** + bool is_even(const unsigned char value) + { + return ((value & 1U) == 0U); + } + + bool is_even(const unsigned short value) + { + return ((value & 1U) == 0U); + } + + bool is_even(const unsigned int value) + { + return ((value & 1U) == 0U); + } + + bool is_even(const unsigned long value) + { + return ((value & 1U) == 0U); + } + + bool is_even(const unsigned long long value) + { + return ((value & 1U) == 0U); + } } + diff --git a/test/test_binary.cpp b/test/test_binary.cpp index fc5ecbc4..35cd1c53 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -1480,6 +1480,44 @@ namespace CHECK(!(etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0x12))); CHECK((etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0xAB))); } + + //************************************************************************* + TEST(test_binary_merge) + { + CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34), uint8_t(0xF0))), uint8_t(0x14)); + CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34))), uint8_t(0x14)); + + CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456), uint16_t(0xF0F0))), uint16_t(0x1436)); + CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456))), uint16_t(0x1436)); + + CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A), uint32_t(0xF0F0F0F0))), uint32_t(0x1436587A)); + CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A))), uint32_t(0x1436587A)); + + CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012), uint64_t(0xF0F0F0F0F0F0F0F0))), uint64_t(0x1436587A9CBED0F2)); + CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012))), uint64_t(0x1436587A9CBED0F2)); + } + + //************************************************************************* + TEST(test_binary_interleave) + { + CHECK_EQUAL((etl::binary_interleave(uint8_t(0x5A), uint8_t(0xA5))), uint16_t(0x9966)); + CHECK_EQUAL((etl::binary_interleave(uint16_t(0x5A5A), uint16_t(0xA5A5))), uint32_t(0x99669966)); + CHECK_EQUAL((etl::binary_interleave(uint32_t(0x5A5A5A5A), uint32_t(0xA5A5A5A5))), uint64_t(0x9966996699669966)); + } + + //************************************************************************* + TEST(test_is_odd) + { + CHECK(etl::is_odd(1)); + CHECK(!etl::is_odd(2)); + } + + //************************************************************************* + TEST(test_is_even) + { + CHECK(!etl::is_even(1)); + CHECK(etl::is_even(2)); + } }; } From fe522ab0f259e0ef7ed48c5cec78eccbf8d1bced Mon Sep 17 00:00:00 2001 From: scls19fr Date: Wed, 30 May 2018 08:48:47 +0200 Subject: [PATCH 07/28] Update library.properties (#76) --- library.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/library.properties b/library.properties index c9913f89..78d54048 100644 --- a/library.properties +++ b/library.properties @@ -2,6 +2,7 @@ name=Embedded Template Library version=10.21.2 author= John Wellbelove maintainer=John Wellbelove +license=MIT sentence=A C++ template library tailored for embedded systems. paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/ or https://github.com/mike-matera/ArduinoSTL.git for Arduino. category=Other From 1d6a1109fc733e495c842451e3e5842507dac0cf Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 31 May 2018 22:26:04 +0100 Subject: [PATCH 08/28] Merge remote-tracking branch 'origin/development' --- .gitmodules | 3 - CMakeLists.txt | 14 +- test/CMakeLists.txt | 157 ++++++++++ test/ExtraCheckMacros.h | 16 +- test/cmake/unit-test_external_project.cmake | 38 +++ test/codeblocks/ETL.cbp | 149 ++++----- test/vs2017/etl.vcxproj | 112 +++---- test/vs2017/etl.vcxproj.filters | 318 ++++++++++---------- unittest-cpp | 1 - 9 files changed, 506 insertions(+), 302 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/cmake/unit-test_external_project.cmake delete mode 160000 unittest-cpp diff --git a/.gitmodules b/.gitmodules index a144f126..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "unittest-cpp"] - path = unittest-cpp - url = https://github.com/unittest-cpp/unittest-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 3456c7be..61c57638 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,14 @@ project(etl) set(ETL_PROFILE "DEFAULT" CACHE STRING "Defines what profile header to include. See https://www.etlcpp.com/setup.html" ) +option(BUILD_TESTS "Build unit tests" ON) + + +# Note: this will not compile src/c/ecl_timer.c as that c file has a dependence +# on ecl_user.h which is provided by clients of this library add_library(etl src/binary.cpp + src/crc16.cpp src/crc16_ccitt.cpp src/crc16_kermit.cpp src/crc32.cpp @@ -28,7 +34,7 @@ add_library(etl ) target_include_directories(etl PUBLIC - include/etl/ + include/etl include/etl/atomic include/etl/profiles PRIVATE @@ -63,3 +69,9 @@ target_compile_definitions(etl ${ETL_PROFILE} ) + + +if (BUILD_TESTS) + enable_testing() + add_subdirectory(test) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..9fb4fb86 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,157 @@ +cmake_minimum_required(VERSION 3.5.0) +project(etl_unit_tests) + +# Bring in the UnitTest++ include directories and libraries +find_package(UnitTest++) + +if(NOT UnitTest++_FOUND) + # Add unittest-cpp as an ExternalProject + include(cmake/unit-test_external_project.cmake) + add_unittest_cpp() +else() + include(${UnitTest++_CONFIG}) + # The CMake install of UnitTest++ puts the include directory to ${CMAKE_INSTALL_PREFIX}/include + # under the assumptions that clients will consume the headers via + # #include + # However the tests in etl include the headers directly, e.g. + # #include "UnitTest++.h" + # Therefore we update the provide UTPP_INCLUDE_DIRS here + set(UTPP_INCLUDE_DIRS "${UTPP_INCLUDE_DIRS}/UnitTest++") +endif() +include_directories(${UTPP_INCLUDE_DIRS}) + +set(TEST_SOURCE_FILES + main.cpp + murmurhash3.cpp + test_algorithm.cpp + test_alignment.cpp + test_array.cpp + test_array_view.cpp + test_array_wrapper.cpp + test_binary.cpp + test_bitset.cpp + test_bloom_filter.cpp + test_bsd_checksum.cpp + test_callback_timer.cpp + test_checksum.cpp + test_compare.cpp + test_constant.cpp + test_container.cpp + test_crc.cpp + test_c_timer_framework.cpp + test_cyclic_value.cpp + test_debounce.cpp + test_deque.cpp + test_endian.cpp + test_enum_type.cpp + test_error_handler.cpp + test_exception.cpp + test_factory.cpp + test_fixed_iterator.cpp + test_flat_map.cpp + test_flat_multimap.cpp + test_flat_multiset.cpp + test_flat_set.cpp + test_fnv_1.cpp + test_forward_list.cpp + test_fsm.cpp + test_functional.cpp + test_function.cpp + test_hash.cpp + test_instance_count.cpp + test_integral_limits.cpp + test_intrusive_forward_list.cpp + test_intrusive_links.cpp + test_intrusive_list.cpp + test_intrusive_queue.cpp + test_intrusive_stack.cpp + test_io_port.cpp + test_iterator.cpp + test_jenkins.cpp + test_largest.cpp + test_list.cpp + test_map.cpp + test_maths.cpp + test_memory.cpp + test_message_bus.cpp + test_message_router.cpp + test_message_timer.cpp + test_multimap.cpp + test_multiset.cpp + test_murmur3.cpp + test_numeric.cpp + test_observer.cpp + test_optional.cpp + test_packet.cpp + test_parameter_type.cpp + test_pearson.cpp + test_pool.cpp + test_priority_queue.cpp + test_queue.cpp + test_random.cpp + test_reference_flat_map.cpp + test_reference_flat_multimap.cpp + test_reference_flat_multiset.cpp + test_reference_flat_set.cpp + test_set.cpp + test_smallest.cpp + test_stack.cpp + test_string_char.cpp + test_string_u16.cpp + test_string_u32.cpp + test_string_wchar_t.cpp + test_task_scheduler.cpp + test_type_def.cpp + test_type_lookup.cpp + test_type_traits.cpp + test_unordered_map.cpp + test_unordered_multimap.cpp + test_unordered_multiset.cpp + test_unordered_set.cpp + test_user_type.cpp + test_utility.cpp + test_variant.cpp + test_variant_pool.cpp + test_vector.cpp + test_vector_non_trivial.cpp + test_vector_pointer.cpp + test_visitor.cpp + test_xor_checksum.cpp + test_xor_rotate_checksum.cpp + + # Compile the source level ecl_timer here as test has provided a ecl_user.h file + ${CMAKE_SOURCE_DIR}/src/c/ecl_timer.c + ) + +if (WIN32) + # test_error_handler.cpp uses windows APIs that assume the microsoft project + # is setup for unicode support. Note: This may have adverse effects on client + # projects and the tests should be updated to be independent of project setup + ADD_DEFINITIONS(-DUNICODE) + ADD_DEFINITIONS(-D_UNICODE) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + list(APPEND TEST_SOURCE_FILES "test_atomic_gcc.cpp") +endif() +add_executable(etl_tests + ${TEST_SOURCE_FILES} + ) +target_link_libraries(etl_tests etl UnitTest++) +target_include_directories(etl_tests + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ) + +# Enable the 'make test' CMake target using the executable defined above +add_test(etl_unit_tests etl_tests) + +# Since ctest will only show you the results of the single executable +# define a target that will output all of the failing or passing tests +# as they appear from UnitTest++ +add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose) + + +# Remaining Tests to be implemented: +#1. Enable embedded compile target testing +# - test_embedded_compile.cpp diff --git a/test/ExtraCheckMacros.h b/test/ExtraCheckMacros.h index b8051f6a..17fcd51a 100644 --- a/test/ExtraCheckMacros.h +++ b/test/ExtraCheckMacros.h @@ -1,14 +1,14 @@ #ifndef UNITTEST_EXTRA_CHECKMACROS_H #define UNITTEST_EXTRA_CHECKMACROS_H -#include "../unittest-cpp/UnitTest++/HelperMacros.h" -#include "../unittest-cpp/UnitTest++/ExceptionMacros.h" -#include "../unittest-cpp/UnitTest++/Checks.h" -#include "../unittest-cpp/UnitTest++/AssertException.h" -#include "../unittest-cpp/UnitTest++/MemoryOutStream.h" -#include "../unittest-cpp/UnitTest++/TestDetails.h" -#include "../unittest-cpp/UnitTest++/CurrentTest.h" -#include "../unittest-cpp/UnitTest++/ReportAssertImpl.h" +#include "HelperMacros.h" +#include "ExceptionMacros.h" +#include "Checks.h" +#include "AssertException.h" +#include "MemoryOutStream.h" +#include "TestDetails.h" +#include "CurrentTest.h" +#include "ReportAssertImpl.h" #ifndef CHECK_NO_THROW #define CHECK_NO_THROW(expression) \ diff --git a/test/cmake/unit-test_external_project.cmake b/test/cmake/unit-test_external_project.cmake new file mode 100644 index 00000000..119c64ee --- /dev/null +++ b/test/cmake/unit-test_external_project.cmake @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.5.0) +find_package(Git REQUIRED) +include(ExternalProject) + + +##### +# \breif Function used to add UnitTest++ as an External Project, install it into the +# binary location of the CMake build, add its header directories in the +# include_directories, and finally add the built static library as an imported +# CMake target +##### +function (add_unittest_cpp) + + set(UTPP_INSATLL_DIR "${CMAKE_CURRENT_BINARY_DIR}/unittest++/install") + if (WIN32) + set(UTPP_LIB_NAME "UnitTest++.lib") + else() + set(UTPP_LIB_NAME "libUnitTest++.a") + endif() + + + ExternalProject_Add(unittest-cpp + GIT_REPOSITORY https://github.com/unittest-cpp/unittest-cpp.git + GIT_TAG v2.0.0 + GIT_SHALLOW TRUE # Don't require downloading the entire history + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/unittest++/src" + INSTALL_DIR "${UTPP_INSATLL_DIR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + TEST_EXCLUDE_FROM_MAIN TRUE # Don't run UnitTest++'s tests by default + ) + + set(UTPP_INCLUDE_DIRS "${UTPP_INSATLL_DIR}/include/UnitTest++" PARENT_SCOPE) + add_library(UnitTest++ STATIC IMPORTED) + set_target_properties(UnitTest++ PROPERTIES IMPORTED_LOCATION "${UTPP_INSATLL_DIR}/lib/${UTPP_LIB_NAME}" ) + # Require the ExternalProject target to complete before importing the library + add_dependencies(UnitTest++ unittest-cpp) + +endfunction(add_unittest_cpp) diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index b4758871..20b6dfb2 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -61,19 +61,90 @@ - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -248,76 +319,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index eee0ad5c..4c47ec11 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -161,7 +161,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test false @@ -203,7 +203,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp\UnitTest++;../../include/etl;../../include/etl/c;../../test false @@ -245,7 +245,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test @@ -323,6 +323,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -379,35 +411,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -428,7 +431,6 @@ - @@ -488,8 +490,6 @@ - - @@ -505,12 +505,31 @@ - - + + + + + + + + + + + + + + + + + + + + + @@ -524,24 +543,6 @@ - - - - - - - - - - - - - - - - - - @@ -725,7 +726,6 @@ - diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index 7ba6c7d5..d8a39e36 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -75,9 +75,6 @@ - - Header Files - ETL\Utilities @@ -156,9 +153,6 @@ ETL\Containers - - Header Files - ETL\Containers @@ -216,9 +210,6 @@ ETL\Maths - - Header Files - ETL\Containers @@ -297,12 +288,6 @@ ETL\Containers - - Header Files - - - Header Files - ETL\Utilities @@ -366,93 +351,6 @@ ETL\Containers - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - ETL\Frameworks @@ -633,6 +531,102 @@ ETL\Maths + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + @@ -908,60 +902,6 @@ Source Files - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - - - UnitTest++ - Source Files @@ -1037,11 +977,71 @@ ETL\Maths + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++\Win32 + - - Header Files - Resource Files diff --git a/unittest-cpp b/unittest-cpp deleted file mode 160000 index bc5d87f4..00000000 --- a/unittest-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bc5d87f484cac2959b0a0eafbde228e69e828d74 From 9278e917a9618c1a55cee382645de70e6e1fb901 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 31 May 2018 22:26:36 +0100 Subject: [PATCH 09/28] Updated version --- include/etl/version.h | 4 ++-- support/Release notes.txt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index fa2e0a6d..9e698aab 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,8 +39,8 @@ SOFTWARE. #define ETL_VERSION "11.9.2" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 9 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MINOR 10 +#define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 09ce8ee4..871bb6e7 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.10.0 +Merged CMake branch + =============================================================================== 11.9.2 Fixed compile error when ETL_DEBUG_COUNT is not defined. From f293b6beee3e74e01e8cf66e0d930ed0917dc0ce Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 4 Jun 2018 07:58:04 +0100 Subject: [PATCH 10/28] Added MIT licence --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a4efc26..e8ebeb82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Embedded Template Library (ETL) ------------------------- -AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) +AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)[License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) **Motivation** From ffd74998d4350c697bcae64531656722328889bf Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 4 Jun 2018 07:58:40 +0100 Subject: [PATCH 11/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8ebeb82..cfbd3f07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Embedded Template Library (ETL) ------------------------- -AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)[License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) **Motivation** From 004a4fbf1afb57be4fc5dcc3b13fa7547b4b2831 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 4 Jun 2018 21:48:26 +0100 Subject: [PATCH 12/28] Added master link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfbd3f07..9e6caea9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Embedded Template Library (ETL) ------------------------- -AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) **Motivation** From 05692d68918f0b2db48a194c064b26bc9c7b6197 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 4 Jun 2018 21:49:14 +0100 Subject: [PATCH 13/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e6caea9..cfbd3f07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Embedded Template Library (ETL) ------------------------- -AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) +AppVeyor [![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) **Motivation** From 873f7e70d0a097555ad702c7709b4779a38d7092 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 17 Jun 2018 10:17:51 +0100 Subject: [PATCH 14/28] Merge remote-tracking branch 'origin/development' --- include/etl/largest.h | 2 +- include/etl/message_router.h | 2 +- include/etl/pool.h | 6 +++--- include/etl/smallest.h | 2 +- include/etl/type_traits_generator.h | 4 ++-- include/etl/variant.h | 2 +- include/etl/variant_pool.h | 2 +- include/etl/variant_pool_generator.h | 2 +- include/etl/version.h | 4 ++-- support/Release notes.txt | 4 ++++ 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/etl/largest.h b/include/etl/largest.h index 0bb51c11..a352a582 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -33,7 +33,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. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 62f591df..ff1ba20b 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.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. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/pool.h b/include/etl/pool.h index 8ce26fe1..e110fa43 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -134,7 +134,7 @@ namespace etl return reinterpret_cast(allocate_item()); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#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 @@ -499,7 +499,7 @@ namespace etl return ipool::allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#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 @@ -650,7 +650,7 @@ namespace etl return base_t::template allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE +#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 diff --git a/include/etl/smallest.h b/include/etl/smallest.h index 33eaaf6a..8b1337e1 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -33,7 +33,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. //*************************************************************************** //*************************************************************************** diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index c993d746..5151b34e 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -281,14 +281,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO)) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {}; diff --git a/include/etl/variant.h b/include/etl/variant.h index 182e19c8..db22a746 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -711,7 +711,7 @@ namespace etl type_id = other.type_id; } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //*************************************************************************** /// Emplace with one constructor parameter. //*************************************************************************** diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index c08dac50..bc66274a 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -133,7 +133,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 5c117bdf..5c859697 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -140,7 +140,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* diff --git a/include/etl/version.h b/include/etl/version.h index 015898b2..1f59cc16 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.11.0" +#define ETL_VERSION "11.11.1" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 3501b177..c182077b 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.11.1 +Compatibilty changes for Segger IDE, GCC & STLPort + =============================================================================== 11.11.0 Compatibilty changes for Segger IDE, GCC & STLPort From 60fb58049d2a34eef68c2c1f93710182221ef1aa Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 18 Jun 2018 18:49:50 +0100 Subject: [PATCH 15/28] Merge remote-tracking branch 'origin/development' --- include/etl/alignment.h | 16 +++---- include/etl/array.h | 4 +- include/etl/atomic/atomic_gcc_sync.h | 2 +- include/etl/binary.h | 50 ++++++++++---------- include/etl/callback_timer.h | 2 +- include/etl/frame_check_sequence.h | 8 ++-- include/etl/hash.h | 18 ++++---- include/etl/largest.h | 8 ++-- include/etl/largest_generator.h | 8 ++-- include/etl/message_router.h | 32 ++++++------- include/etl/message_router_generator.h | 4 +- include/etl/message_timer.h | 2 +- include/etl/murmur3.h | 6 +-- include/etl/nullptr.h | 8 ---- include/etl/packet.h | 12 ++--- include/etl/pearson.h | 6 +-- include/etl/pool.h | 64 +++++++++++++------------- include/etl/reference_flat_map.h | 2 +- include/etl/static_assert.h | 14 +++--- include/etl/type_lookup.h | 6 +-- include/etl/type_lookup_generator.h | 6 +-- include/etl/type_select.h | 32 ++++++------- include/etl/type_select_generator.h | 4 +- include/etl/type_traits.h | 4 +- include/etl/type_traits_generator.h | 4 +- include/etl/variant.h | 20 ++++---- include/etl/variant_pool.h | 14 +++--- include/etl/variant_pool_generator.h | 14 +++--- include/etl/vector.h | 2 +- include/etl/version.h | 6 +-- src/crc8_ccitt.cpp | 2 +- src/pearson.cpp | 2 +- support/Release notes.txt | 5 ++ 33 files changed, 192 insertions(+), 195 deletions(-) diff --git a/include/etl/alignment.h b/include/etl/alignment.h index 1867874b..e7f1bb9d 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -116,7 +116,7 @@ namespace etl template operator T& () { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); T* t = *this; return *t; } @@ -125,7 +125,7 @@ namespace etl template operator const T& () const { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); const T* t = *this; return *t; } @@ -134,7 +134,7 @@ namespace etl template operator T* () { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); return reinterpret_cast(data); } @@ -142,7 +142,7 @@ namespace etl template operator const T* () const { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); return reinterpret_cast(data); } @@ -150,7 +150,7 @@ namespace etl template T& get_reference() { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); T* t = *this; return *t; } @@ -159,7 +159,7 @@ namespace etl template const T& get_reference() const { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); const T* t = *this; return *t; } @@ -168,7 +168,7 @@ namespace etl template T* get_address() { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); return reinterpret_cast(data); } @@ -176,7 +176,7 @@ namespace etl template const T* get_address() const { - STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); + ETL_STATIC_ASSERT((etl::is_same:: value || ((ALIGNMENT % etl::alignment_of::value) == 0)), "Incompatible alignment"); return reinterpret_cast(data); } diff --git a/include/etl/array.h b/include/etl/array.h index 06c096a7..05393422 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -649,7 +649,7 @@ namespace etl template inline T& get(array& a) { - STATIC_ASSERT(I < MAXN, "Index out of bounds"); + ETL_STATIC_ASSERT(I < MAXN, "Index out of bounds"); return a[I]; } @@ -664,7 +664,7 @@ namespace etl template inline const T& get(const array& a) { - STATIC_ASSERT(I < MAXN, "Index out of bounds"); + ETL_STATIC_ASSERT(I < MAXN, "Index out of bounds"); return a[I]; } } diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index d77046c2..c866d85e 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -62,7 +62,7 @@ namespace etl { public: - STATIC_ASSERT(etl::is_integral::value, "Only integral types are supported"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Only integral types are supported"); atomic() : value(0) diff --git a/include/etl/binary.h b/include/etl/binary.h index c9fa2653..cf2a80ef 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -108,7 +108,7 @@ namespace etl template T rotate_left(T value) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); const size_t SHIFT = etl::integral_limits::type>::bits - 1; @@ -121,7 +121,7 @@ namespace etl template T rotate_left(T value, size_t distance) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); const size_t BITS = etl::integral_limits::type>::bits; distance %= BITS; @@ -136,7 +136,7 @@ namespace etl template T rotate_right(T value) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); const size_t SHIFT = etl::integral_limits::type>::bits - 1; @@ -149,7 +149,7 @@ namespace etl template T rotate_right(T value, size_t distance) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); const size_t BITS = etl::integral_limits::type>::bits; distance %= BITS; @@ -165,7 +165,7 @@ namespace etl template T rotate(T value, typename etl::make_signed::type distance) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); T result; @@ -215,7 +215,7 @@ namespace etl template T binary_to_gray(T value) { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); return (value >> 1) ^ value; } @@ -268,7 +268,7 @@ namespace etl template TReturn fold_bits(TValue value) { - STATIC_ASSERT(integral_limits::bits >= NBITS, "Return type too small to hold result"); + ETL_STATIC_ASSERT(integral_limits::bits >= NBITS, "Return type too small to hold result"); const TValue mask = etl::power<2, NBITS>::value - 1; const size_t shift = NBITS; @@ -296,10 +296,10 @@ namespace etl template TReturn sign_extend(TValue value) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); - STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); + 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"); struct S { @@ -317,11 +317,11 @@ namespace etl template TReturn sign_extend(TValue value) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); - STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); - STATIC_ASSERT(SHIFT <= std::numeric_limits::digits, "SHIFT too large"); + 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"); struct S { @@ -338,9 +338,9 @@ namespace etl template TReturn sign_extend(TValue value, const size_t NBITS) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); - STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); + 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_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); @@ -358,9 +358,9 @@ namespace etl template TReturn sign_extend(TValue value, const size_t NBITS, const size_t SHIFT) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); - STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); + 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_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); @@ -443,8 +443,8 @@ namespace etl { private: - STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); - STATIC_ASSERT(VALUE <= etl::integral_limits::type>::max, "Value is too large for specified type"); + ETL_STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + ETL_STATIC_ASSERT(VALUE <= etl::integral_limits::type>::max, "Value is too large for specified type"); typedef typename etl::make_unsigned::type unsigned_r_t; typedef typename etl::make_unsigned::type unsigned_v_t; @@ -472,7 +472,7 @@ namespace etl template static TResult value(TValue value) { - STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + ETL_STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); typedef typename etl::make_unsigned::type unsigned_v_t; diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 2547e346..3a829833 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -669,7 +669,7 @@ namespace etl { public: - STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); //******************************************* /// Constructor. diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index 093a93c9..f54dc72c 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -34,7 +34,7 @@ SOFTWARE. #include "type_traits.h" #include "binary.h" -STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); +ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); ///\defgroup frame_check_sequence Frame check sequence calculation ///\ingroup maths @@ -54,7 +54,7 @@ namespace etl typedef TPolicy policy_type; typedef typename policy_type::value_type value_type; - STATIC_ASSERT(etl::is_unsigned::value, "Signed frame check type not supported"); + ETL_STATIC_ASSERT(etl::is_unsigned::value, "Signed frame check type not supported"); //************************************************************************* /// Default constructor. @@ -72,7 +72,7 @@ namespace etl template frame_check_sequence(TIterator begin, const TIterator end) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); reset(); add(begin, end); @@ -94,7 +94,7 @@ namespace etl template void add(TIterator begin, const TIterator end) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); while (begin != end) { diff --git a/include/etl/hash.h b/include/etl/hash.h index 61b19b81..42c2b2a0 100644 --- a/include/etl/hash.h +++ b/include/etl/hash.h @@ -97,7 +97,7 @@ namespace etl template <> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(bool), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(bool), "size_t smaller than type"); size_t operator ()(bool v) const { @@ -112,7 +112,7 @@ namespace etl template <> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(char), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(char), "size_t smaller than type"); size_t operator ()(char v) const { @@ -127,7 +127,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(signed char), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(signed char), "size_t smaller than type"); size_t operator ()(signed char v) const { @@ -142,7 +142,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned char), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned char), "size_t smaller than type"); size_t operator ()(unsigned char v) const { @@ -157,7 +157,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(wchar_t), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(wchar_t), "size_t smaller than type"); size_t operator ()(wchar_t v) const { @@ -172,7 +172,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(short), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(short), "size_t smaller than type"); size_t operator ()(short v) const { @@ -187,7 +187,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned short), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned short), "size_t smaller than type"); size_t operator ()(unsigned short v) const { @@ -202,7 +202,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(int), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(int), "size_t smaller than type"); size_t operator ()(int v) const { @@ -217,7 +217,7 @@ namespace etl template<> struct hash { - STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned int), "size_t smaller than type"); + ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned int), "size_t smaller than type"); size_t operator ()(unsigned int v) const { diff --git a/include/etl/largest.h b/include/etl/largest.h index a352a582..4ab26e80 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -160,7 +160,7 @@ namespace etl template struct larger_int_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_int_for_bits::type>::bits + 1>::type type; }; @@ -173,7 +173,7 @@ namespace etl template struct larger_uint_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_uint_for_bits::type>::bits + 1>::type type; }; @@ -190,7 +190,7 @@ namespace etl template struct larger_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_uint_for_bits::bits + 1>::type type; }; @@ -198,7 +198,7 @@ namespace etl template struct larger_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_int_for_bits::bits + 1>::type type; }; diff --git a/include/etl/largest_generator.h b/include/etl/largest_generator.h index 7ac3db53..13b6d58d 100644 --- a/include/etl/largest_generator.h +++ b/include/etl/largest_generator.h @@ -208,7 +208,7 @@ namespace etl template struct larger_int_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_int_for_bits::type>::bits + 1>::type type; }; @@ -221,7 +221,7 @@ namespace etl template struct larger_uint_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_uint_for_bits::type>::bits + 1>::type type; }; @@ -238,7 +238,7 @@ namespace etl template struct larger_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_uint_for_bits::bits + 1>::type type; }; @@ -246,7 +246,7 @@ namespace etl template struct larger_type { - STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Must be an integral type"); typedef typename etl::smallest_int_for_bits::bits + 1>::type type; }; diff --git a/include/etl/message_router.h b/include/etl/message_router.h index ff1ba20b..94d6e248 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -286,7 +286,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -472,7 +472,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -655,7 +655,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -835,7 +835,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1011,7 +1011,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1184,7 +1184,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1354,7 +1354,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1521,7 +1521,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1684,7 +1684,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -1844,7 +1844,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2000,7 +2000,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2153,7 +2153,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2302,7 +2302,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2448,7 +2448,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2591,7 +2591,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); @@ -2731,7 +2731,7 @@ namespace etl template explicit message_packet(const T& msg) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type for this message packet"); void* p = data; ::new (p) T(static_cast(msg)); diff --git a/include/etl/message_router_generator.h b/include/etl/message_router_generator.h index cc503cca..3edf621b 100644 --- a/include/etl/message_router_generator.h +++ b/include/etl/message_router_generator.h @@ -294,7 +294,7 @@ namespace etl cog.outl(" template ") cog.outl(" explicit message_packet(const T& msg)") cog.outl(" {") - cog.out(" STATIC_ASSERT((etl::is_one_of") cog.outl(" explicit message_packet(const T& msg)") cog.outl(" {") - cog.out(" STATIC_ASSERT((etl::is_one_of::value || etl::is_same::value), "Only 32 & 64 bit types supported"); + ETL_STATIC_ASSERT((etl::is_same::value || etl::is_same::value), "Only 32 & 64 bit types supported"); typedef THash value_type; @@ -81,7 +81,7 @@ namespace etl murmur3(TIterator begin, const TIterator end, value_type seed_ = 0) : seed(seed_) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Incompatible type"); + ETL_STATIC_ASSERT(sizeof(typename 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) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Incompatible type"); + ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Incompatible type"); ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)); while (begin != end) diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index 641b6338..1fd946c6 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -67,14 +67,6 @@ namespace std // Can't take address of nullptr. void operator&() const; }; - - //***************************************************************************** - /// A null pointer. - ///\ingroup nullptr - //***************************************************************************** - #if !defined(ETL_STLPORT) - const nullptr_t nullptr = { }; - #endif } //***************************************************************************** diff --git a/include/etl/packet.h b/include/etl/packet.h index bd9f28f7..5e12c0a5 100644 --- a/include/etl/packet.h +++ b/include/etl/packet.h @@ -62,9 +62,9 @@ namespace etl template explicit packet(const T& value) { - STATIC_ASSERT((etl::is_base_of::value), "Unsupported type"); - STATIC_ASSERT(sizeof(T) <= SIZE, "Unsupported size"); - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Unsupported alignment"); + ETL_STATIC_ASSERT((etl::is_base_of::value), "Unsupported type"); + ETL_STATIC_ASSERT(sizeof(T) <= SIZE, "Unsupported size"); + ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Unsupported alignment"); ::new (static_cast(data)) T(value); } @@ -84,9 +84,9 @@ namespace etl template packet& operator =(const T& value) { - STATIC_ASSERT((etl::is_base_of::value), "Unsupported type"); - STATIC_ASSERT(sizeof(T) <= SIZE, "Unsupported size"); - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Unsupported alignment"); + ETL_STATIC_ASSERT((etl::is_base_of::value), "Unsupported type"); + ETL_STATIC_ASSERT(sizeof(T) <= SIZE, "Unsupported size"); + ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Unsupported alignment"); static_cast(data)->~TBase(); ::new (static_cast(data)) T(value); diff --git a/include/etl/pearson.h b/include/etl/pearson.h index aef15302..a7ae1829 100644 --- a/include/etl/pearson.h +++ b/include/etl/pearson.h @@ -40,7 +40,7 @@ SOFTWARE. #include "array.h" #include "container.h" -STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); +ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 @@ -87,7 +87,7 @@ namespace etl pearson(TIterator begin, const TIterator end) : first(true) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); reset(); add(begin, end); @@ -109,7 +109,7 @@ namespace etl template void add(TIterator begin, const TIterator end) { - STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); + ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits::value_type) == 1, "Type not supported"); while (begin != end) { diff --git a/include/etl/pool.h b/include/etl/pool.h index e110fa43..57ad5940 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -494,8 +494,8 @@ namespace etl template U* allocate() { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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::allocate(); } @@ -508,8 +508,8 @@ namespace etl template U* create() { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(); } @@ -521,8 +521,8 @@ namespace etl template U* create(const T1& value1) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1); } @@ -534,8 +534,8 @@ namespace etl template U* create(const T1& value1, const T2& value2) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2); } @@ -547,8 +547,8 @@ namespace etl template U* create(const T1& value1, const T2& value2, const T3& value3) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2, value3); } @@ -560,8 +560,8 @@ namespace etl template U* create(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2, value3, value4); } #else @@ -571,8 +571,8 @@ namespace etl template U* create(Args&&... args) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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)...); } #endif @@ -585,8 +585,8 @@ namespace etl template void destroy(const void* const p_object) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT_, "Type has incompatible alignment"); + ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); reinterpret_cast((const_cast(p_object)))->~U(); ipool::release(p_object); } @@ -645,8 +645,8 @@ namespace etl template U* allocate() { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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 allocate(); } @@ -659,8 +659,8 @@ namespace etl template U* create() { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(); } @@ -672,8 +672,8 @@ namespace etl template U* create(const T1& value1) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1); } @@ -685,8 +685,8 @@ namespace etl template U* create(const T1& value1, const T2& value2) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2); } @@ -698,8 +698,8 @@ namespace etl template U* create(const T1& value1, const T2& value2, const T3& value3) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2, value3); } @@ -711,8 +711,8 @@ namespace etl template U* create(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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(value1, value2, value3, value4); } #else @@ -724,8 +724,8 @@ namespace etl template U* create(Args&&... args) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + 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)...); } #endif @@ -738,8 +738,8 @@ namespace etl template void destroy(const void* const p_object) { - STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); - STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); + ETL_STATIC_ASSERT(etl::alignment_of::value <= ALIGNMENT, "Type has incompatible alignment"); + ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); reinterpret_cast((const_cast(p_object)))->~U(); base_t::release(p_object); } diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index e76ccfd6..339a8fb3 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -522,7 +522,7 @@ namespace etl template void assign(TIterator first, TIterator last) { - 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); diff --git a/include/etl/static_assert.h b/include/etl/static_assert.h index af3d76a1..4d09cbb9 100644 --- a/include/etl/static_assert.h +++ b/include/etl/static_assert.h @@ -26,26 +26,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_STATIC_ASSERT_INCLUDED -#define ETL_STATIC_ASSERT_INCLUDED +#ifndef ETL_ETL_STATIC_ASSERT_INCLUDED +#define ETL_ETL_STATIC_ASSERT_INCLUDED #include "platform.h" #if (ETL_CPP11_SUPPORTED) - #define STATIC_ASSERT(Condition, Message) static_assert(Condition, Message) + #define ETL_STATIC_ASSERT(Condition, Message) static_assert(Condition, Message) #else template - struct STATIC_ASSERT_FAILED; + struct ETL_ETL_STATIC_ASSERT_FAILED; template <> - struct STATIC_ASSERT_FAILED {}; + struct ETL_ETL_STATIC_ASSERT_FAILED {}; #define ETL_SA1(a,b) a##b #define ETL_SA2(a,b) ETL_SA1(a,b) - #define STATIC_ASSERT(Condition, Message) \ + #define ETL_STATIC_ASSERT(Condition, Message) \ enum \ { \ - ETL_SA2(dummy, __LINE__) = sizeof(STATIC_ASSERT_FAILED<(bool)(Condition)>) \ + ETL_SA2(dummy, __LINE__) = sizeof(ETL_ETL_STATIC_ASSERT_FAILED<(bool)(Condition)>) \ } #endif diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index 30e4932e..4470f3f4 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -122,7 +122,7 @@ namespace etl ::type>::type>::type>::type> ::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid id"); + ETL_STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid id"); }; //************************************ @@ -156,7 +156,7 @@ namespace etl (unsigned int) UNKNOWN }; - STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); + ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; //************************************ @@ -221,7 +221,7 @@ namespace etl etl::null_type<0>>::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid type"); + ETL_STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid type"); }; }; } diff --git a/include/etl/type_lookup_generator.h b/include/etl/type_lookup_generator.h index 398773bd..b003a746 100644 --- a/include/etl/type_lookup_generator.h +++ b/include/etl/type_lookup_generator.h @@ -116,7 +116,7 @@ namespace etl cog.outl("") cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid id\");") + cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid id\");") cog.outl(" };") cog.outl("") cog.outl(" //************************************") @@ -136,7 +136,7 @@ namespace etl cog.outl(" (unsigned int) UNKNOWN") cog.outl(" };") cog.outl("") - cog.outl(" STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");") + cog.outl(" ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");") cog.outl(" };") cog.outl("") cog.outl(" //************************************") @@ -183,7 +183,7 @@ namespace etl cog.outl("") cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid type\");") + cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid type\");") cog.outl(" };") cog.outl("};") ]]]*/ diff --git a/include/etl/type_select.h b/include/etl/type_select.h index 52c8f5f5..894b642d 100644 --- a/include/etl/type_select.h +++ b/include/etl/type_select.h @@ -93,7 +93,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 16, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 16, "Invalid ID"); }; }; @@ -140,7 +140,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 15, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 15, "Invalid ID"); }; }; @@ -185,7 +185,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 14, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 14, "Invalid ID"); }; }; @@ -228,7 +228,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 13, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 13, "Invalid ID"); }; }; @@ -269,7 +269,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type>::type type; - STATIC_ASSERT(ID < 12, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 12, "Invalid ID"); }; }; @@ -308,7 +308,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type>::type type; - STATIC_ASSERT(ID < 11, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 11, "Invalid ID"); }; }; @@ -345,7 +345,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type>::type type; - STATIC_ASSERT(ID < 10, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 10, "Invalid ID"); }; }; @@ -380,7 +380,7 @@ namespace etl ::type>::type>::type>::type>::type>::type>::type>::type> ::type type; - STATIC_ASSERT(ID < 9, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 9, "Invalid ID"); }; }; @@ -412,7 +412,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 8, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 8, "Invalid ID"); }; }; @@ -442,7 +442,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 7, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 7, "Invalid ID"); }; }; @@ -470,7 +470,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 6, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 6, "Invalid ID"); }; }; @@ -496,7 +496,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type>::type>::type type; - STATIC_ASSERT(ID < 5, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 5, "Invalid ID"); }; }; @@ -520,7 +520,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type>::type type; - STATIC_ASSERT(ID < 4, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 4, "Invalid ID"); }; }; @@ -542,7 +542,7 @@ namespace etl etl::null_type<0> > ::type>::type>::type type; - STATIC_ASSERT(ID < 3, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 3, "Invalid ID"); }; }; @@ -562,7 +562,7 @@ namespace etl etl::null_type<0> > ::type>::type type; - STATIC_ASSERT(ID < 2, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 2, "Invalid ID"); }; }; @@ -580,7 +580,7 @@ namespace etl etl::null_type<0> > ::type type; - STATIC_ASSERT(ID < 1, "Invalid ID"); + ETL_STATIC_ASSERT(ID < 1, "Invalid ID"); }; }; } diff --git a/include/etl/type_select_generator.h b/include/etl/type_select_generator.h index e804360b..70880f9c 100644 --- a/include/etl/type_select_generator.h +++ b/include/etl/type_select_generator.h @@ -87,7 +87,7 @@ namespace etl cog.out(" ") cog.outl("::type type;") cog.outl(""); - cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % int(NTypes)); + cog.outl(" ETL_STATIC_ASSERT(ID < %s, \"Invalid ID\");" % int(NTypes)); cog.outl(" };") cog.outl("};") @@ -122,7 +122,7 @@ namespace etl cog.out(" ") cog.outl("::type type;") cog.outl(""); - cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % s); + cog.outl(" ETL_STATIC_ASSERT(ID < %s, \"Invalid ID\");" % s); cog.outl(" };") cog.outl("};") ]]]*/ diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 36036944..f0b23bfa 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -327,14 +327,14 @@ namespace etl template struct conditional_integral_constant { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); static const T value = TRUE_VALUE; }; template struct conditional_integral_constant { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); static const T value = FALSE_VALUE; }; diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index 5151b34e..61df9313 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -339,14 +339,14 @@ namespace etl template struct conditional_integral_constant { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); static const T value = TRUE_VALUE; }; template struct conditional_integral_constant { - STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); + ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); static const T value = FALSE_VALUE; }; diff --git a/include/etl/variant.h b/include/etl/variant.h index db22a746..a539fe3f 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -678,12 +678,12 @@ namespace etl //*************************************************************************** /// Constructor that catches any types that are not supported. - /// Forces a STATIC_ASSERT. + /// Forces a ETL_STATIC_ASSERT. //*************************************************************************** template variant(const T& value) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); ::new (static_cast(data)) T(value); type_id = Type_Id_Lookup::type_id; @@ -718,7 +718,7 @@ namespace etl template T& emplace(const TP1& value1) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(value1); @@ -733,7 +733,7 @@ namespace etl template T& emplace(const TP1& value1, const TP2& value2) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(value1, value2); @@ -748,7 +748,7 @@ namespace etl template T& emplace(const TP1& value1, const TP2& value2, const TP3& value3) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(value1, value2, value3); @@ -763,7 +763,7 @@ namespace etl template T& emplace(const TP1& value1, const TP2& value2, const TP3& value3, const TP4& value4) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(value1, value2, value3, value4); @@ -779,7 +779,7 @@ namespace etl template T& emplace(Args&&... args) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(std::forward(args)...); @@ -796,7 +796,7 @@ namespace etl template variant& operator =(const T& value) { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); destruct_current(); ::new (static_cast(data)) T(value); @@ -933,7 +933,7 @@ namespace etl template T& get() { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); return static_cast(data); @@ -947,7 +947,7 @@ namespace etl template const T& get() const { - STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); return static_cast(data); diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index bc66274a..1c033ce5 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -140,7 +140,7 @@ namespace etl template T* create() { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -167,7 +167,7 @@ namespace etl template T* create(const TP1& p1) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -194,7 +194,7 @@ namespace etl template T* create(const TP1& p1, const TP2& p2) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -221,7 +221,7 @@ namespace etl template T* create(const TP1& p1, const TP2& p2, const TP3& p3) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -248,7 +248,7 @@ namespace etl template T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -275,7 +275,7 @@ namespace etl template T* create(Args&&... args) { - STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); + ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); T* p = nullptr; @@ -303,7 +303,7 @@ namespace etl template bool destroy(const T* const p) { - STATIC_ASSERT((etl::is_one_of::value || + ETL_STATIC_ASSERT((etl::is_one_of::value || etl::is_base_of::value || etl::is_base_of::value || etl::is_base_of::value || diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 5c859697..cb357424 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -149,7 +149,7 @@ namespace etl { /*[[[cog import cog - cog.out("STATIC_ASSERT((etl::is_one_of void assign(TIterator first, TIterator last) { - 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); diff --git a/include/etl/version.h b/include/etl/version.h index 5b4b22be..fb81796b 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.11.2" +#define ETL_VERSION "11.12.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MINOR 12 +#define ETL_VERSION_PATCH 0 #endif diff --git a/src/crc8_ccitt.cpp b/src/crc8_ccitt.cpp index 3ab90ceb..15b80cc9 100644 --- a/src/crc8_ccitt.cpp +++ b/src/crc8_ccitt.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "platform.h" #include "static_assert.h" -STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); +ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); namespace etl { diff --git a/src/pearson.cpp b/src/pearson.cpp index 94c5ec0f..0852c7e5 100644 --- a/src/pearson.cpp +++ b/src/pearson.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "platform.h" #include "static_assert.h" -STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); +ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); namespace etl { diff --git a/support/Release notes.txt b/support/Release notes.txt index c182077b..fc86ae10 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +11.12.0 +Renamed STATIC_ASSERT to ETL_STATIC_ASSERT +Removed non-conforming std::nullptr + =============================================================================== 11.11.1 Compatibilty changes for Segger IDE, GCC & STLPort From a7025917fbb084b29273171ec5e0785c1c49a286 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 24 Jun 2018 23:39:08 -0700 Subject: [PATCH 16/28] Fix license formatting so it will be recognized (#78) GitHub uses the licensee ruby gem to detect the license type of the repository. licensee uses the license texts from choosealicense.com so if the text of your license file differs from their license it will not be recognized. GitHub allows filtering searches by license type and also shows the license type on the homepage of your repository and when viewing the license page but these features are only available when the license is recognized. --- LICENSE | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 8f66b070..0e19085c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 jwellbelove -https://github.com/ETLCPP/etl -http://www.etlcpp.com +Copyright (c) 2016 jwellbelove, https://github.com/ETLCPP/etl, http://www.etlcpp.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From eb676c11ca47d2dc6b2df4a8cdf957d58e7a2648 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 27 Jun 2018 20:46:37 +0100 Subject: [PATCH 17/28] Merge remote-tracking branch 'origin/development' --- include/etl/array_view.h | 37 +-- include/etl/map.h | 2 +- include/etl/multimap.h | 2 +- include/etl/multiset.h | 2 +- include/etl/priority_queue.h | 2 +- include/etl/private/pvoidvector.h | 471 +++--------------------------- include/etl/set.h | 2 +- include/etl/version.h | 4 +- src/private/pvoidvector.cpp | 456 +++++++++++++++++++++++++++++ support/Release notes.txt | 6 + 10 files changed, 524 insertions(+), 460 deletions(-) diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 7a9722c7..b56e21e5 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -123,8 +123,7 @@ namespace etl /// Construct from std::array or etl::array or other type that supports /// data() and size() member functions. //************************************************************************* - template ::value, void>::type> + template explicit array_view(TArray& a) : mbegin(a.data()), mend(a.data() + a.size()) @@ -134,8 +133,7 @@ namespace etl //************************************************************************* /// Construct from iterators //************************************************************************* - template ::value, void>::type> + template array_view(TIterator begin_, TIterator end_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + std::distance(begin_, end_)) @@ -146,8 +144,7 @@ namespace etl /// Construct from C array //************************************************************************* template ::value, void>::type> + typename TSize> array_view(TIterator begin_, TSize size_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + size_) @@ -354,24 +351,22 @@ namespace etl //************************************************************************* /// Assign from iterators //************************************************************************* - template ::value, void>::type> + template void assign(TIterator begin_, TIterator end_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + std::distance(begin_, end_); + mend = etl::addressof(*begin_) + std::distance(begin_, end_); } //************************************************************************* /// Assign from iterator and size. //************************************************************************* template ::value, void>::type> + typename TSize> void assign(TIterator begin_, TSize size_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + size_; + mend = etl::addressof(*begin_) + size_; } //************************************************************************* @@ -518,8 +513,7 @@ namespace etl /// Construct from std::array or etl::array or other type that supports /// data() and size() member functions. //************************************************************************* - template ::value, void>::type> + template explicit const_array_view(TArray& a) : mbegin(a.data()), mend(a.data() + a.size()) @@ -529,8 +523,7 @@ namespace etl //************************************************************************* /// Construct from iterators //************************************************************************* - template ::value, void>::type> + template const_array_view(TIterator begin_, TIterator end_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + std::distance(begin_, end_)) @@ -541,7 +534,7 @@ namespace etl /// Construct from C array //************************************************************************* template ::value, void>::type> + typename TSize> const_array_view(TIterator begin_, TSize size_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + size_) @@ -705,8 +698,7 @@ namespace etl //************************************************************************* /// Assign from iterators //************************************************************************* - template ::value, void>::type> + template void assign(TIterator begin_, TIterator end_) { mbegin = etl::addressof(*begin_); @@ -717,8 +709,7 @@ namespace etl /// Assign from iterator and size. //************************************************************************* template ::value, void>::type> + typename TSize> void assign(TIterator begin_, TSize size_) { mbegin = etl::addressof(*begin_); @@ -833,7 +824,7 @@ namespace etl size_t operator()(const etl::array_view& view) const { return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), - reinterpret_cast(&view[view.size()])); + reinterpret_cast(&view[view.size()])); } }; @@ -843,7 +834,7 @@ namespace etl size_t operator()(const etl::const_array_view& view) const { return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), - reinterpret_cast(&view[view.size()])); + reinterpret_cast(&view[view.size()])); } }; #endif diff --git a/include/etl/map.h b/include/etl/map.h index b04ffc87..de8d73a3 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -458,7 +458,7 @@ namespace etl /// A templated base for all etl::map types. ///\ingroup map //*************************************************************************** - template + template > class imap : public etl::map_base { public: diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 6be6b681..2653eb88 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -614,7 +614,7 @@ namespace etl /// A templated base for all etl::multimap types. ///\ingroup map //*************************************************************************** - template + template > class imultimap : public etl::multimap_base { public: diff --git a/include/etl/multiset.h b/include/etl/multiset.h index e0be09db..2cecb26b 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -614,7 +614,7 @@ namespace etl /// A templated base for all etl::multiset types. ///\ingroup set //*************************************************************************** - template + template > class imultiset : public etl::multiset_base { public: diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 42df8261..54bcd779 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -113,7 +113,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: diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 4cef3c8e..5997b2e6 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -74,246 +74,41 @@ namespace etl public: - //********************************************************************* - /// Returns an iterator to the beginning of the vector. - ///\return An iterator to the beginning of the vector. - //********************************************************************* - iterator begin() - { - return p_buffer; - } + iterator begin(); + const_iterator begin() const; - //********************************************************************* - /// Returns a const_iterator to the beginning of the vector. - ///\return A const iterator to the beginning of the vector. - //********************************************************************* - const_iterator begin() const - { - return const_iterator(p_buffer); - } + iterator end(); + const_iterator end() const; - //********************************************************************* - /// Returns an iterator to the end of the vector. - ///\return An iterator to the end of the vector. - //********************************************************************* - iterator end() - { - return p_end; - } + const_iterator cbegin() const; + const_iterator cend() const; - //********************************************************************* - /// Returns a const_iterator to the end of the vector. - ///\return A const iterator to the end of the vector. - //********************************************************************* - const_iterator end() const - { - return const_iterator(p_end); - } + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; - //********************************************************************* - /// Returns a const_iterator to the beginning of the vector. - ///\return A const iterator to the beginning of the vector. - //********************************************************************* - const_iterator cbegin() const - { - return const_iterator(p_buffer); - } + reverse_iterator rend(); + const_reverse_iterator rend() const; - //********************************************************************* - /// Returns a const_iterator to the end of the vector. - ///\return A const iterator to the end of the vector. - //********************************************************************* - const_iterator cend() const - { - return const_iterator(p_end); - } + const_reverse_iterator crbegin() const; + const_reverse_iterator crend() const; - //********************************************************************* - /// Returns an reverse iterator to the reverse beginning of the vector. - ///\return Iterator to the reverse beginning of the vector. - //********************************************************************* - reverse_iterator rbegin() - { - return reverse_iterator(end()); - } + void resize(size_t new_size); + void resize(size_t new_size, value_type value); - //********************************************************************* - /// Returns a const reverse iterator to the reverse beginning of the vector. - ///\return Const iterator to the reverse beginning of the vector. - //********************************************************************* - const_reverse_iterator rbegin() const - { - return const_reverse_iterator(end()); - } + reference operator [](size_t i); + const_reference operator [](size_t i) const; - //********************************************************************* - /// Returns a reverse iterator to the end + 1 of the vector. - ///\return Reverse iterator to the end + 1 of the vector. - //********************************************************************* - reverse_iterator rend() - { - return reverse_iterator(begin()); - } + reference at(size_t i); + const_reference at(size_t i) const; - //********************************************************************* - /// Returns a const reverse iterator to the end + 1 of the vector. - ///\return Const reverse iterator to the end + 1 of the vector. - //********************************************************************* - const_reverse_iterator rend() const - { - return const_reverse_iterator(begin()); - } + reference front(); + const_reference front() const; - //********************************************************************* - /// Returns a const reverse iterator to the reverse beginning of the vector. - ///\return Const reverse iterator to the reverse beginning of the vector. - //********************************************************************* - const_reverse_iterator crbegin() const - { - return const_reverse_iterator(cend()); - } + reference back(); + const_reference back() const; - //********************************************************************* - /// Returns a const reverse iterator to the end + 1 of the vector. - ///\return Const reverse iterator to the end + 1 of the vector. - //********************************************************************* - const_reverse_iterator crend() const - { - return const_reverse_iterator(cbegin()); - } - - //********************************************************************* - /// Resizes the vector. - /// If asserts or exceptions are enabled and the new size is larger than the - /// maximum then a vector_full is thrown. - ///\param new_size The new size. - //********************************************************************* - void resize(size_t new_size) - { - ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full)); - - p_end = p_buffer + new_size; - } - - //********************************************************************* - /// Resizes the vector. - /// If asserts or exceptions are enabled and the new size is larger than the - /// maximum then a vector_full is thrown. - ///\param new_size The new size. - ///\param value The value to fill new elements with. Default = default constructed value. - //********************************************************************* - void resize(size_t new_size, value_type value) - { - ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full)); - - pointer p_new_end = p_buffer + new_size; - - // Size up if necessary. - if (p_end < p_new_end) - { - std::fill(p_end, p_new_end, value); - } - - p_end = p_new_end; - } - - //********************************************************************* - /// Returns a reference to the value at index 'i' - ///\param i The index. - ///\return A reference to the value at index 'i' - //********************************************************************* - reference operator [](size_t i) - { - return p_buffer[i]; - } - - //********************************************************************* - /// Returns a const reference to the value at index 'i' - ///\param i The index. - ///\return A const reference to the value at index 'i' - //********************************************************************* - const_reference operator [](size_t i) const - { - return const_reference(p_buffer[i]); - } - - //********************************************************************* - /// Returns a reference to the value at index 'i' - /// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. - ///\param i The index. - ///\return A reference to the value at index 'i' - //********************************************************************* - reference at(size_t i) - { - ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds)); - return p_buffer[i]; - } - - //********************************************************************* - /// Returns a const reference to the value at index 'i' - /// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. - ///\param i The index. - ///\return A const reference to the value at index 'i' - //********************************************************************* - const_reference at(size_t i) const - { - ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds)); - return const_reference(p_buffer[i]); - } - - //********************************************************************* - /// Returns a reference to the first element. - ///\return A reference to the first element. - //********************************************************************* - reference front() - { - return p_buffer[0]; - } - - //********************************************************************* - /// Returns a const reference to the first element. - ///\return A const reference to the first element. - //********************************************************************* - const_reference front() const - { - return const_reference(p_buffer[0]); - } - - //********************************************************************* - /// Returns a reference to the last element. - ///\return A reference to the last element. - //********************************************************************* - reference back() - { - return *(p_end -1); - } - - //********************************************************************* - /// Returns a const reference to the last element. - ///\return A const reference to the last element. - //********************************************************************* - const_reference back() const - { - return const_reference(*(p_end - 1)); - } - - //********************************************************************* - /// Returns a pointer to the beginning of the vector data. - ///\return A pointer to the beginning of the vector data. - //********************************************************************* - pointer data() - { - return p_buffer; - } - - //********************************************************************* - /// Returns a const pointer to the beginning of the vector data. - ///\return A const pointer to the beginning of the vector data. - //********************************************************************* - const_pointer data() const - { - return const_pointer(p_buffer); - } + pointer data(); + const_pointer data() const; //********************************************************************* /// Assigns values to the vector. @@ -338,110 +133,17 @@ namespace etl } } - //********************************************************************* - /// Assigns values to the vector. - /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. - ///\param n The number of elements to add. - ///\param value The value to insert for each element. - //********************************************************************* - void assign(size_t n, value_type value) - { - initialise(); + void assign(size_t n, value_type value); - ETL_ASSERT(n <= CAPACITY, ETL_ERROR(vector_full)); + void clear(); - for (size_t current_size = 0; current_size < n; ++current_size) - { - *p_end++ = value; - } - } + void push_back(); + void push_back(value_type value); - //************************************************************************* - /// Clears the vector. - //************************************************************************* - void clear() - { - initialise(); - } + void pop_back(); - //************************************************************************* - /// Increases the size of the vector by one, but does not initialise the new element. - /// If asserts or exceptions are enabled, throws a vector_full if the vector is already full. - //************************************************************************* - void push_back() - { -#if defined(ETL_CHECK_PUSH_POP) - ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); -#endif - - ++p_end; - } - - //********************************************************************* - /// Inserts a value at the end of the vector. - /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. - ///\param value The value to add. - //********************************************************************* - void push_back(value_type value) - { -#if defined(ETL_CHECK_PUSH_POP) - ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); -#endif - *p_end++ = value; - } - - //************************************************************************* - /// Removes an element from the end of the vector. - /// Does nothing if the vector is empty. - //************************************************************************* - void pop_back() - { -#if defined(ETL_CHECK_PUSH_POP) - ETL_ASSERT(size() > 0, ETL_ERROR(vector_empty)); -#endif - --p_end; - } - - //********************************************************************* - /// Inserts a value to the vector. - /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. - ///\param position The position to insert before. - ///\param value The value to insert. - //********************************************************************* - iterator insert(iterator position, value_type value) - { - ETL_ASSERT(size() + 1 <= CAPACITY, ETL_ERROR(vector_full)); - - if (position != end()) - { - ++p_end; - std::copy_backward(position, end() - 1, end()); - *position = value; - } - else - { - *p_end++ = value; - } - - return position; - } - - //********************************************************************* - /// Inserts 'n' values to the vector. - /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. - ///\param position The position to insert before. - ///\param n The number of elements to add. - ///\param value The value to insert. - //********************************************************************* - void insert(iterator position, size_t n, value_type value) - { - ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full)); - - std::copy_backward(position, p_end, p_end + n); - std::fill_n(position, n, value); - - p_end += n; - } + iterator insert(iterator position, value_type value); + void insert(iterator position, size_t n, value_type value); //********************************************************************* /// Inserts a range of values to the vector. @@ -463,117 +165,26 @@ namespace etl p_end += count; } - //********************************************************************* - /// Erases an element. - ///\param i_element Iterator to the element. - ///\return An iterator pointing to the element that followed the erased element. - //********************************************************************* - iterator erase(iterator i_element) - { - std::copy(i_element + 1, end(), i_element); - --p_end; + iterator erase(iterator i_element); + iterator erase(iterator first, iterator last); - return i_element; - } + pvoidvector& operator = (const pvoidvector& rhs); - //********************************************************************* - /// Erases a range of elements. - /// The range includes all the elements between first and last, including the - /// element pointed by first, but not the one pointed by last. - ///\param first Iterator to the first element. - ///\param last Iterator to the last element. - ///\return An iterator pointing to the element that followed the erased element. - //********************************************************************* - iterator erase(iterator first, iterator last) - { - std::copy(last, end(), first); - size_t n_delete = std::distance(first, last); + size_type size() const; - // Just adjust the count. - p_end -= n_delete; + bool empty() const; - return first; - } + bool full() const; - //************************************************************************* - /// Assignment operator. - //************************************************************************* - pvoidvector& operator = (const pvoidvector& rhs) - { - if (&rhs != this) - { - assign(rhs.cbegin(), rhs.cend()); - } - - return *this; - } - - //************************************************************************* - /// Gets the current size of the vector. - ///\return The current size of the vector. - //************************************************************************* - size_type size() const - { - return size_t(p_end - p_buffer); - } - - //************************************************************************* - /// Checks the 'empty' state of the vector. - ///\return true if empty. - //************************************************************************* - bool empty() const - { - return (p_end == p_buffer); - } - - //************************************************************************* - /// Checks the 'full' state of the vector. - ///\return true if full. - //************************************************************************* - bool full() const - { - return size() == CAPACITY; - } - - //************************************************************************* - /// Returns the remaining capacity. - ///\return The remaining capacity. - //************************************************************************* - size_t available() const - { - return max_size() - size(); - } + size_t available() const; protected: - //********************************************************************* - /// Constructor. - //********************************************************************* - pvoidvector(void** p_buffer_, size_t MAX_SIZE) - : vector_base(MAX_SIZE), - p_buffer(p_buffer_), - p_end(p_buffer_) - { - } + pvoidvector(void** p_buffer_, size_t MAX_SIZE); - //********************************************************************* - /// Initialise the vector. - //********************************************************************* - void initialise() - { - p_end = p_buffer; - } + void initialise(); - //************************************************************************* - /// Fix the internal pointers after a low level memory copy. - //************************************************************************* - void repair(void** p_buffer_) - { - uintptr_t length = p_end - p_buffer; - - p_buffer = p_buffer_; - p_end = p_buffer_ + length; - } + void repair(void** p_buffer_); void** p_buffer; void** p_end; diff --git a/include/etl/set.h b/include/etl/set.h index 59283c0c..a6df4f39 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -453,7 +453,7 @@ namespace etl /// A templated base for all etl::set types. ///\ingroup set //*************************************************************************** - template + template > class iset : public etl::set_base { public: diff --git a/include/etl/version.h b/include/etl/version.h index c13c8c8e..cb827822 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.12.1" +#define ETL_VERSION "11.12.2" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 12 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #endif diff --git a/src/private/pvoidvector.cpp b/src/private/pvoidvector.cpp index 5b000adf..527abfbe 100644 --- a/src/private/pvoidvector.cpp +++ b/src/private/pvoidvector.cpp @@ -31,6 +31,462 @@ SOFTWARE. #include "../../include/etl/platform.h" #include "../../include/etl/private/pvoidvector.h" +//********************************************************************* +/// Returns an iterator to the beginning of the vector. +///\return An iterator to the beginning of the vector. +//********************************************************************* +etl::pvoidvector::iterator etl::pvoidvector::begin() +{ + return p_buffer; +} + +//********************************************************************* +/// Returns a const_iterator to the beginning of the vector. +///\return A const iterator to the beginning of the vector. +//********************************************************************* +etl::pvoidvector::const_iterator etl::pvoidvector::begin() const +{ + return const_iterator(p_buffer); +} + +//********************************************************************* +/// Returns an iterator to the end of the vector. +///\return An iterator to the end of the vector. +//********************************************************************* +etl::pvoidvector::iterator etl::pvoidvector::end() +{ + return p_end; +} + +//********************************************************************* +/// Returns a const_iterator to the end of the vector. +///\return A const iterator to the end of the vector. +//********************************************************************* +etl::pvoidvector::const_iterator etl::pvoidvector::end() const +{ + return const_iterator(p_end); +} + +//********************************************************************* +/// Returns a const_iterator to the beginning of the vector. +///\return A const iterator to the beginning of the vector. +//********************************************************************* +etl::pvoidvector::const_iterator etl::pvoidvector::cbegin() const +{ + return const_iterator(p_buffer); +} + +//********************************************************************* +/// Returns a const_iterator to the end of the vector. +///\return A const iterator to the end of the vector. +//********************************************************************* +etl::pvoidvector::const_iterator etl::pvoidvector::cend() const +{ + return const_iterator(p_end); +} + +//********************************************************************* +/// Returns an reverse iterator to the reverse beginning of the vector. +///\return Iterator to the reverse beginning of the vector. +//********************************************************************* +etl::pvoidvector::reverse_iterator etl::pvoidvector::rbegin() +{ + return reverse_iterator(end()); +} + +//********************************************************************* +/// Returns a const reverse iterator to the reverse beginning of the vector. +///\return Const iterator to the reverse beginning of the vector. +//********************************************************************* +etl::pvoidvector::const_reverse_iterator etl::pvoidvector::rbegin() const +{ + return const_reverse_iterator(end()); +} + +//********************************************************************* +/// Returns a reverse iterator to the end + 1 of the vector. +///\return Reverse iterator to the end + 1 of the vector. +//********************************************************************* +etl::pvoidvector::reverse_iterator etl::pvoidvector::rend() +{ + return reverse_iterator(begin()); +} + +//********************************************************************* +/// Returns a const reverse iterator to the end + 1 of the vector. +///\return Const reverse iterator to the end + 1 of the vector. +//********************************************************************* +etl::pvoidvector::const_reverse_iterator etl::pvoidvector::rend() const +{ + return const_reverse_iterator(begin()); +} + +//********************************************************************* +/// Returns a const reverse iterator to the reverse beginning of the vector. +///\return Const reverse iterator to the reverse beginning of the vector. +//********************************************************************* +etl::pvoidvector::const_reverse_iterator etl::pvoidvector::crbegin() const +{ + return const_reverse_iterator(cend()); +} + +//********************************************************************* +/// Returns a const reverse iterator to the end + 1 of the vector. +///\return Const reverse iterator to the end + 1 of the vector. +//********************************************************************* +etl::pvoidvector::const_reverse_iterator etl::pvoidvector::crend() const +{ + return const_reverse_iterator(cbegin()); +} + +//********************************************************************* +/// Resizes the vector. +/// If asserts or exceptions are enabled and the new size is larger than the +/// maximum then a vector_full is thrown. +///\param new_size The new size. +//********************************************************************* +void etl::pvoidvector::resize(size_t new_size) +{ + ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full)); + + p_end = p_buffer + new_size; +} + +//********************************************************************* +/// Resizes the vector. +/// If asserts or exceptions are enabled and the new size is larger than the +/// maximum then a vector_full is thrown. +///\param new_size The new size. +///\param value The value to fill new elements with. Default = default constructed value. +//********************************************************************* +void etl::pvoidvector::resize(size_t new_size, etl::pvoidvector::value_type value) +{ + ETL_ASSERT(new_size <= CAPACITY, ETL_ERROR(vector_full)); + + pointer p_new_end = p_buffer + new_size; + + // Size up if necessary. + if (p_end < p_new_end) + { + std::fill(p_end, p_new_end, value); + } + + p_end = p_new_end; +} + +//********************************************************************* +/// Returns a reference to the value at index 'i' +///\param i The index. +///\return A reference to the value at index 'i' +//********************************************************************* +etl::pvoidvector::reference etl::pvoidvector::operator [](size_t i) +{ + return p_buffer[i]; +} + +//********************************************************************* +/// Returns a const reference to the value at index 'i' +///\param i The index. +///\return A const reference to the value at index 'i' +//********************************************************************* +etl::pvoidvector::const_reference etl::pvoidvector::operator [](size_t i) const +{ + return const_reference(p_buffer[i]); +} + +//********************************************************************* +/// Returns a reference to the value at index 'i' +/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. +///\param i The index. +///\return A reference to the value at index 'i' +//********************************************************************* +etl::pvoidvector::reference etl::pvoidvector::at(size_t i) +{ + ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds)); + return p_buffer[i]; +} + +//********************************************************************* +/// Returns a const reference to the value at index 'i' +/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. +///\param i The index. +///\return A const reference to the value at index 'i' +//********************************************************************* +etl::pvoidvector::const_reference etl::pvoidvector::at(size_t i) const +{ + ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds)); + return const_reference(p_buffer[i]); +} + +//********************************************************************* +/// Returns a reference to the first element. +///\return A reference to the first element. +//********************************************************************* +etl::pvoidvector::reference etl::pvoidvector::front() +{ + return p_buffer[0]; +} + +//********************************************************************* +/// Returns a const reference to the first element. +///\return A const reference to the first element. +//********************************************************************* +etl::pvoidvector::const_reference etl::pvoidvector::front() const +{ + return const_reference(p_buffer[0]); +} + +//********************************************************************* +/// Returns a reference to the last element. +///\return A reference to the last element. +//********************************************************************* +etl::pvoidvector::reference etl::pvoidvector::back() +{ + return *(p_end - 1); +} + +//********************************************************************* +/// Returns a const reference to the last element. +///\return A const reference to the last element. +//********************************************************************* +etl::pvoidvector::const_reference etl::pvoidvector::back() const +{ + return const_reference(*(p_end - 1)); +} + +//********************************************************************* +/// Returns a pointer to the beginning of the vector data. +///\return A pointer to the beginning of the vector data. +//********************************************************************* +etl::pvoidvector::pointer etl::pvoidvector::data() +{ + return p_buffer; +} + +//********************************************************************* +/// Returns a const pointer to the beginning of the vector data. +///\return A const pointer to the beginning of the vector data. +//********************************************************************* +etl::pvoidvector::const_pointer etl::pvoidvector::data() const +{ + return const_pointer(p_buffer); +} + +//********************************************************************* +/// Assigns values to the vector. +/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. +///\param n The number of elements to add. +///\param value The value to insert for each element. +//********************************************************************* +void etl::pvoidvector::assign(size_t n, etl::pvoidvector::value_type value) +{ + initialise(); + + ETL_ASSERT(n <= CAPACITY, ETL_ERROR(vector_full)); + + for (size_t current_size = 0; current_size < n; ++current_size) + { + *p_end++ = value; + } +} + +//************************************************************************* +/// Clears the vector. +//************************************************************************* +void etl::pvoidvector::clear() +{ + initialise(); +} + +//************************************************************************* +/// Increases the size of the vector by one, but does not initialise the new element. +/// If asserts or exceptions are enabled, throws a vector_full if the vector is already full. +//************************************************************************* +void etl::pvoidvector::push_back() +{ +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); +#endif + + ++p_end; +} + +//********************************************************************* +/// Inserts a value at the end of the vector. +/// If asserts or exceptions are enabled, emits vector_full if the vector is already full. +///\param value The value to add. +//********************************************************************* +void etl::pvoidvector::push_back(etl::pvoidvector::value_type value) +{ +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); +#endif + *p_end++ = value; +} + +//************************************************************************* +/// Removes an element from the end of the vector. +/// Does nothing if the vector is empty. +//************************************************************************* +void etl::pvoidvector::pop_back() +{ +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(size() > 0, ETL_ERROR(vector_empty)); +#endif + --p_end; +} + +//********************************************************************* +/// Inserts a value to the vector. +/// If asserts or exceptions are enabled, emits vector_full if the vector is already full. +///\param position The position to insert before. +///\param value The value to insert. +//********************************************************************* +etl::pvoidvector::iterator etl::pvoidvector::insert(etl::pvoidvector::iterator position, etl::pvoidvector::value_type value) +{ + ETL_ASSERT(size() + 1 <= CAPACITY, ETL_ERROR(vector_full)); + + if (position != end()) + { + ++p_end; + std::copy_backward(position, end() - 1, end()); + *position = value; + } + else + { + *p_end++ = value; + } + + return position; +} + +//********************************************************************* +/// Inserts 'n' values to the vector. +/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. +///\param position The position to insert before. +///\param n The number of elements to add. +///\param value The value to insert. +//********************************************************************* +void etl::pvoidvector::insert(etl::pvoidvector::iterator position, size_t n, etl::pvoidvector::value_type value) +{ + ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full)); + + std::copy_backward(position, p_end, p_end + n); + std::fill_n(position, n, value); + + p_end += n; +} + +//********************************************************************* +/// Erases an element. +///\param i_element Iterator to the element. +///\return An iterator pointing to the element that followed the erased element. +//********************************************************************* +etl::pvoidvector::iterator etl::pvoidvector::erase(etl::pvoidvector::iterator i_element) +{ + std::copy(i_element + 1, end(), i_element); + --p_end; + + return i_element; +} + +//********************************************************************* +/// Erases a range of elements. +/// The range includes all the elements between first and last, including the +/// element pointed by first, but not the one pointed by last. +///\param first Iterator to the first element. +///\param last Iterator to the last element. +///\return An iterator pointing to the element that followed the erased element. +//********************************************************************* +etl::pvoidvector::iterator etl::pvoidvector::erase(etl::pvoidvector::iterator first, etl::pvoidvector::iterator last) +{ + std::copy(last, end(), first); + size_t n_delete = std::distance(first, last); + + // Just adjust the count. + p_end -= n_delete; + + return first; +} + +//************************************************************************* +/// Assignment operator. +//************************************************************************* +etl::pvoidvector& etl::pvoidvector::operator = (const etl::pvoidvector& rhs) +{ + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; +} + +//************************************************************************* +/// Gets the current size of the vector. +///\return The current size of the vector. +//************************************************************************* +etl::pvoidvector::size_type etl::pvoidvector::size() const +{ + return size_t(p_end - p_buffer); +} + +//************************************************************************* +/// Checks the 'empty' state of the vector. +///\return true if empty. +//************************************************************************* +bool etl::pvoidvector::empty() const +{ + return (p_end == p_buffer); +} + +//************************************************************************* +/// Checks the 'full' state of the vector. +///\return true if full. +//************************************************************************* +bool etl::pvoidvector::full() const +{ + return size() == CAPACITY; +} + +//************************************************************************* +/// Returns the remaining capacity. +///\return The remaining capacity. +//************************************************************************* +size_t etl::pvoidvector::available() const +{ + return max_size() - size(); +} + +//********************************************************************* +/// Constructor. +//********************************************************************* +etl::pvoidvector::pvoidvector(void** p_buffer_, size_t MAX_SIZE) + : vector_base(MAX_SIZE), + p_buffer(p_buffer_), + p_end(p_buffer_) +{ +} + +//********************************************************************* +/// Initialise the vector. +//********************************************************************* +void etl::pvoidvector::initialise() +{ + p_end = p_buffer; +} + +//************************************************************************* +/// Fix the internal pointers after a low level memory copy. +//************************************************************************* +void etl::pvoidvector::repair(void** p_buffer_) +{ + uintptr_t length = p_end - p_buffer; + + p_buffer = p_buffer_; + p_end = p_buffer_ + length; +} + namespace etl { //*************************************************************************** diff --git a/support/Release notes.txt b/support/Release notes.txt index 7ef5910e..79e74a7d 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,9 @@ +=============================================================================== +11.12.2 +Remove SFINAE from array_view. +Added default etl::less compare type appropriate map and set classes. +Moved non-template code in pvoidvector to cpp file. + =============================================================================== 11.12.1 Made atomic load const for non STL vesions From 58f10b305d6783c4192f4a2c76db9ac87addd467 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 3 Jul 2018 22:14:12 +0100 Subject: [PATCH 18/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # support/Release notes.txt --- include/etl/private/ivectorpointer.h | 402 ++++++++++++ include/etl/version.h | 6 +- support/Release notes.txt | 4 + test/test_vector_pointer.cpp | 902 +++++++++++++++++++++++++-- 4 files changed, 1275 insertions(+), 39 deletions(-) diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index 6dcda8f3..9ef26977 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -446,6 +446,408 @@ namespace etl } }; + template + class ivector : public pvoidvector + { + public: + + typedef const T* value_type; + typedef const T*& reference; + typedef const T* const & const_reference; + typedef const T** pointer; + typedef const T* const * const_pointer; + typedef const T** iterator; + typedef const T* const * const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef size_t size_type; + typedef typename std::iterator_traits::difference_type difference_type; + + protected: + + typedef value_type parameter_t; + + private: + + typedef pvoidvector base_t; + + public: + + //********************************************************************* + /// Returns an iterator to the beginning of the vector. + ///\return An iterator to the beginning of the vector. + //********************************************************************* + iterator begin() + { + return iterator(base_t::begin()); + } + + //********************************************************************* + /// Returns a const_iterator to the beginning of the vector. + ///\return A const iterator to the beginning of the vector. + //********************************************************************* + const_iterator begin() const + { + return const_iterator(base_t::begin()); + } + + //********************************************************************* + /// Returns an iterator to the end of the vector. + ///\return An iterator to the end of the vector. + //********************************************************************* + iterator end() + { + return iterator(base_t::end()); + } + + //********************************************************************* + /// Returns a const_iterator to the end of the vector. + ///\return A const iterator to the end of the vector. + //********************************************************************* + const_iterator end() const + { + return const_iterator(base_t::end()); + } + + //********************************************************************* + /// Returns a const_iterator to the beginning of the vector. + ///\return A const iterator to the beginning of the vector. + //********************************************************************* + const_iterator cbegin() const + { + return const_iterator(base_t::cbegin()); + } + + //********************************************************************* + /// Returns a const_iterator to the end of the vector. + ///\return A const iterator to the end of the vector. + //********************************************************************* + const_iterator cend() const + { + return const_iterator(base_t::cend()); + } + + //********************************************************************* + /// Returns an reverse iterator to the reverse beginning of the vector. + ///\return Iterator to the reverse beginning of the vector. + //********************************************************************* + reverse_iterator rbegin() + { + return reverse_iterator(iterator(base_t::end())); + } + + //********************************************************************* + /// Returns a const reverse iterator to the reverse beginning of the vector. + ///\return Const iterator to the reverse beginning of the vector. + //********************************************************************* + const_reverse_iterator rbegin() const + { + return const_reverse_iterator(const_iterator(base_t::end())); + } + + //********************************************************************* + /// Returns a reverse iterator to the end + 1 of the vector. + ///\return Reverse iterator to the end + 1 of the vector. + //********************************************************************* + reverse_iterator rend() + { + return reverse_iterator(iterator(base_t::begin())); + } + + //********************************************************************* + /// Returns a const reverse iterator to the end + 1 of the vector. + ///\return Const reverse iterator to the end + 1 of the vector. + //********************************************************************* + const_reverse_iterator rend() const + { + return const_reverse_iterator(const_iterator(base_t::begin())); + } + + //********************************************************************* + /// Returns a const reverse iterator to the reverse beginning of the vector. + ///\return Const reverse iterator to the reverse beginning of the vector. + //********************************************************************* + const_reverse_iterator crbegin() const + { + return const_reverse_iterator(const_iterator(base_t::cend())); + } + + //********************************************************************* + /// Returns a const reverse iterator to the end + 1 of the vector. + ///\return Const reverse iterator to the end + 1 of the vector. + //********************************************************************* + const_reverse_iterator crend() const + { + return const_reverse_iterator(const_iterator(base_t::cbegin())); + } + + //********************************************************************* + /// Resizes the vector. + /// If asserts or exceptions are enabled and the new size is larger than the + /// maximum then a vector_full is thrown. + ///\param new_size The new size. + //********************************************************************* + void resize(size_t new_size) + { + base_t::resize(new_size); + } + + //********************************************************************* + /// Resizes the vector. + /// If asserts or exceptions are enabled and the new size is larger than the + /// maximum then a vector_full is thrown. + ///\param new_size The new size. + ///\param value The value to fill new elements with. Default = default constructed value. + //********************************************************************* + void resize(size_t new_size, value_type value) + { + base_t::resize(new_size, const_cast(value)); + } + + //********************************************************************* + /// Returns a reference to the value at index 'i' + ///\param i The index. + ///\return A reference to the value at index 'i' + //********************************************************************* + reference operator [](size_t i) + { + return reference(base_t::operator[](i)); + } + + //********************************************************************* + /// Returns a const reference to the value at index 'i' + ///\param i The index. + ///\return A const reference to the value at index 'i' + //********************************************************************* + const_reference operator [](size_t i) const + { + return const_reference(base_t::operator[](i)); + } + + //********************************************************************* + /// Returns a reference to the value at index 'i' + /// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. + ///\param i The index. + ///\return A reference to the value at index 'i' + //********************************************************************* + reference at(size_t i) + { + return reference(base_t::at(i)); + } + + //********************************************************************* + /// Returns a const reference to the value at index 'i' + /// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range. + ///\param i The index. + ///\return A const reference to the value at index 'i' + //********************************************************************* + const_reference at(size_t i) const + { + return const_reference(base_t::at(i)); + } + + //********************************************************************* + /// Returns a reference to the first element. + ///\return A reference to the first element. + //********************************************************************* + reference front() + { + return reference(base_t::front()); + } + + //********************************************************************* + /// Returns a const reference to the first element. + ///\return A const reference to the first element. + //********************************************************************* + const_reference front() const + { + return const_reference(base_t::front()); + } + + //********************************************************************* + /// Returns a reference to the last element. + ///\return A reference to the last element. + //********************************************************************* + reference back() + { + return reference(base_t::back()); + } + + //********************************************************************* + /// Returns a const reference to the last element. + ///\return A const reference to the last element. + //********************************************************************* + const_reference back() const + { + return const_reference(base_t::back()); + } + + //********************************************************************* + /// Returns a pointer to the beginning of the vector data. + ///\return A pointer to the beginning of the vector data. + //********************************************************************* + pointer data() + { + return pointer(base_t::data()); + } + + //********************************************************************* + /// Returns a const pointer to the beginning of the vector data. + ///\return A const pointer to the beginning of the vector data. + //********************************************************************* + const_pointer data() const + { + return const_pointer(base_t::data()); + } + + //********************************************************************* + /// Assigns values to the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. + /// If asserts or exceptions are enabled, emits vector_iterator if the iterators are reversed. + ///\param first The iterator to the first element. + ///\param last The iterator to the last element + 1. + //********************************************************************* + template + void assign(TIterator first, TIterator last) + { + base_t::initialise(); + + while (first != last) + { + *p_end++ = (void*)*first++; + } + } + + //********************************************************************* + /// Assigns values to the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. + ///\param n The number of elements to add. + ///\param value The value to insert for each element. + //********************************************************************* + void assign(size_t n, parameter_t value) + { + base_t::assign(n, const_cast(value)); + } + + //************************************************************************* + /// Clears the vector. + //************************************************************************* + void clear() + { + base_t::clear(); + } + + //************************************************************************* + /// Increases the size of the vector by one, but does not initialise the new element. + /// If asserts or exceptions are enabled, throws a vector_full if the vector is already full. + //************************************************************************* + void push_back() + { + base_t::push_back(); + } + + //********************************************************************* + /// Inserts a value at the end of the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. + ///\param value The value to add. + //********************************************************************* + void push_back(parameter_t value) + { + base_t::push_back(const_cast(value)); + } + + //************************************************************************* + /// Removes an element from the end of the vector. + /// Does nothing if the vector is empty. + //************************************************************************* + void pop_back() + { + base_t::pop_back(); + } + + //********************************************************************* + /// Inserts a value to the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. + ///\param position The position to insert before. + ///\param value The value to insert. + //********************************************************************* + iterator insert(iterator position, parameter_t value) + { + return iterator(base_t::insert(base_t::iterator(position), const_cast(value))); + } + + //********************************************************************* + /// Inserts 'n' values to the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. + ///\param position The position to insert before. + ///\param n The number of elements to add. + ///\param value The value to insert. + //********************************************************************* + void insert(iterator position, size_t n, parameter_t value) + { + base_t::insert(base_t::iterator(position), n, const_cast(value)); + } + + //********************************************************************* + /// Inserts a range of values to the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space. + ///\param position The position to insert before. + ///\param first The first element to add. + ///\param last The last + 1 element to add. + //********************************************************************* + template + void insert(iterator position, TIterator first, TIterator last) + { + base_t::insert(base_t::iterator(position), first, last); + } + + //********************************************************************* + /// Erases an element. + ///\param i_element Iterator to the element. + ///\return An iterator pointing to the element that followed the erased element. + //********************************************************************* + iterator erase(iterator i_element) + { + return iterator(base_t::erase(base_t::iterator(i_element))); + } + + //********************************************************************* + /// Erases a range of elements. + /// The range includes all the elements between first and last, including the + /// element pointed by first, but not the one pointed by last. + ///\param first Iterator to the first element. + ///\param last Iterator to the last element. + ///\return An iterator pointing to the element that followed the erased element. + //********************************************************************* + iterator erase(iterator first, iterator last) + { + return iterator(base_t::erase(base_t::iterator(first), base_t::iterator(last))); + } + + //************************************************************************* + /// Assignment operator. + //************************************************************************* + ivector& operator = (const ivector& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + + protected: + + //********************************************************************* + /// Constructor. + //********************************************************************* + ivector(const T** p_buffer_, size_t MAX_SIZE_) + : pvoidvector(reinterpret_cast(const_cast(p_buffer_)), MAX_SIZE_) + { + } + }; + //*************************************************************************** /// Equal operator. ///\param lhs Reference to the first vector. diff --git a/include/etl/version.h b/include/etl/version.h index cb827822..9043d8f3 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.12.2" +#define ETL_VERSION "11.13.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 12 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MINOR 13 +#define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 79e74a7d..315fa97c 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.13.0 +Added specialisation for vector + =============================================================================== 11.12.2 Remove SFINAE from array_view. diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index 970d2263..eeac0e8c 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -41,9 +41,12 @@ namespace { static const size_t SIZE = 10; - typedef etl::vector Data; - typedef etl::ivector IData; - typedef std::vector Compare_Data; + typedef etl::vector Data; + typedef etl::vector CData; + typedef etl::ivector IData; + typedef etl::ivector CIData; + typedef std::vector Compare_Data; + typedef std::vector CCompare_Data; Compare_Data initial_data; Compare_Data less_data; @@ -97,6 +100,17 @@ namespace CHECK_EQUAL(data.max_size(), SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_default_constructor) + { + CData data; + + CHECK_EQUAL(data.size(), size_t(0)); + CHECK(data.empty()); + CHECK_EQUAL(data.capacity(), SIZE); + CHECK_EQUAL(data.max_size(), SIZE); + } + //************************************************************************* TEST(test_iterator_comparison_empty) { @@ -108,6 +122,17 @@ namespace CHECK(data.crbegin() == data.crend()); } + //************************************************************************* + TEST(test_const_iterator_comparison_empty) + { + CData data; + + CHECK(data.begin() == data.end()); + CHECK(data.cbegin() == data.cend()); + CHECK(data.rbegin() == data.rend()); + CHECK(data.crbegin() == data.crend()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size) { @@ -118,6 +143,16 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_constructor_size) + { + const size_t INITIAL_SIZE = 5; + CData data(INITIAL_SIZE); + + CHECK(data.size() == INITIAL_SIZE); + CHECK(!data.empty()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_value) { @@ -137,12 +172,37 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_constructor_size_value) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + + std::array compare_data; + compare_data.fill(&INITIAL_VALUE); + + CData data(INITIAL_SIZE, &INITIAL_VALUE); + + CHECK(data.size() == INITIAL_SIZE); + CHECK(!data.empty()); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_excess) { CHECK_THROW(Data data(SIZE + 1), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_constructor_size_excess) + { + CHECK_THROW(CData data(SIZE + 1), etl::vector_full); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { @@ -155,6 +215,18 @@ namespace CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_constructor_range) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + CHECK(data.size() == SIZE); + CHECK(!data.empty()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST(test_constructor_initializer_list) { @@ -170,6 +242,21 @@ namespace CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); } + //************************************************************************* + TEST(test_const_constructor_initializer_list) + { + int a = 0; + int b = 1; + int c = 3; + int d = 4; + + CCompare_Data compare_data = { &a, &b, &c, &d }; + CData data = { &a, &b, &c, &d }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -181,6 +268,17 @@ namespace CHECK(data2 != data); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_copy_constructor) + { + CData data(initial_data.begin(), initial_data.end()); + CData data2(data); + CHECK(data2 == data); + + data2[2] = nullptr; + CHECK(data2 != data); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { @@ -194,6 +292,19 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_assignment) + { + CData data(initial_data.begin(), initial_data.end()); + CData other_data; + + other_data = data; + + bool is_equal = std::equal(data.begin(), data.end(), other_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment_iterface) { @@ -210,6 +321,22 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_assignment_iterface) + { + CData data1(initial_data.begin(), initial_data.end()); + CData data2; + + CIData& idata1 = data1; + CIData& idata2 = data2; + + idata2 = idata1; + + bool is_equal = std::equal(data1.begin(), data1.end(), data2.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { @@ -223,6 +350,19 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_self_assignment) + { + CData data(initial_data.begin(), initial_data.end()); + CData other_data(data); + + other_data = other_data; + + bool is_equal = std::equal(data.begin(), data.end(), other_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -233,6 +373,16 @@ namespace CHECK_EQUAL(&constData[0], constData.begin()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_begin) + { + CData data(10); + const CData constData(10); + + CHECK_EQUAL(&data[0], data.begin()); + CHECK_EQUAL(&constData[0], constData.begin()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_end) { @@ -243,6 +393,16 @@ namespace CHECK_EQUAL(&constData[10], constData.end()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_end) + { + CData data(10); + const CData constData(10); + + CHECK_EQUAL(&data[10], data.end()); + CHECK_EQUAL(&constData[10], constData.end()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_resize_up) { @@ -255,6 +415,18 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_resize_up) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 8; + + CData data(INITIAL_SIZE); + data.resize(NEW_SIZE); + + CHECK_EQUAL(data.size(), NEW_SIZE); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_resize_up_value) { @@ -273,6 +445,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_resize_up_value) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 8; + int INITIAL_VALUE = 1; + + CData data(INITIAL_SIZE, &INITIAL_VALUE); + data.resize(NEW_SIZE, &INITIAL_VALUE); + + std::array compare_data; + compare_data.fill(&INITIAL_VALUE); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_resize_excess) { @@ -284,6 +474,17 @@ namespace CHECK_THROW(data.resize(NEW_SIZE), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_resize_excess) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = SIZE + 1; + + CData data(INITIAL_SIZE); + + CHECK_THROW(data.resize(NEW_SIZE), etl::vector_full); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_resize_down) { @@ -296,6 +497,18 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_resize_down) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 2; + + CData data(INITIAL_SIZE); + data.resize(NEW_SIZE); + + CHECK_EQUAL(data.size(), NEW_SIZE); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_resize_down_value) { @@ -309,6 +522,19 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_resize_down_value) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 2; + int INITIAL_VALUE = 1; + + CData data(INITIAL_SIZE); + data.resize(NEW_SIZE, &INITIAL_VALUE); + + CHECK_EQUAL(data.size(), NEW_SIZE); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty) { @@ -319,6 +545,16 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_empty) + { + CData data; + data.resize(data.max_size()); + + CHECK(data.full()); + CHECK(!data.empty()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_full) { @@ -328,6 +564,15 @@ namespace CHECK(data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_full) + { + CData data; + + CHECK(!data.full()); + CHECK(data.empty()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { @@ -341,6 +586,19 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_index) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], compare_data[i]); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { @@ -354,6 +612,19 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_index_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + const CData data(compare_data.begin(), compare_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], compare_data[i]); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { @@ -368,6 +639,20 @@ namespace CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_at) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data.at(i), compare_data.at(i)); + } + + CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { @@ -382,6 +667,20 @@ namespace CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_at_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + const CData data(initial_data.begin(), initial_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data.at(i), compare_data.at(i)); + } + + CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { @@ -391,6 +690,15 @@ namespace CHECK(data.front() == compare_data.front()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_front) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + CHECK(data.front() == compare_data.front()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { @@ -400,6 +708,15 @@ namespace CHECK(data.front() == compare_data.front()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_front_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + const CData data(initial_data.begin(), initial_data.end()); + + CHECK(data.front() == compare_data.front()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { @@ -409,6 +726,15 @@ namespace CHECK(data.back() == compare_data.back()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_back) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + CHECK(data.back() == compare_data.back()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { @@ -418,6 +744,14 @@ namespace CHECK(data.back() == compare_data.back()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_back_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + const CData data(initial_data.begin(), initial_data.end()); + + CHECK(data.back() == compare_data.back()); + } //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) @@ -431,6 +765,18 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_data) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.data(), data.data() + data.size(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { @@ -443,6 +789,18 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_data_const) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + const CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.data(), data.data() + data.size(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { @@ -457,6 +815,20 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_assign_range) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data; + + data.assign(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_size_value) { @@ -473,6 +845,22 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_assign_size_value) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + std::array compare_data; + compare_data.fill(&INITIAL_VALUE); + + CData data; + data.assign(INITIAL_SIZE, &INITIAL_VALUE); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) { @@ -487,6 +875,20 @@ namespace CHECK_THROW(data.assign(EXCESS_SIZE, &INITIAL_VALUE), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_assign_size_value_excess) + { + const size_t INITIAL_SIZE = SIZE; + const size_t EXCESS_SIZE = SIZE + 1; + int INITIAL_VALUE = 1; + std::array compare_data; + compare_data.fill(&INITIAL_VALUE); + + CData data; + + CHECK_THROW(data.assign(EXCESS_SIZE, &INITIAL_VALUE), etl::vector_full); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { @@ -510,6 +912,29 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_push_back) + { + CCompare_Data compare_data; + CData data; + + const int d = 0; + + for (size_t i = 0; i < SIZE; ++i) + { + compare_data.push_back(&d); + } + + for (size_t i = 0; i < SIZE; ++i) + { + data.push_back(&d); + } + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_null) { @@ -528,6 +953,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_push_back_null) + { + CCompare_Data compare_data; + CData data; + + const int d = 0; + + compare_data.push_back(&d); + + data.push_back(); + data[0] = &d; + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { @@ -543,6 +986,21 @@ namespace CHECK_THROW(data.push_back(&d), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_push_back_excess) + { + CData data; + + const int d = 0; + + for (size_t i = 0; i < SIZE; ++i) + { + data.push_back(&d); + } + + CHECK_THROW(data.push_back(&d), etl::vector_full); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { @@ -555,9 +1013,24 @@ namespace data.pop_back(); data.pop_back(); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_pop_back) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + compare_data.pop_back(); + compare_data.pop_back(); + + data.pop_back(); + data.pop_back(); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -575,6 +1048,19 @@ namespace CHECK_THROW(data.pop_back(), etl::vector_empty); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_pop_back_exception) + { + CData data; + + data.resize(2); + + data.pop_back(); + data.pop_back(); + + CHECK_THROW(data.pop_back(), etl::vector_empty); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value) { @@ -594,9 +1080,32 @@ namespace CHECK_EQUAL(compare_data.size(), data.size()); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_value) + { + const size_t INITIAL_SIZE = 5; + int INITIAL_VALUE = 1; + + for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) + { + CCompare_Data compare_data; + CData data; + + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + + data.insert(data.begin() + offset, &INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, &INITIAL_VALUE); + + CHECK_EQUAL(compare_data.size(), data.size()); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -640,9 +1149,30 @@ namespace data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE); compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value) + { + const size_t INITIAL_SIZE = 5; + const size_t INSERT_SIZE = 3; + int INITIAL_VALUE = 11; + + for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) + { + CCompare_Data compare_data; + CData data; + + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -674,6 +1204,32 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_n_value_excess) + { + const size_t INITIAL_SIZE = SIZE; + const size_t INSERT_SIZE = 4; + const int INITIAL_VALUE = 1; + + CData data(INITIAL_SIZE, &INITIAL_VALUE); + + size_t offset = 0; + + CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE), etl::vector_full); + + offset = 2; + + CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE), etl::vector_full); + + offset = 4; + + CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE), etl::vector_full); + + offset = data.size(); + + CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, &INITIAL_VALUE), etl::vector_full); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_range) { @@ -698,6 +1254,30 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_range) + { + const size_t INITIAL_SIZE = 5; + const int INITIAL_VALUE = 1; + + for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) + { + CCompare_Data compare_data; + CData data; + + data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + compare_data.assign(initial_data.begin(), initial_data.begin() + INITIAL_SIZE); + data.insert(data.begin() + offset, insert_data.begin(), insert_data.end()); + compare_data.insert(compare_data.begin() + offset, insert_data.begin(), insert_data.end()); + + bool is_equal = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) { @@ -722,7 +1302,31 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_insert_position_range_excess) + { + const size_t INITIAL_SIZE = 5; + const int INITIAL_VALUE = 1; + CData data(INITIAL_SIZE, &INITIAL_VALUE); + + size_t offset = 0; + + CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); + + offset = 2; + + CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); + + offset = 4; + + CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); + + offset = data.size(); + + CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); + } //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single) @@ -734,9 +1338,22 @@ namespace data.erase(data.begin() + 2); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_single) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + compare_data.erase(compare_data.begin() + 2); + + data.erase(data.begin() + 2); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -751,9 +1368,22 @@ namespace data.erase(data.begin() + 2, data.begin() + 4); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_erase_range) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + CData data(initial_data.begin(), initial_data.end()); + + compare_data.erase(compare_data.begin() + 2, compare_data.begin() + 4); + + data.erase(data.begin() + 2, data.begin() + 4); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -769,6 +1399,17 @@ namespace CHECK_EQUAL(data.size(), size_t(0)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_clear) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + data.clear(); + + CHECK_EQUAL(data.size(), size_t(0)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { @@ -776,9 +1417,19 @@ namespace Data data(compare_data.begin(), compare_data.end()); - bool is_equal = std::equal(data.begin(), - data.end(), - compare_data.begin()); + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_iterator_const) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(is_equal); } @@ -790,9 +1441,19 @@ namespace Data data(compare_data.begin(), compare_data.end()); - bool is_equal = std::equal(data.cbegin(), - data.cend(), - compare_data.cbegin()); + bool is_equal = std::equal(data.cbegin(), data.cend(), compare_data.cbegin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_iterator_const) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.cbegin(), data.cend(), compare_data.cbegin()); CHECK(is_equal); } @@ -804,9 +1465,19 @@ namespace Data data(compare_data.begin(), compare_data.end()); - bool is_equal = std::equal(data.rbegin(), - data.rend(), - compare_data.rbegin()); + bool is_equal = std::equal(data.rbegin(), data.rend(), compare_data.rbegin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_reverse_iterator_const) + { + CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.rbegin(), data.rend(), compare_data.rbegin()); CHECK(is_equal); } @@ -818,9 +1489,19 @@ namespace const Data data(compare_data.begin(), compare_data.end()); - bool is_equal = std::equal(data.crbegin(), - data.crend(), - compare_data.crbegin()); + bool is_equal = std::equal(data.crbegin(), data.crend(), compare_data.crbegin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_reverse_iterator_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + const CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.crbegin(), data.crend(), compare_data.crbegin()); CHECK(is_equal); } @@ -832,9 +1513,19 @@ namespace const Data data(compare_data.begin(), compare_data.end()); - bool is_equal = std::equal(data.rbegin(), - data.rend(), - compare_data.rbegin()); + bool is_equal = std::equal(data.rbegin(), data.rend(), compare_data.rbegin()); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_reverse_iterator2_const) + { + const CCompare_Data compare_data(initial_data.begin(), initial_data.end()); + + const CData data(compare_data.begin(), compare_data.end()); + + bool is_equal = std::equal(data.rbegin(), data.rend(), compare_data.rbegin()); CHECK(is_equal); } @@ -856,6 +1547,23 @@ namespace CHECK(!(shorter == initial1)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_equal) + { + const CData initial1(initial_data.begin(), initial_data.end()); + const CData initial2(initial_data.begin(), initial_data.end()); + + CHECK(initial1 == initial2); + + const CData different(different_data.begin(), different_data.end()); + + CHECK(!(initial1 == different)); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK(!(shorter == initial1)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_not_equal) { @@ -873,6 +1581,23 @@ namespace CHECK(shorter != initial1); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_not_equal) + { + const CData initial1(initial_data.begin(), initial_data.end()); + const CData initial2(initial_data.begin(), initial_data.end()); + + CHECK(!(initial1 != initial2)); + + const CData different(different_data.begin(), different_data.end()); + + CHECK(initial1 != different); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK(shorter != initial1); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_less_than) { @@ -891,6 +1616,24 @@ namespace CHECK((initial < shorter) == (initial_data < shorter_data)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_less_than) + { + const CData less(less_data.begin(), less_data.end()); + const CData initial(initial_data.begin(), initial_data.end()); + + CHECK((less < initial) == (less_data < initial_data)); + + const CData greater(greater_data.begin(), greater_data.end()); + + CHECK((greater < initial) == (greater_data < initial_data)); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK((shorter < initial) == (shorter_data < initial_data)); + CHECK((initial < shorter) == (initial_data < shorter_data)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_less_than_or_equal) { @@ -912,6 +1655,27 @@ namespace CHECK((initial <= initial2) == (initial_data <= initial_data)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_less_than_or_equal) + { + const CData less(less_data.begin(), less_data.end()); + const CData initial(initial_data.begin(), initial_data.end()); + + CHECK((less <= initial) == (less_data <= initial_data)); + + const CData greater(greater_data.begin(), greater_data.end()); + + CHECK((greater <= initial) == (greater_data <= initial_data)); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK((shorter <= initial) == (shorter_data <= initial_data)); + CHECK((initial <= shorter) == (initial_data <= shorter_data)); + + const CData initial2(initial_data.begin(), initial_data.end()); + CHECK((initial <= initial2) == (initial_data <= initial_data)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_greater_than) { @@ -930,6 +1694,24 @@ namespace CHECK((initial > shorter) == (initial_data > shorter_data)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_greater_than) + { + const CData less(less_data.begin(), less_data.end()); + const CData initial(initial_data.begin(), initial_data.end()); + + CHECK((less > initial) == (less_data > initial_data)); + + const CData greater(greater_data.begin(), greater_data.end()); + + CHECK((greater > initial) == (greater_data > initial_data)); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK((shorter > initial) == (shorter_data > initial_data)); + CHECK((initial > shorter) == (initial_data > shorter_data)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_greater_than_or_equal) { @@ -951,6 +1733,27 @@ namespace CHECK((initial >= initial2) == (initial_data >= initial_data)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_greater_than_or_equal) + { + const CData less(less_data.begin(), less_data.end()); + const CData initial(initial_data.begin(), initial_data.end()); + + CHECK((less >= initial) == (less_data >= initial_data)); + + const CData greater(greater_data.begin(), greater_data.end()); + + CHECK((greater >= initial) == (greater_data >= initial_data)); + + const CData shorter(shorter_data.begin(), shorter_data.end()); + + CHECK((shorter >= initial) == (shorter_data >= initial_data)); + CHECK((initial >= shorter) == (initial_data > shorter_data)); + + const CData initial2(initial_data.begin(), initial_data.end()); + CHECK((initial >= initial2) == (initial_data >= initial_data)); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_memcpy_repair) { @@ -977,9 +1780,36 @@ namespace // Modify the original and check that the memcpy'd vector is not the same. std::reverse(data.begin(), data.end()); - is_equal = std::equal(rdata.begin(), - rdata.end(), - data.begin()); + is_equal = std::equal(rdata.begin(), rdata.end(), data.begin()); + + CHECK(!is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_memcpy_repair) + { + CData data(initial_data.begin(), initial_data.end()); + + char buffer[sizeof(CData)]; + + memcpy(&buffer, &data, sizeof(data)); + + CData& rdata(*reinterpret_cast(buffer)); + rdata.repair(); + + // Check that the memcpy'd vector is the same. + CHECK_EQUAL(data.size(), rdata.size()); + CHECK(!rdata.empty()); + CHECK(rdata.full()); + + bool is_equal = std::equal(rdata.begin(), rdata.end(), data.begin()); + + CHECK(is_equal); + + // Modify the original and check that the memcpy'd vector is not the same. + std::reverse(data.begin(), data.end()); + + is_equal = std::equal(rdata.begin(), rdata.end(), data.begin()); CHECK(!is_equal); } From 90bc895cce06470e2b3f032644f0316dbfd75e04 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 4 Jul 2018 20:26:34 +0100 Subject: [PATCH 19/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/private/ivectorpointer.h # include/etl/version.h # src/private/pvoidvector.cpp # support/Release notes.txt # test/test_vector_pointer.cpp --- include/etl/private/ivectorpointer.h | 24 ++++++++++++------------ include/etl/private/pvoidvector.h | 12 ++++++------ include/etl/version.h | 4 ++-- src/private/pvoidvector.cpp | 10 +++++----- support/Release notes.txt | 4 ++++ test/test_vector_pointer.cpp | 28 ++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 25 deletions(-) diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index 9ef26977..4a24a186 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -50,12 +50,12 @@ namespace etl public: typedef T* value_type; - typedef T*& reference; - typedef const T* const & const_reference; - typedef T** pointer; - typedef const T* const * const_pointer; - typedef T** iterator; - typedef const T* const * const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* pointer; + 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 size_t size_type; @@ -452,12 +452,12 @@ namespace etl public: typedef const T* value_type; - typedef const T*& reference; - typedef const T* const & const_reference; - typedef const T** pointer; - typedef const T* const * const_pointer; - typedef const T** iterator; - typedef const T* const * const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* pointer; + 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 size_t size_type; diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 5997b2e6..b6f8e61a 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -61,12 +61,12 @@ namespace etl public: typedef void* value_type; - typedef void*& reference; - typedef const void*& const_reference; - typedef void** pointer; - typedef const void** const_pointer; - typedef void** iterator; - typedef const void** const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* pointer; + 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 size_t size_type; diff --git a/include/etl/version.h b/include/etl/version.h index 9043d8f3..5c7e5d03 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.13.0" +#define ETL_VERSION "11.13.1" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 13 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #endif diff --git a/src/private/pvoidvector.cpp b/src/private/pvoidvector.cpp index 527abfbe..814abbd4 100644 --- a/src/private/pvoidvector.cpp +++ b/src/private/pvoidvector.cpp @@ -181,7 +181,7 @@ void etl::pvoidvector::resize(size_t new_size, etl::pvoidvector::value_type valu //********************************************************************* etl::pvoidvector::reference etl::pvoidvector::operator [](size_t i) { - return p_buffer[i]; + return reference(p_buffer[i]); } //********************************************************************* @@ -203,7 +203,7 @@ etl::pvoidvector::const_reference etl::pvoidvector::operator [](size_t i) const etl::pvoidvector::reference etl::pvoidvector::at(size_t i) { ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds)); - return p_buffer[i]; + return reference(p_buffer[i]); } //********************************************************************* @@ -224,7 +224,7 @@ etl::pvoidvector::const_reference etl::pvoidvector::at(size_t i) const //********************************************************************* etl::pvoidvector::reference etl::pvoidvector::front() { - return p_buffer[0]; + return reference(p_buffer[0]); } //********************************************************************* @@ -242,7 +242,7 @@ etl::pvoidvector::const_reference etl::pvoidvector::front() const //********************************************************************* etl::pvoidvector::reference etl::pvoidvector::back() { - return *(p_end - 1); + return reference(*(p_end - 1)); } //********************************************************************* @@ -260,7 +260,7 @@ etl::pvoidvector::const_reference etl::pvoidvector::back() const //********************************************************************* etl::pvoidvector::pointer etl::pvoidvector::data() { - return p_buffer; + return pointer(p_buffer); } //********************************************************************* diff --git a/support/Release notes.txt b/support/Release notes.txt index 315fa97c..94460ab2 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.13.1 +Fixed vector of pointer typedefs + =============================================================================== 11.13.0 Added specialisation for vector diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index eeac0e8c..d35cc045 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -1813,5 +1813,33 @@ namespace CHECK(!is_equal); } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_ivector_of_pointer_to_pointer) + { + int i1 = 1; + etl::vector consttest; + consttest.push_back(&i1); + const etl::ivector& ct = consttest; + + int* i2 = ct[0]; + + CHECK(i1 == *i2); + CHECK(&i1 == i2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_ivector_of_pointer_to_const_pointer) + { + int i1 = 1; + etl::vector consttest; + consttest.push_back(&i1); + const etl::ivector& ct = consttest; + + const int* i2 = ct[0]; + + CHECK(i1 == *i2); + CHECK(&i1 == i2); + } }; } From f541da6bcb49473e02a5e31daf73c37ec98d06ff Mon Sep 17 00:00:00 2001 From: kiciek Date: Thu, 12 Jul 2018 22:28:05 +0200 Subject: [PATCH 20/28] Restrict destructors (#80) * hide observable destructor * hide fsm_state destructor, get_fsm_context in 0 specialisation made protected * Update observer.h Changed protected destructor in observble to use C++03 syntax. * Update fsm.h Minor formatting changes * Update fsm_generator.h Minor format changes --- include/etl/fsm.h | 70 +++++++++++++++++++++++++++++++++++++ include/etl/fsm_generator.h | 14 ++++++++ include/etl/observer.h | 6 ++++ 3 files changed, 90 insertions(+) diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 3a837f39..8ba4b972 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -390,6 +390,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -451,6 +455,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -511,6 +519,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -570,6 +582,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -627,6 +643,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -683,6 +703,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -738,6 +762,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -792,6 +820,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -844,6 +876,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -895,6 +931,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -945,6 +985,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -994,6 +1038,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -1041,6 +1089,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -1087,6 +1139,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -1132,6 +1188,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -1176,6 +1236,10 @@ namespace etl } protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { @@ -1216,6 +1280,12 @@ namespace etl : ifsm_state(STATE_ID) { } + + protected: + + ~fsm_state() + { + } inline TContext& get_fsm_context() const { diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index a937542e..176fa60d 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -411,6 +411,10 @@ namespace etl cog.outl("") cog.outl("protected:") cog.outl("") + cog.outl(" ~fsm_state()") + cog.outl(" {") + cog.outl(" }") + cog.outl("") cog.outl(" inline TContext& get_fsm_context() const") cog.outl(" {") cog.outl(" return static_cast(ifsm_state::get_fsm_context());") @@ -484,6 +488,10 @@ namespace etl cog.outl("") cog.outl("protected:") cog.outl("") + cog.outl(" ~fsm_state()") + cog.outl(" {") + cog.outl(" }") + cog.outl("") cog.outl(" inline TContext& get_fsm_context() const") cog.outl(" {") cog.outl(" return static_cast(ifsm_state::get_fsm_context());") @@ -538,6 +546,12 @@ namespace etl cog.outl(" {") cog.outl(" }") cog.outl("") + cog.outl("protected:") + cog.outl("") + cog.outl(" ~fsm_state()") + cog.outl(" {") + cog.outl(" }") + cog.outl("") cog.outl(" inline TContext& get_fsm_context() const") cog.outl(" {") cog.outl(" return static_cast(ifsm_state::get_fsm_context());") diff --git a/include/etl/observer.h b/include/etl/observer.h index b9c0dbfa..1cc9786a 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -179,6 +179,12 @@ namespace etl } } + protected: + + ~observable() + { + } + private: /// The list of observers. From 902ab7d0529d892ea1421338f2db43ee7b14e1b4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 12 Jul 2018 21:42:06 +0100 Subject: [PATCH 21/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # support/Release notes.txt --- include/etl/observer.h | 8 +++++++- include/etl/version.h | 4 ++-- support/Release notes.txt | 5 +++++ test/test_observer.cpp | 6 +++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/etl/observer.h b/include/etl/observer.h index 1cc9786a..1cd9b3f0 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -133,8 +133,9 @@ namespace etl //***************************************************************** /// Remove a particular observer from the list. ///\param observer A reference to the observer. + ///\return true if the observer was removed, false if not. //***************************************************************** - void remove_observer(TObserver& observer) + bool remove_observer(TObserver& observer) { // See if we have it in our list. typename Observer_List::iterator i_observer = std::find(observer_list.begin(), @@ -146,6 +147,11 @@ namespace etl { // Erase it. observer_list.erase(i_observer); + return true; + } + else + { + return false; } } diff --git a/include/etl/version.h b/include/etl/version.h index 5c7e5d03..caaedbcf 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.13.1" +#define ETL_VERSION "11.13.2" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 13 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 94460ab2..e9202643 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +11.13.2 +Protected destructor for some FSM classes. +Observer's remove_observer returns bool. + =============================================================================== 11.13.1 Fixed vector of pointer typedefs diff --git a/test/test_observer.cpp b/test/test_observer.cpp index f6efc6b4..b23a1359 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -424,7 +424,11 @@ namespace CHECK_THROW(observable.add_observer(observer5), etl::observer_list_full); - observable.remove_observer(observer3); + CHECK(observable.remove_observer(observer3)); + CHECK_EQUAL(size_t(3), observable.number_of_observers()); + + // Try again. + CHECK(!observable.remove_observer(observer3)); CHECK_EQUAL(size_t(3), observable.number_of_observers()); observable.clear_observers(); From 1f0294cb62ddadb7fdb9edcbd917e702fda64979 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 23 Jul 2018 00:04:28 +0100 Subject: [PATCH 22/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/private/pvoidvector.h --- include/etl/algorithm.h | 43 +- include/etl/array.h | 28 +- include/etl/array_view.h | 7 +- include/etl/array_wrapper.h | 22 +- include/etl/atomic.h | 2 +- include/etl/atomic/atomic_gcc_sync.h | 16 +- include/etl/atomic/atomic_std.h | 16 +- include/etl/basic_string.h | 8 +- include/etl/binary.h | 4 +- include/etl/bitset.h | 6 +- include/etl/callback_timer.h | 2 +- include/etl/char_traits.h | 5 +- include/etl/compare.h | 4 +- include/etl/container.h | 3 +- include/etl/crc16.h | 3 +- include/etl/crc16_ccitt.h | 3 +- include/etl/crc16_kermit.h | 3 +- include/etl/crc32.h | 3 +- include/etl/crc32_c.h | 3 +- include/etl/crc64_ecma.h | 3 +- include/etl/crc8_ccitt.h | 4 +- include/etl/cstring.h | 4 +- include/etl/cyclic_value.h | 4 +- include/etl/deque.h | 10 +- include/etl/fixed_iterator.h | 4 +- include/etl/flat_map.h | 4 +- include/etl/flat_multimap.h | 4 +- include/etl/flat_multiset.h | 4 +- include/etl/flat_set.h | 4 +- include/etl/forward_list.h | 12 +- include/etl/ihash.h | 4 +- include/etl/intrusive_forward_list.h | 7 +- include/etl/intrusive_links.h | 3 +- include/etl/intrusive_list.h | 7 +- include/etl/io_port.h | 3 +- include/etl/iterator.h | 5 +- include/etl/jenkins.h | 3 +- include/etl/list.h | 12 +- include/etl/map.h | 13 +- include/etl/memory.h | 5 +- include/etl/message_bus.h | 2 +- include/etl/message_timer.h | 2 +- include/etl/multimap.h | 12 +- include/etl/multiset.h | 12 +- include/etl/mutex.h | 2 +- include/etl/observer.h | 2 +- include/etl/platform.h | 1 + include/etl/pool.h | 14 +- include/etl/priority_queue.h | 6 +- include/etl/private/pvoidvector.h | 6 +- include/etl/profiles/arduino_arm.h | 2 - include/etl/profiles/armv5.h | 2 - .../etl/profiles/armv5_no_stl.h | 51 +- include/etl/profiles/armv6.h | 2 - include/etl/profiles/armv6_no_stl.h | 49 ++ include/etl/profiles/cpp03.h | 2 - include/etl/profiles/cpp03_no_stl.h | 49 ++ include/etl/profiles/cpp11.h | 2 - include/etl/profiles/cpp11_no_stl.h | 49 ++ include/etl/profiles/cpp14.h | 2 - include/etl/profiles/cpp14_no_stl.h | 49 ++ include/etl/profiles/gcc_generic.h | 6 +- include/etl/profiles/gcc_linux_x86.h | 6 +- include/etl/profiles/gcc_windows_x86.h | 6 +- include/etl/profiles/msvc_x86.h | 6 +- include/etl/profiles/segger_gcc_stlport.h | 6 +- include/etl/profiles/ticc.h | 2 - include/etl/reference_flat_multiset.h | 10 +- include/etl/reference_flat_set.h | 10 +- include/etl/set.h | 11 +- include/etl/stack.h | 4 +- include/etl/stl/algorithm.h | 42 + include/etl/stl/alternate/algorithm.h | 626 ++++++++++++++ include/etl/stl/alternate/functional.h | 54 ++ include/etl/stl/alternate/iterator.h | 347 ++++++++ include/etl/stl/alternate/limits.h | 533 ++++++++++++ include/etl/stl/alternate/utility.h | 140 ++++ include/etl/stl/functional.h | 13 + include/etl/stl/iterator.h | 43 + include/etl/stl/limits.h | 42 + include/etl/stl/utility.h | 42 + include/etl/string_view.h | 4 +- include/etl/type_traits.h | 6 +- include/etl/type_traits_generator.h | 6 +- include/etl/u16string.h | 4 +- include/etl/u32string.h | 4 +- include/etl/unordered_map.h | 11 +- include/etl/unordered_multimap.h | 11 +- include/etl/unordered_multiset.h | 11 +- include/etl/unordered_set.h | 11 +- include/etl/variant_pool.h | 6 +- include/etl/variant_pool_generator.h | 5 +- include/etl/vector.h | 13 +- include/etl/wstring.h | 4 +- test/CMakeLists.txt | 2 +- test/codeblocks/ETL.cbp | 14 + test/etl_profile.h | 2 + test/test_algorithm.cpp | 42 + test/test_atomic_std.cpp | 4 +- test/test_fsm.cpp | 4 +- test/test_no_stl_algorithm.cpp | 581 +++++++++++++ test/test_no_stl_functional.cpp | 78 ++ test/test_no_stl_limits.cpp | 762 ++++++++++++++++++ test/test_no_stl_utility.cpp | 142 ++++ test/vs2017/etl.vcxproj | 20 + test/vs2017/etl.vcxproj.filters | 72 +- 106 files changed, 4113 insertions(+), 273 deletions(-) rename src/profiles/etl_profile.h => include/etl/profiles/armv5_no_stl.h (61%) create mode 100644 include/etl/profiles/armv6_no_stl.h create mode 100644 include/etl/profiles/cpp03_no_stl.h create mode 100644 include/etl/profiles/cpp11_no_stl.h create mode 100644 include/etl/profiles/cpp14_no_stl.h create mode 100644 include/etl/stl/algorithm.h create mode 100644 include/etl/stl/alternate/algorithm.h create mode 100644 include/etl/stl/alternate/functional.h create mode 100644 include/etl/stl/alternate/iterator.h create mode 100644 include/etl/stl/alternate/limits.h create mode 100644 include/etl/stl/alternate/utility.h create mode 100644 include/etl/stl/functional.h create mode 100644 include/etl/stl/iterator.h create mode 100644 include/etl/stl/limits.h create mode 100644 include/etl/stl/utility.h create mode 100644 test/test_no_stl_algorithm.cpp create mode 100644 test/test_no_stl_functional.cpp create mode 100644 test/test_no_stl_limits.cpp create mode 100644 test/test_no_stl_utility.cpp diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 67917e26..a45f66cd 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -36,11 +36,11 @@ SOFTWARE. /// Additional new variants of certain algorithms. ///\ingroup utilities -#include -#include -#include -#include -#include +#include "stl/algorithm.h" +#include "stl/utility.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include #include "platform.h" @@ -1113,6 +1113,39 @@ namespace etl return std::pair(destination_true, destination_false); } + + //*************************************************************************** + /// Sorts the elements using shell sort. + /// Uses users defined comparison. + ///\ingroup algorithm + //*************************************************************************** + template ::value_type> > + void sort(TIterator first, TIterator last, TCompare compare = TCompare()) + { + typedef typename std::iterator_traits::difference_type difference_t; + + difference_t n = std::distance(first, last); + + for (difference_t i = n / 2; i > 0; i /= 2) + { + for (difference_t j = i; j < n; ++j) + { + for (difference_t k = j - i; k >= 0; k -= i) + { + TIterator itr1 = first; + TIterator itr2 = first; + + std::advance(itr1, k); + std::advance(itr2, k + i); + + if (compare(*itr2, *itr1)) + { + std::iter_swap(itr1, itr2); + } + } + } + } + } } #endif diff --git a/include/etl/array.h b/include/etl/array.h index 05393422..2c0e854d 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -31,12 +31,14 @@ SOFTWARE. #ifndef ETL_ARRAY_INCLUDED #define ETL_ARRAY_INCLUDED -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "exception.h" #include "type_traits.h" #include "parameter_type.h" @@ -97,8 +99,8 @@ namespace etl }; typedef T value_type; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T& reference; typedef const T& const_reference; typedef T* pointer; @@ -569,7 +571,7 @@ namespace etl ///\param rhs The second array. ///\return true if the arrays are equal, otherwise false //************************************************************************* - template + template bool operator ==(const etl::array& lhs, const etl::array& rhs) { return std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()); @@ -581,7 +583,7 @@ namespace etl ///\param rhs The second array. ///\return true if the arrays are not equal, otherwise false //************************************************************************* - template + template bool operator !=(const etl::array& lhs, const etl::array& rhs) { return !(lhs == rhs); @@ -593,7 +595,7 @@ namespace etl ///\param rhs The second array. ///\return true if the first array is lexicographically less than the second, otherwise false //************************************************************************* - template + template bool operator <(const etl::array& lhs, const etl::array& rhs) { return std::lexicographical_compare(lhs.cbegin(), @@ -608,7 +610,7 @@ namespace etl ///\param rhs The second array. ///\return true if the first array is lexicographically less than or equal to the second, otherwise false //************************************************************************* - template + template bool operator <=(const etl::array& lhs, const etl::array& rhs) { return !(lhs > rhs); @@ -619,7 +621,7 @@ namespace etl ///\param lhs The first array. ///\param rhs The second array. ///\return true if the first array is lexicographically greater than the second, otherwise false - template + template //************************************************************************* bool operator >(const etl::array& lhs, const etl::array& rhs) { @@ -632,7 +634,7 @@ namespace etl ///\param rhs The second array. ///\return true if the first array is lexicographically greater than or equal to the second, otherwise false //************************************************************************* - template + template bool operator >=(const etl::array& lhs, const etl::array& rhs) { return !(lhs < rhs); @@ -646,7 +648,7 @@ namespace etl ///\param a The array. ///\return A reference to the element //************************************************************************* - template + template inline T& get(array& a) { ETL_STATIC_ASSERT(I < MAXN, "Index out of bounds"); @@ -661,7 +663,7 @@ namespace etl ///\param a The array. ///\return A const reference to the element //************************************************************************* - template + template inline const T& get(const array& a) { ETL_STATIC_ASSERT(I < MAXN, "Index out of bounds"); diff --git a/include/etl/array_view.h b/include/etl/array_view.h index b56e21e5..ec46d96c 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -38,8 +38,9 @@ SOFTWARE. #include "exception.h" #include "nullptr.h" #include "hash.h" +#include "algorithm.h" -#include +#include "stl/algorithm.h" ///\defgroup array array /// A wrapper for arrays @@ -100,7 +101,7 @@ namespace etl public: typedef T value_type; - typedef std::size_t size_type; + typedef size_t size_type; typedef T& reference; typedef const T& const_reference; typedef T* pointer; @@ -494,7 +495,7 @@ namespace etl public: typedef T value_type; - typedef std::size_t size_type; + typedef size_t size_type; typedef const T& const_reference; typedef const T* const_pointer; typedef const T* const_iterator; diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index ec840350..caf73404 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -39,7 +39,7 @@ SOFTWARE. #include "container.h" #include "parameter_type.h" -#include +#include "algorithm.h" ///\defgroup array array /// A wrapper for arrays @@ -80,13 +80,13 @@ namespace etl //*************************************************************************** /// Array wrapper. //*************************************************************************** - template + template class array_wrapper { public: typedef T value_type; - typedef std::size_t size_type; + typedef size_t size_type; typedef T& reference; typedef const T& const_reference; typedef T* pointer; @@ -330,7 +330,7 @@ namespace etl //************************************************************************* /// Equality for array wrappers. //************************************************************************* - template + template bool operator == (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -340,7 +340,7 @@ namespace etl //************************************************************************* /// Inequality for array wrapper. //************************************************************************* - template + template bool operator != (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -350,7 +350,7 @@ namespace etl //************************************************************************* /// Less-than for array wrapper. //************************************************************************* - template + template bool operator < (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -360,7 +360,7 @@ namespace etl //************************************************************************* /// Greater-than for array wrapper. //************************************************************************* - template + template bool operator > (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -370,7 +370,7 @@ namespace etl //************************************************************************* /// Less-than-equal for array wrapper. //************************************************************************* - template + template bool operator <= (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -380,7 +380,7 @@ namespace etl //************************************************************************* /// Greater-than-equal for array wrapper. //************************************************************************* - template + template bool operator >= (const etl::array_wrapper& lhs, const etl::array_wrapper& rhs) { @@ -391,7 +391,7 @@ namespace etl /// Hash function. //************************************************************************* #if ETL_8BIT_SUPPORT - template + template struct hash > { size_t operator()(const etl::array_wrapper& aw) const @@ -406,7 +406,7 @@ namespace etl //************************************************************************* /// Swap. //************************************************************************* -template +template void swap(etl::array_wrapper& lhs, etl::array_wrapper& rhs) { diff --git a/include/etl/atomic.h b/include/etl/atomic.h index 166c3e0b..5d247356 100644 --- a/include/etl/atomic.h +++ b/include/etl/atomic.h @@ -31,7 +31,7 @@ SOFTWARE. #include "platform.h" -#if ETL_CPP11_SUPPORTED == 1 +#if ETL_CPP11_SUPPORTED == 1 && !defined(ETL_NO_STL) #include "atomic/atomic_std.h" #define ETL_HAS_ATOMIC 1 #elif defined(ETL_COMPILER_ARM) diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index 2bdcea49..d26005b2 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -507,23 +507,23 @@ namespace etl } // Add - T* operator +=(std::ptrdiff_t v) + T* operator +=(ptrdiff_t v) { return fetch_add(v) + v; } - T* operator +=(std::ptrdiff_t v) volatile + T* operator +=(ptrdiff_t v) volatile { return fetch_add(v) + v; } // Subtract - T* operator -=(std::ptrdiff_t v) + T* operator -=(ptrdiff_t v) { return fetch_sub(v) - v; } - T* operator -=(std::ptrdiff_t v) volatile + T* operator -=(ptrdiff_t v) volatile { return fetch_sub(v) - v; } @@ -573,23 +573,23 @@ namespace etl } // Fetch add - T* fetch_add(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) + T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) { return __sync_fetch_and_add(&value, v); } - T* fetch_add(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile + T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile { return __sync_fetch_and_add(&value, v); } // Fetch subtract - T* fetch_sub(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) + T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) { return __sync_fetch_and_sub(&value, v); } - T* fetch_sub(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile + T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile { return __sync_fetch_and_sub(&value, v); } diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index fe663ff1..eb3cd146 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -407,23 +407,23 @@ namespace etl } // Add - T* operator +=(std::ptrdiff_t v) + T* operator +=(ptrdiff_t v) { return value += v; } - T* operator +=(std::ptrdiff_t v) volatile + T* operator +=(ptrdiff_t v) volatile { return value += v; } // Subtract - T* operator -=(std::ptrdiff_t v) + T* operator -=(ptrdiff_t v) { return value -= v; } - T* operator -=(std::ptrdiff_t v) volatile + T* operator -=(ptrdiff_t v) volatile { return value -= v; } @@ -473,23 +473,23 @@ namespace etl } // Fetch add - T* fetch_add(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) + T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) { return value.fetch_add(v, order); } - T* fetch_add(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile + T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile { return value.fetch_add(v, order); } // Fetch subtract - T* fetch_sub(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) + T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) { return value.fetch_sub(v, order); } - T* fetch_sub(std::ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile + T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile { return value.fetch_sub(v, order); } diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 17ee2480..b87f989b 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -33,12 +33,14 @@ SOFTWARE. #include #include -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "char_traits.h" #include "container.h" #include "alignment.h" diff --git a/include/etl/binary.h b/include/etl/binary.h index cf2a80ef..82bbbaeb 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -35,8 +35,6 @@ SOFTWARE. /// Binary utilities ///\ingroup utilities -#include - #include "platform.h" #include "type_traits.h" #include "integral_limits.h" @@ -47,6 +45,8 @@ SOFTWARE. #include "exception.h" #include "error_handler.h" +#include "stl/limits.h" + #undef ETL_FILE #define ETL_FILE "50" diff --git a/include/etl/bitset.h b/include/etl/bitset.h index ae328129..2b0b6abe 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -31,13 +31,15 @@ SOFTWARE. #ifndef ETL_BITSET_INCLUDED #define ETL_BITSET_INCLUDED -#include -#include #include #include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" + #include "integral_limits.h" #include "algorithm.h" #include "nullptr.h" diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 3a829833..a57f9d5d 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -30,7 +30,7 @@ SOFTWARE. #define ETL_CALLBACK_TIMER_INCLUDED #include -#include +#include "algorithm.h" #include "platform.h" #include "nullptr.h" diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index 25ee662b..ef5d2e74 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -31,12 +31,13 @@ SOFTWARE. #ifndef ETL_CHAR_TRAITS_INCLUDED #define ETL_CHAR_TRAITS_INCLUDED -#include - #include "platform.h" #include "stdint.h" #include "algorithm.h" +#include "stl/algorithm.h" +#include "stl/iterator.h" + //***************************************************************************** ///\defgroup char_traits char_traits /// Character traits diff --git a/include/etl/compare.h b/include/etl/compare.h index fdf864ce..5550dfbf 100644 --- a/include/etl/compare.h +++ b/include/etl/compare.h @@ -31,11 +31,11 @@ SOFTWARE. #ifndef ETL_COMPARE_INCLUDED #define ETL_COMPARE_INCLUDED -#include - #include "platform.h" #include "parameter_type.h" +#include "stl/functional.h" + //***************************************************************************** ///\defgroup compare compare /// Comparisons only using less than operator diff --git a/include/etl/container.h b/include/etl/container.h index 51d66c30..c7cbfe3a 100644 --- a/include/etl/container.h +++ b/include/etl/container.h @@ -32,10 +32,11 @@ SOFTWARE. #define ETL_CONTAINER_INCLUDED #include -#include #include "platform.h" +#include "stl/iterator.h" + ///\defgroup container container ///\ingroup utilities diff --git a/include/etl/crc16.h b/include/etl/crc16.h index 1f535d1d..9fa21d8b 100644 --- a/include/etl/crc16.h +++ b/include/etl/crc16.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC16_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc16_ccitt.h b/include/etl/crc16_ccitt.h index 90ce365e..28ef7054 100644 --- a/include/etl/crc16_ccitt.h +++ b/include/etl/crc16_ccitt.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC16_CCITT_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc16_kermit.h b/include/etl/crc16_kermit.h index 4691c9ab..dffc6ed2 100644 --- a/include/etl/crc16_kermit.h +++ b/include/etl/crc16_kermit.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC16_KERMIT_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc32.h b/include/etl/crc32.h index 35af1545..8f78e429 100644 --- a/include/etl/crc32.h +++ b/include/etl/crc32.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC32_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc32_c.h b/include/etl/crc32_c.h index cd47c145..e24cf45c 100644 --- a/include/etl/crc32_c.h +++ b/include/etl/crc32_c.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC32_C_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc64_ecma.h b/include/etl/crc64_ecma.h index a1532ddc..98bc3c3b 100644 --- a/include/etl/crc64_ecma.h +++ b/include/etl/crc64_ecma.h @@ -32,11 +32,12 @@ SOFTWARE. #define ETL_CRC64_ECMA_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/crc8_ccitt.h b/include/etl/crc8_ccitt.h index 61c3a140..68853a14 100644 --- a/include/etl/crc8_ccitt.h +++ b/include/etl/crc8_ccitt.h @@ -32,11 +32,13 @@ SOFTWARE. #define ETL_CRC8_CCITT_INCLUDED #include -#include #include "platform.h" #include "frame_check_sequence.h" +#include "stl/algorithm.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 567561e9..87ab5d5a 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -35,7 +35,7 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -141,7 +141,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/cyclic_value.h b/include/etl/cyclic_value.h index 9df9efb6..e1fdd12d 100644 --- a/include/etl/cyclic_value.h +++ b/include/etl/cyclic_value.h @@ -37,14 +37,14 @@ SOFTWARE. /// Provides a value that cycles between two limits. /// \ingroup utilities -#include - #include "platform.h" #include "static_assert.h" #include "exception.h" #include "static_assert.h" #include "type_traits.h" +#include "stl/algorithm.h" + namespace etl { //*************************************************************************** diff --git a/include/etl/deque.h b/include/etl/deque.h index ccccff02..a9ed9301 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -33,10 +33,12 @@ SOFTWARE. #include #include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" + #include "container.h" #include "alignment.h" #include "array.h" @@ -48,7 +50,7 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -2066,7 +2068,7 @@ namespace etl this->assign(n, value); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/fixed_iterator.h b/include/etl/fixed_iterator.h index c981320b..e756b734 100644 --- a/include/etl/fixed_iterator.h +++ b/include/etl/fixed_iterator.h @@ -31,10 +31,10 @@ SOFTWARE. #ifndef ETL_FIXED_ITERATOR_INCLUDED #define ETL_FIXED_ITERATOR_INCLUDED -#include - #include "platform.h" +#include "stl/iterator.h" + ///\defgroup iterator Iterator types namespace etl diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index d12f1f0e..d2c78810 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -35,7 +35,7 @@ SOFTWARE. #include "reference_flat_map.h" #include "pool.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -854,7 +854,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 1545eeea..e2b9a8c4 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -35,7 +35,7 @@ SOFTWARE. #include "reference_flat_multimap.h" #include "pool.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -735,7 +735,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 5858c211..023a526a 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -35,7 +35,7 @@ SOFTWARE. #include "reference_flat_multiset.h" #include "pool.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -694,7 +694,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index ab6a4cd2..d4dd28c0 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -35,7 +35,7 @@ SOFTWARE. #include "reference_flat_set.h" #include "pool.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -760,7 +760,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 619547a1..35d3a2d4 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -31,12 +31,14 @@ SOFTWARE. #ifndef ETL_FORWARD_LIST_INCLUDED #define ETL_FORWARD_LIST_INCLUDED -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "pool.h" #include "container.h" #include "exception.h" @@ -46,7 +48,7 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1415,7 +1417,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/ihash.h b/include/etl/ihash.h index e0ccf2b5..8d47a8e1 100644 --- a/include/etl/ihash.h +++ b/include/etl/ihash.h @@ -32,9 +32,11 @@ SOFTWARE. #define ETL_IHASH_INCLUDED #include -#include #include "platform.h" + +#include "stl/utility.h" + #include "exception.h" #include "error_handler.h" diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index bcc24ddd..3f6394c3 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -33,11 +33,12 @@ SOFTWARE. #include "platform.h" +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "private/minmax_push.h" -#include -#include -#include #include #include "platform.h" diff --git a/include/etl/intrusive_links.h b/include/etl/intrusive_links.h index 65353e7b..5a04169f 100644 --- a/include/etl/intrusive_links.h +++ b/include/etl/intrusive_links.h @@ -32,7 +32,6 @@ SOFTWARE. #define ETL_INTRUSIVE_LINKS_INCLUDED #include -#include #include "platform.h" #include "nullptr.h" @@ -40,6 +39,8 @@ SOFTWARE. #include "exception.h" #include "error_handler.h" +#include "stl/utility.h" + #undef ETL_FILE #define ETL_FILE "22" diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 6e4494d0..9c5c2ef0 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -35,9 +35,6 @@ SOFTWARE. #include "private/minmax_push.h" -#include -#include -#include #include #include "platform.h" @@ -49,6 +46,10 @@ SOFTWARE. #include "static_assert.h" #include "algorithm.h" +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #undef ETL_FILE #define ETL_FILE "21" diff --git a/include/etl/io_port.h b/include/etl/io_port.h index 053a1f78..3fc39d00 100644 --- a/include/etl/io_port.h +++ b/include/etl/io_port.h @@ -36,11 +36,12 @@ SOFTWARE. ///\ingroup utilities #include -#include #include "platform.h" #include "nullptr.h" +#include "stl/iterator.h" + namespace etl { //*************************************************************************** diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 3e1e2a0b..b1ebb5cd 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -31,9 +31,10 @@ SOFTWARE. #ifndef ETL_ITERATOR_INCLUDED #define ETL_ITERATOR_INCLUDED -#include - #include "platform.h" + +#include "stl/iterator.h" + #include "type_traits.h" ///\defgroup iterator iterator diff --git a/include/etl/jenkins.h b/include/etl/jenkins.h index 7135b685..2217b775 100644 --- a/include/etl/jenkins.h +++ b/include/etl/jenkins.h @@ -32,7 +32,6 @@ SOFTWARE. #define ETL_JENKINS_INCLUDED #include -#include #include "platform.h" #include "static_assert.h" @@ -41,6 +40,8 @@ SOFTWARE. #include "ihash.h" #include "frame_check_sequence.h" +#include "stl/iterator.h" + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 #endif diff --git a/include/etl/list.h b/include/etl/list.h index 242ac520..a95e9f78 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -31,12 +31,14 @@ SOFTWARE. #ifndef ETL_LIST_INCLUDED #define ETL_LIST_INCLUDED -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "container.h" #include "pool.h" #include "exception.h" @@ -47,7 +49,7 @@ SOFTWARE. #include "parameter_type.h" #include "algorithm.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1655,7 +1657,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/map.h b/include/etl/map.h index de8d73a3..d1eb6d93 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -32,12 +32,13 @@ SOFTWARE. #define ETL_MAP_INCLUDED #include -#include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "container.h" #include "pool.h" #include "exception.h" @@ -47,7 +48,7 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -2063,7 +2064,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* diff --git a/include/etl/memory.h b/include/etl/memory.h index 941b841f..0d06a1f0 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -31,12 +31,13 @@ SOFTWARE. #ifndef ETL_MEMORY_INCLUDED #define ETL_MEMORY_INCLUDED -#include -#include +#include "algorithm.h" #include "platform.h" #include "type_traits.h" +#include "stl/iterator.h" + ///\defgroup memory memory ///\ingroup etl namespace etl diff --git a/include/etl/message_bus.h b/include/etl/message_bus.h index 25046dda..90d9b01f 100644 --- a/include/etl/message_bus.h +++ b/include/etl/message_bus.h @@ -30,7 +30,7 @@ SOFTWARE. #define ETL_MESSAGE_BUS_ #include -#include +#include "algorithm.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index a6051396..1da2f363 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -30,7 +30,7 @@ SOFTWARE. #define ETL_MESSAGE_TIMER_INCLUDED #include -#include +#include "algorithm.h" #include "platform.h" #include "nullptr.h" diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 2653eb88..b03dfdf6 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -32,11 +32,13 @@ SOFTWARE. #define ETL_MULTIMAP_INCLUDED #include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "container.h" #include "pool.h" #include "exception.h" @@ -46,7 +48,7 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1948,7 +1950,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 2cecb26b..5c2b23d9 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -32,11 +32,13 @@ SOFTWARE. #define ETL_MULTISET_INCLUDED #include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + #include "parameter_type.h" #include "container.h" #include "pool.h" @@ -46,7 +48,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1928,7 +1930,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* diff --git a/include/etl/mutex.h b/include/etl/mutex.h index 0fb1ec10..4c0e1562 100644 --- a/include/etl/mutex.h +++ b/include/etl/mutex.h @@ -31,7 +31,7 @@ SOFTWARE. #include "platform.h" -#if ETL_CPP11_SUPPORTED == 1 +#if ETL_CPP11_SUPPORTED == 1 && !defined(ETL_NO_STL) #include "mutex/mutex_std.h" #define ETL_HAS_MUTEX 1 #elif defined(ETL_COMPILER_ARM) diff --git a/include/etl/observer.h b/include/etl/observer.h index 1cd9b3f0..06d07dfc 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -51,7 +51,7 @@ SOFTWARE. ///\ingroup patterns //***************************************************************************** -#include +#include "algorithm.h" #include "platform.h" #include "vector.h" diff --git a/include/etl/platform.h b/include/etl/platform.h index 655f78bb..0034c1cc 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -29,6 +29,7 @@ SOFTWARE. ******************************************************************************/ #include +#include #ifndef ETL_PLATFORM_INCLUDED #define ETL_PLATFORM_INCLUDED diff --git a/include/etl/pool.h b/include/etl/pool.h index 57ad5940..a79f04bf 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -32,6 +32,10 @@ SOFTWARE. #define ETL_POOL_INCLUDED #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" + #include "error_handler.h" #include "alignment.h" #include "array.h" @@ -40,9 +44,7 @@ SOFTWARE. #include "nullptr.h" #include "alignment.h" #include "static_assert.h" - -#include -#include +#include "algorithm.h" #undef ETL_FILE #define ETL_FILE "11" @@ -134,7 +136,7 @@ namespace etl return reinterpret_cast(allocate_item()); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) //************************************************************************* /// 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 @@ -499,7 +501,7 @@ namespace etl return ipool::allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) //************************************************************************* /// 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 @@ -650,7 +652,7 @@ namespace etl return base_t::template allocate(); } -#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) +#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) //************************************************************************* /// 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 diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 54bcd779..6e0474b3 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -32,10 +32,12 @@ SOFTWARE. #define ETL_PRIORITY_QUEUE_INCLUDED #include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/functional.h" + #include "container.h" #include "vector.h" #include "type_traits.h" diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index b6f8e61a..07692a61 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -33,9 +33,6 @@ SOFTWARE. #define ETL_IN_PVOIDVECTOR -#include -#include -#include #include #include "../platform.h" @@ -44,6 +41,9 @@ SOFTWARE. #include "../type_traits.h" #include "../error_handler.h" +#include "../stl/functional.h" +#include "../stl/iterator.h" + #ifdef ETL_COMPILER_GCC #pragma GCC diagnostic ignored "-Wunused-variable" #endif diff --git a/include/etl/profiles/arduino_arm.h b/include/etl/profiles/arduino_arm.h index ca43b901..70ba8b27 100644 --- a/include/etl/profiles/arduino_arm.h +++ b/include/etl/profiles/arduino_arm.h @@ -35,8 +35,6 @@ SOFTWARE. // Arduino //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_ARM #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GCC diff --git a/include/etl/profiles/armv5.h b/include/etl/profiles/armv5.h index cf9d601f..6d8f8746 100644 --- a/include/etl/profiles/armv5.h +++ b/include/etl/profiles/armv5.h @@ -35,8 +35,6 @@ SOFTWARE. // ARM Compiler Version 5 //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_ARM #define ETL_TARGET_OS_NONE #define ETL_COMPILER_ARM diff --git a/src/profiles/etl_profile.h b/include/etl/profiles/armv5_no_stl.h similarity index 61% rename from src/profiles/etl_profile.h rename to include/etl/profiles/armv5_no_stl.h index 45596b1a..d69fcbf6 100644 --- a/src/profiles/etl_profile.h +++ b/include/etl/profiles/armv5_no_stl.h @@ -7,7 +7,7 @@ Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com -Copyright(c) 2017 jwellbelove, scott-eddy +Copyright(c) 2018 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 @@ -27,34 +27,23 @@ 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_PROFILE_H__ -#define __ETL_PROFILE_H__ -#ifdef PROFILE_MSVC - #include "msvc_x86.h" -#elif PROFILE_GCC_GENERIC - #include "gcc_generic.h" -#elif PROFILE_GCC_LINUX_X86 - #include "gcc_linux_x86.h" -#elif PROFILE_GCC_WINDOWS_X86 - #include "gcc_windows_x86.h" -#elif PROFILE_ARM_V5_GENERIC - #include "armv5.h" -#elif PROFILE_ARM_V6_GENERIC - #include "armv6.h" -#elif PROFILE_ARDUINO - #include "arduino_arm.h" -#elif PROFILE_TICC - #include "ticc.h" -#elif PROFILE_CPP03_GENERIC - #include "cpp03.h" -#elif PROFILE_CPP11_GENERIC - #include "cpp11.h" -#elif PROFILE_CPP14_GENERIC - #include "cpp14.h" -#elif PROFILE_CUSTOM - #include "custom_profile.h" -#else - #error Must provide a profile header file when buiding ETL. See https://www.etlcpp.com/setup.html -#endif -#endif // __ETL_PROFILE_H_ +#ifndef ETL_ARMV5_NO_STL_INCLUDED +#define ETL_ARMV5_NO_STL_INCLUDED + +//***************************************************************************** +// ARM Compiler Version 5 +//***************************************************************************** + +#define ETL_TARGET_DEVICE_ARM +#define ETL_TARGET_OS_NONE +#define ETL_COMPILER_ARM +#define ETL_CPP11_SUPPORTED 0 +#define ETL_CPP14_SUPPORTED 0 +#define ETL_CPP17_SUPPORTED 0 +#define ETL_NO_NULLPTR_SUPPORT 1 +#define ETL_NO_LARGE_CHAR_SUPPORT 1 +#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0 +#define ETL_NO_STL + +#endif diff --git a/include/etl/profiles/armv6.h b/include/etl/profiles/armv6.h index 3cafec46..f8f59ad4 100644 --- a/include/etl/profiles/armv6.h +++ b/include/etl/profiles/armv6.h @@ -35,8 +35,6 @@ SOFTWARE. // ARM Compiler Version 6 //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_ARM #define ETL_TARGET_OS_NONE #define ETL_COMPILER_LLVM diff --git a/include/etl/profiles/armv6_no_stl.h b/include/etl/profiles/armv6_no_stl.h new file mode 100644 index 00000000..0c25c3c1 --- /dev/null +++ b/include/etl/profiles/armv6_no_stl.h @@ -0,0 +1,49 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ARMV6_NO_STL_INCLUDED +#define ETL_ARMV6_NO_STL_INCLUDED + +//***************************************************************************** +// ARM Compiler Version 6 +//***************************************************************************** + +#define ETL_TARGET_DEVICE_ARM +#define ETL_TARGET_OS_NONE +#define ETL_COMPILER_LLVM +#define ETL_CPP11_SUPPORTED 1 +#define ETL_CPP14_SUPPORTED 0 +#define ETL_CPP17_SUPPORTED 0 +#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_NO_LARGE_CHAR_SUPPORT 0 +#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1 +#define ETL_NO_STL + +#endif diff --git a/include/etl/profiles/cpp03.h b/include/etl/profiles/cpp03.h index 79379628..391af458 100644 --- a/include/etl/profiles/cpp03.h +++ b/include/etl/profiles/cpp03.h @@ -35,8 +35,6 @@ SOFTWARE. // Generic C++03 //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GENERIC diff --git a/include/etl/profiles/cpp03_no_stl.h b/include/etl/profiles/cpp03_no_stl.h new file mode 100644 index 00000000..3a42a6a1 --- /dev/null +++ b/include/etl/profiles/cpp03_no_stl.h @@ -0,0 +1,49 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_CPP03_NO_STL_INCLUDED +#define ETL_CPP03_NO_STL_INCLUDED + +//***************************************************************************** +// Generic C++03 +//***************************************************************************** + +#define ETL_TARGET_DEVICE_GENERIC +#define ETL_TARGET_OS_NONE +#define ETL_COMPILER_GENERIC +#define ETL_CPP11_SUPPORTED 0 +#define ETL_CPP14_SUPPORTED 0 +#define ETL_CPP17_SUPPORTED 0 +#define ETL_NO_NULLPTR_SUPPORT 1 +#define ETL_NO_LARGE_CHAR_SUPPORT 1 +#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0 +#define ETL_NO_STL + +#endif diff --git a/include/etl/profiles/cpp11.h b/include/etl/profiles/cpp11.h index 3faaa1db..6487ecb3 100644 --- a/include/etl/profiles/cpp11.h +++ b/include/etl/profiles/cpp11.h @@ -35,8 +35,6 @@ SOFTWARE. // Generic C++11 //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GENERIC diff --git a/include/etl/profiles/cpp11_no_stl.h b/include/etl/profiles/cpp11_no_stl.h new file mode 100644 index 00000000..a7255134 --- /dev/null +++ b/include/etl/profiles/cpp11_no_stl.h @@ -0,0 +1,49 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_CPP11_NO_STL_INCLUDED +#define ETL_CPP11_NO_STL_INCLUDED + +//***************************************************************************** +// Generic C++11 +//***************************************************************************** + +#define ETL_TARGET_DEVICE_GENERIC +#define ETL_TARGET_OS_NONE +#define ETL_COMPILER_GENERIC +#define ETL_CPP11_SUPPORTED 1 +#define ETL_CPP14_SUPPORTED 0 +#define ETL_CPP17_SUPPORTED 0 +#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_NO_LARGE_CHAR_SUPPORT 0 +#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0 +#define ETL_NO_STL + +#endif diff --git a/include/etl/profiles/cpp14.h b/include/etl/profiles/cpp14.h index 28bc9988..5f8bf7fd 100644 --- a/include/etl/profiles/cpp14.h +++ b/include/etl/profiles/cpp14.h @@ -35,8 +35,6 @@ SOFTWARE. // Generic C++14 //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GENERIC diff --git a/include/etl/profiles/cpp14_no_stl.h b/include/etl/profiles/cpp14_no_stl.h new file mode 100644 index 00000000..e92acf84 --- /dev/null +++ b/include/etl/profiles/cpp14_no_stl.h @@ -0,0 +1,49 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2017 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_CPP14_NO_STL_INCLUDED +#define ETL_CPP14_NO_STL_INCLUDED + +//***************************************************************************** +// Generic C++14 +//***************************************************************************** + +#define ETL_TARGET_DEVICE_GENERIC +#define ETL_TARGET_OS_NONE +#define ETL_COMPILER_GENERIC +#define ETL_CPP11_SUPPORTED 1 +#define ETL_CPP14_SUPPORTED 1 +#define ETL_CPP17_SUPPORTED 0 +#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_NO_LARGE_CHAR_SUPPORT 0 +#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0 +#define ETL_NO_STL + +#endif diff --git a/include/etl/profiles/gcc_generic.h b/include/etl/profiles/gcc_generic.h index 68a54123..39826014 100644 --- a/include/etl/profiles/gcc_generic.h +++ b/include/etl/profiles/gcc_generic.h @@ -28,15 +28,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_GCC_INCLUDED -#define ETL_GCC_INCLUDED +#ifndef ETL_GCC_GENERIC_INCLUDED +#define ETL_GCC_GENERIC_INCLUDED //***************************************************************************** // GCC //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GCC diff --git a/include/etl/profiles/gcc_linux_x86.h b/include/etl/profiles/gcc_linux_x86.h index 2435658a..c9a3c9cc 100644 --- a/include/etl/profiles/gcc_linux_x86.h +++ b/include/etl/profiles/gcc_linux_x86.h @@ -28,15 +28,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_GCC_INCLUDED -#define ETL_GCC_INCLUDED +#ifndef ETL_GCC_LINUX_X86_INCLUDED +#define ETL_GCC_LINUX_X86_INCLUDED //***************************************************************************** // GCC //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_X86 #define ETL_TARGET_OS_LINUX #define ETL_COMPILER_GCC diff --git a/include/etl/profiles/gcc_windows_x86.h b/include/etl/profiles/gcc_windows_x86.h index 5fa06f48..a5a83349 100644 --- a/include/etl/profiles/gcc_windows_x86.h +++ b/include/etl/profiles/gcc_windows_x86.h @@ -28,15 +28,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_GCC_INCLUDED -#define ETL_GCC_INCLUDED +#ifndef ETL_GCC_WINDOWS_X86_INCLUDED +#define ETL_GCC_WINDOWS_X86_INCLUDED //***************************************************************************** // GCC //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_X86 #define ETL_TARGET_OS_WINDOWS #define ETL_COMPILER_GCC diff --git a/include/etl/profiles/msvc_x86.h b/include/etl/profiles/msvc_x86.h index 37910922..d4286277 100644 --- a/include/etl/profiles/msvc_x86.h +++ b/include/etl/profiles/msvc_x86.h @@ -28,15 +28,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_MSVC_INCLUDED -#define ETL_MSVC_INCLUDED +#ifndef ETL_MSVC_X86_INCLUDED +#define ETL_MSVC_X86_INCLUDED //***************************************************************************** // Microsoft Visual Studio //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_X86 #define ETL_TARGET_OS_WINDOWS #define ETL_COMPILER_MICROSOFT diff --git a/include/etl/profiles/segger_gcc_stlport.h b/include/etl/profiles/segger_gcc_stlport.h index 095f4601..c626bb29 100644 --- a/include/etl/profiles/segger_gcc_stlport.h +++ b/include/etl/profiles/segger_gcc_stlport.h @@ -28,15 +28,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_GCC_INCLUDED -#define ETL_GCC_INCLUDED +#ifndef ETL_SEGGER_GCC_INCLUDED +#define ETL_SEGGER_GCC_INCLUDED //***************************************************************************** // GCC //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_GCC diff --git a/include/etl/profiles/ticc.h b/include/etl/profiles/ticc.h index 11a8b583..72489442 100644 --- a/include/etl/profiles/ticc.h +++ b/include/etl/profiles/ticc.h @@ -35,8 +35,6 @@ SOFTWARE. // Texas Instruments Code Composer //***************************************************************************** -#include - #define ETL_TARGET_DEVICE_GENERIC #define ETL_TARGET_OS_NONE #define ETL_COMPILER_TI diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index 4a502e65..11f89c8f 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -31,13 +31,15 @@ SOFTWARE. #ifndef ETL_REFERENCE_FLAT_MULTISET_INCLUDED #define ETL_REFERENCE_FLAT_MULTISET_INCLUDED -#include -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "type_traits.h" #include "vector.h" #include "pool.h" diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index c7c866b8..bcb5a5df 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -31,13 +31,15 @@ SOFTWARE. #ifndef ETL_REFERENCE_FLAT_SET_INCLUDED #define ETL_REFERENCE_FLAT_SET_INCLUDED -#include -#include -#include -#include #include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "type_traits.h" #include "pool.h" #include "error_handler.h" diff --git a/include/etl/set.h b/include/etl/set.h index a6df4f39..31f0ff7d 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -32,9 +32,6 @@ SOFTWARE. #define ETL_SET_INCLUDED #include -#include -#include -#include #include "platform.h" #include "container.h" @@ -46,7 +43,11 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1986,7 +1987,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* diff --git a/include/etl/stack.h b/include/etl/stack.h index 497390df..e085a231 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -33,9 +33,11 @@ SOFTWARE. #include #include -#include #include "platform.h" + +#include "stl/algorithm.h" + #include "container.h" #include "alignment.h" #include "array.h" diff --git a/include/etl/stl/algorithm.h b/include/etl/stl/algorithm.h new file mode 100644 index 00000000..43c1aaa7 --- /dev/null +++ b/include/etl/stl/algorithm.h @@ -0,0 +1,42 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ALGORITHM_INCLUDED +#define ETL_STL_ALGORITHM_INCLUDED + +#include "../platform.h" + +#if defined(ETL_NO_STL) + #include "alternate/algorithm.h" +#else + #include +#endif + +#endif diff --git a/include/etl/stl/alternate/algorithm.h b/include/etl/stl/alternate/algorithm.h new file mode 100644 index 00000000..74291034 --- /dev/null +++ b/include/etl/stl/alternate/algorithm.h @@ -0,0 +1,626 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ALTERNATE_ALGORITHM_INCLUDED +#define ETL_STL_ALTERNATE_ALGORITHM_INCLUDED + +#include "../../platform.h" + +#include + +#include "../../type_traits.h" + +#include "iterator.h" +#include "functional.h" + +#if defined(ETL_IN_UNIT_TEST) +#define ETLSTD etlstd +namespace etlstd +#else +#define ETLSTD std +namespace std +#endif +{ + //*************************************************************************** + // distance + template + typename etl::enable_if::iterator_category, std::random_access_iterator_tag>::value, + typename std::iterator_traits::difference_type>::type + distance(TIterator first, TIterator last) + { + typename std::iterator_traits::difference_type count = 0; + + while (first != last) + { + ++count; + ++first; + } + + return count; + } + + template + typename etl::enable_if::iterator_category, std::random_access_iterator_tag>::value, + typename std::iterator_traits::difference_type>::type + distance(TIterator first, TIterator last) + { + return last - first; + } + + //*************************************************************************** + // advance + template + typename etl::enable_if::iterator_tag, std::random_access_iterator_tag>::value, void>::type + advance(TIterator itr, TDistance distance) + { + while (distance-- != 0) + { + ++itr; + } + } + + template + typename etl::enable_if::iterator_tag, std::random_access_iterator_tag>::value, void>::type + advance(TIterator itr, TDistance distance) + { + return itr += distance; + } + + //*************************************************************************** + // copy + // Pointer + template + typename etl::enable_if::value && + etl::is_pointer::value && + etl::is_pod::value_type>::value, TIterator2>::type + copy(TIterator1 sb, TIterator1 se, TIterator2 db) + { + typedef typename std::iterator_traits::value_type value_t; + + return TIterator2(memcpy(db, sb, sizeof(value_t) * (se - sb))); + } + + // Other iterator + template + typename etl::enable_if::value || + !etl::is_pointer::value || + !etl::is_pod::value_type>::value, TIterator2>::type + copy(TIterator1 sb, TIterator1 se, TIterator2 db) + { + while (sb != se) + { + *db++ = *sb++; + } + + return db; + } + + //*************************************************************************** + // copy_n + // Pointer + template + typename etl::enable_if::value && + etl::is_pointer::value && + etl::is_pod::value_type>::value, TIterator2>::type + copy_n(TIterator1 sb, TSize count, TIterator2 db) + { + typedef typename std::iterator_traits::value_type value_t; + + return TIterator2(memcpy(db, sb, sizeof(value_t) * count)); + } + + // Other iterator + template + typename etl::enable_if::value || + !etl::is_pointer::value || + !etl::is_pod::value_type>::value, TIterator2>::type + copy_n(TIterator1 sb, TSize count, TIterator2 db) + { + while (count != 0) + { + *db++ = *sb++; + --count; + } + + return db; + } + + //*************************************************************************** + // copy_backward + // Pointer + template + typename etl::enable_if::value && + etl::is_pointer::value && + etl::is_pod::value_type>::value, TIterator2>::type + copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) + { + typedef typename std::iterator_traits::value_type value_t; + + const size_t length = (se - sb); + + return TIterator2(memmove(de - length, sb, sizeof(value_t) * length)); + } + + // Other iterator + template + typename etl::enable_if::value || + !etl::is_pointer::value || + !etl::is_pod::value_type>::value, TIterator2>::type + copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) + { + while (se != sb) + { + *(--de) = *(--se); + } + + return de; + } + + //*************************************************************************** + // lower_bound + template + TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) + { + typedef typename std::iterator_traits::difference_type difference_t; + + difference_t count = std::distance(first, last); + + while (count > 0) + { + TIterator itr = first; + difference_t step = count / 2; + + std::advance(itr, step); + + if (compare(*itr, value)) + { + first = ++itr; + count -= step + 1; + } + else + { + count = step; + } + } + + return first; + } + + template + TIterator lower_bound(TIterator first, TIterator last, const TValue& value) + { + typedef std::less::value_type> compare; + + return ETLSTD::lower_bound(first, last, value, compare()); + } + + //*************************************************************************** + // upper_bound + template + TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) + { + typedef typename std::iterator_traits::difference_type difference_t; + + difference_t count = std::distance(first, last); + + while (count > 0) + { + TIterator itr = first; + difference_t step = count / 2; + + std::advance(itr, step); + + if (!compare(value, *itr)) + { + first = ++itr; + count -= step + 1; + } + else + { + count = step; + } + } + + return first; + } + + template + TIterator upper_bound(TIterator first, TIterator last, const TValue& value) + { + typedef std::less::value_type> compare; + + return ETLSTD::upper_bound(first, last, value, compare()); + } + + //*************************************************************************** + // equal_range + template + std::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare) + { + return std::make_pair(ETLSTD::lower_bound(first, last, value, compare), + ETLSTD::upper_bound(first, last, value, compare)); + } + + template + std::pair equal_range(TIterator first, TIterator last, const TValue& value) + { + typedef std::less::value_type> compare; + + return std::make_pair(ETLSTD::lower_bound(first, last, value, compare()), + ETLSTD::upper_bound(first, last, value, compare())); + } + + //*************************************************************************** + // fill + template + typename etl::enable_if::value || etl::is_same::value) || !etl::is_pointer::value, void>::type + fill(TIterator first, TIterator last, const TValue& value) + { + while (first != last) + { + *first++ = value; + } + } + + template + typename etl::enable_if<(etl::is_same::value || etl::is_same::value) && etl::is_pointer::value, void>::type + fill(TIterator first, TIterator last, const TValue& value) + { + memset(first, value, last - first); + } + + //*************************************************************************** + // 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 std::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 + equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) + { + while (first1 != last1) + { + if (*first1++ != *first2++) + { + return false; + } + } + + return true; + } + + template + 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 std::iterator_traits::value_type value_t; + + return (memcmp(first1, first2, sizeof(value_t) * (last1 - last1)) == 0); + } + + //*************************************************************************** + // lexicographical_compare + template + bool lexicographical_compare(TIterator1 first1, TIterator1 last1, + TIterator2 first2, TIterator2 last2, + TCompare compare) + { + while ((first1 != last1) && (first2 != last2)) + { + if (compare(*first1, *first2)) + { + return true; + } + + if (compare(*first2, *first1)) + { + return false; + } + + ++first1; + ++first2; + } + + return (first1 == last1) && (first2 != last2); + } + + //*************************************************************************** + // lexicographical_compare + template + bool lexicographical_compare(TIterator1 first1, TIterator1 last1, + TIterator2 first2, TIterator2 last2) + { + typedef std::less::value_type> compare; + + return ETLSTD::lexicographical_compare(first1, last1, first2, last2, compare()); + } + + //*************************************************************************** + // min + template + const T& min(const T& a, const T& b, TCompare compare) + { + return (compare(a, b)) ? a : b; + } + + template + const T& min(const T& a, const T& b) + { + typedef std::less compare; + + return ETLSTD::min(a, b, compare()); + } + + //*************************************************************************** + // max + template + const T& max(const T& a, const T& b, TCompare compare) + { + return (compare(a, b)) ? b : a; + } + + template + const T& max(const T& a, const T& b) + { + typedef std::less compare; + + return ETLSTD::max(a, b, compare()); + } + + //*************************************************************************** + // Heap + namespace private_heap + { + // Push Heap Helper + template + void push_heap(TIterator first, TDistance value_index, TDistance top_index, TValue value, TCompare compare) + { + TDistance parent = (value_index - 1) / 2; + + while ((value_index > top_index) && compare(first[parent], value)) + { + first[value_index] = first[parent]; + value_index = parent; + parent = (value_index - 1) / 2; + } + + first[value_index] = value; + } + + // Adjust Heap Helper + template + void adjust_heap(TIterator first, TDistance value_index, TDistance length, TValue value, TCompare compare) + { + TDistance top_index = value_index; + TDistance child2nd = (2 * value_index) + 2; + + while (child2nd < length) + { + if (compare(first[child2nd], first[child2nd - 1])) + { + child2nd--; + } + + first[value_index] = first[child2nd]; + value_index = child2nd; + child2nd = 2 * (child2nd + 1); + } + + if (child2nd == length) + { + first[value_index] = first[child2nd - 1]; + value_index = child2nd - 1; + } + + push_heap(first, value_index, top_index, value, compare); + } + + // Is Heap Helper + template + bool is_heap(const TIterator first, const TDistance n, TCompare compare) + { + TDistance parent = 0; + + for (TDistance child = 1; child < n; ++child) + { + if (compare(first[parent], first[child])) + { + return false; + } + + if ((child & 1) == 0) + { + ++parent; + } + } + + return true; + } + } + + // Pop Heap + template + void pop_heap(TIterator first, TIterator last, TCompare compare) + { + typedef typename std::iterator_traits::value_type value_t; + typedef typename std::iterator_traits::difference_type distance_t; + + value_t value = last[-1]; + last[-1] = first[0]; + + private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), value, compare); + } + + // Pop Heap + template + void pop_heap(TIterator first, TIterator last) + { + typedef std::less::value_type> compare; + + ETLSTD::pop_heap(first, last, compare()); + } + + // Push Heap + template + void push_heap(TIterator first, TIterator last, TCompare compare) + { + typedef typename std::iterator_traits::difference_type difference_t; + typedef typename std::iterator_traits::value_type value_t; + + private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(*(last - 1)), compare); + } + + // Push Heap + template + void push_heap(TIterator first, TIterator last) + { + typedef std::less::value_type> compare; + + ETLSTD::push_heap(first, last, compare()); + } + + // Make Heap + template + void make_heap(TIterator first, TIterator last, TCompare compare) + { + typedef typename std::iterator_traits::difference_type difference_t; + + if ((last - first) < 2) + { + return; + } + + difference_t length = last - first; + difference_t parent = (length - 2) / 2; + + while (true) + { + private_heap::adjust_heap(first, parent, length, *(first + parent), compare); + + if (parent == 0) + { + return; + } + + --parent; + } + } + + // Make Heap + template + void make_heap(TIterator first, TIterator last) + { + typedef std::less::value_type> compare; + + ETLSTD::make_heap(first, last, compare()); + } + + // Is Heap + template + bool is_heap(TIterator first, TIterator last) + { + typedef std::less::value_type> compare; + + return private_heap::is_heap(first, last - first, compare()); + } + + // Is Heap + template + bool is_heap(TIterator first, TIterator last, TCompare compare) + { + return private_heap::is_heap(first, last - first, compare); + } + + // Search + template + TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare) + { + if (search_first == search_last) + { + return first; + } + + while (first != last) + { + TIterator1 itr1 = first; + TIterator2 itr2 = search_first; + + while (compare(*itr1,*itr2)) + { + if (itr2 == search_last) + { + return first; + } + + if (itr1 == last) + { + return last; + } + + ++itr1; + ++itr2; + } + + ++first; + } + + return last; + } + + // Search + template + TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last) + { + typedef std::equal_to::value_type> compare; + + return ETLSTD::search(first, last, search_first, search_last, compare()); + } +} + +#endif + + diff --git a/include/etl/stl/alternate/functional.h b/include/etl/stl/alternate/functional.h new file mode 100644 index 00000000..5dd58506 --- /dev/null +++ b/include/etl/stl/alternate/functional.h @@ -0,0 +1,54 @@ + +#ifndef ETL_STL_ALTERNATE_FUNCTIONAL_INCLUDED +#define ETL_STL_ALTERNATE_FUNCTIONAL_INCLUDED + +#include "../../platform.h" + +#if defined(ETL_IN_UNIT_TEST) +namespace etlstd +#else +namespace std +#endif +{ + //*************************************************************************** + template + struct less + { + ETL_CONSTEXPR bool operator()(const T &lhs, const T &rhs) const + { + return lhs < rhs; + } + }; + + //*************************************************************************** + template + struct greater + { + ETL_CONSTEXPR bool operator()(const T &lhs, const T &rhs) const + { + return lhs > rhs; + } + }; + + //*************************************************************************** + template + struct equal_to + { + ETL_CONSTEXPR bool operator()(const T &lhs, const T &rhs) const + { + return lhs == rhs; + } + }; + + //*************************************************************************** + template + struct not_equal_to + { + ETL_CONSTEXPR bool operator()(const T &lhs, const T &rhs) const + { + return lhs != rhs; + } + }; +} + +#endif \ No newline at end of file diff --git a/include/etl/stl/alternate/iterator.h b/include/etl/stl/alternate/iterator.h new file mode 100644 index 00000000..45ea129a --- /dev/null +++ b/include/etl/stl/alternate/iterator.h @@ -0,0 +1,347 @@ + +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ALTERNATE_ITERATOR_INCLUDED +#define ETL_STL_ALTERNATE_ITERATOR_INCLUDED + +#include "../../platform.h" + +#include +#include "../../type_traits.h" + +#if defined(ETL_IN_UNIT_TEST) +namespace etlstd +#else +namespace std +#endif +{ + //*************************************************************************** + // 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 {}; + struct output_iterator_tag {}; + struct forward_iterator_tag : public input_iterator_tag {}; + struct bidirectional_iterator_tag : public forward_iterator_tag {}; + struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + + //*************************************************************************** + // iterator_traits + template + struct iterator_traits + { + typedef typename TIterator::difference_type difference_type; + typedef typename TIterator::value_type value_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 ; + }; + + 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 ; + }; + + //*************************************************************************** + // advance + template + typename etl::enable_if::iterator_catagory, input_iterator_tag>::value, void>::type + advance(TIterator& itr, TDistance n) + { + while (n--) + { + ++itr; + } + } + + template + typename etl::enable_if::iterator_catagory, output_iterator_tag>::value, void>::type + advance(TIterator& itr, TDistance n) + { + while (n--) + { + ++itr; + } + } + + template + typename etl::enable_if::iterator_catagory, forward_iterator_tag>::value, void>::type + advance(TIterator& itr, TDistance n) + { + while (n--) + { + ++itr; + } + } + + template + typename etl::enable_if::iterator_catagory, bidirectional_iterator_tag>::value, void>::type + advance(TIterator& itr, TDistance n) + { + if (n > 0) + { + while (n--) + { + ++itr; + } + } + else + { + while (n--) + { + --itr; + } + } + } + + template + typename etl::enable_if::iterator_catagory, random_access_iterator_tag>::value, void>::type + advance(TIterator& itr, TDistance n) + { + itr += n; + } + + //*************************************************************************** + // distance + template + typename etl::enable_if::iterator_catagory, random_access_iterator_tag>::value, + typename iterator_traits::difference_type>::type + distance(TIterator first, TIterator last) + { + typename iterator_traits::difference_type d = 0; + + while (first != last) + { + ++d; + } + + return d; + } + + template + typename etl::enable_if::iterator_catagory, random_access_iterator_tag>::value, + typename iterator_traits::difference_type>::type + distance(TIterator first, TIterator last) + { + return last - first; + } + + //*************************************************************************** + // reverse_iterator + template + struct reverse_iterator + { + public: + + typedef typename iterator_traits::difference_type difference_type; + typedef typename iterator_traits::value_type value_type; + typedef typename iterator_traits::pointer pointer; + typedef typename iterator_traits::reference reference; + typedef typename iterator_traits::iterator_category iterator_category; + + reverse_iterator() + { + } + + explicit reverse_iterator(TIterator itr) : current(itr) + { + } + + reverse_iterator(const reverse_iterator& itr) + : current(itr.current) + { + } + + template + reverse_iterator(const reverse_iterator& itr) + : current(itr.base()) + { + } + + 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 + { + return current; + } + + ETL_CONSTEXPR reference operator *() const + { + TIterator temp = current; + --temp; + return *temp; + } + + ETL_CONSTEXPR pointer operator ->() const + { + TIterator temp = current; + --temp; + return &(*temp); + } + + ETL_CONSTEXPR reverse_iterator& operator ++() + { + --current; + return *this; + } + + ETL_CONSTEXPR reverse_iterator operator ++(int) + { + reverse_iterator temp = *this; + --current; + return temp; + } + + ETL_CONSTEXPR reverse_iterator& operator --() + { + ++current; + return *this; + } + + ETL_CONSTEXPR reverse_iterator operator --(int) + { + reverse_iterator temp = *this; + ++current; + return temp; + } + + ETL_CONSTEXPR reverse_iterator operator +(difference_type n) const + { + return reverse_iterator(current - n); + } + + ETL_CONSTEXPR reverse_iterator& operator +=(difference_type n) + { + current -= n; + return *this; + } + + ETL_CONSTEXPR reverse_iterator operator -(difference_type n) const + { + return reverse_iterator(current + n); + } + + ETL_CONSTEXPR reverse_iterator& operator -=(difference_type n) + { + current += n; + return *this; + } + + ETL_CONSTEXPR reference operator [](difference_type n) const + { + return *(*this + n); + } + + protected: + + TIterator current; + }; + + template + inline ETL_CONSTEXPR bool operator <(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return rhs.base() < lhs.base(); + } + + template + inline ETL_CONSTEXPR bool operator !=(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return !(lhs == rhs); + } + + template + inline ETL_CONSTEXPR bool operator >(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return rhs < lhs; + } + + template + inline ETL_CONSTEXPR bool operator <=(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return !(rhs < lhs); + } + + template + inline ETL_CONSTEXPR bool operator >=(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return !(lhs < rhs); + } + + template + inline ETL_CONSTEXPR typename reverse_iterator::difference_type operator -(const reverse_iterator& lhs, const reverse_iterator& rhs) + { + return rhs.base() - lhs.base(); + } + + template + inline ETL_CONSTEXPR reverse_iterator operator +(TDifference n, const reverse_iterator& itr) + { + return itr.operator +(n); + } +} + +#endif diff --git a/include/etl/stl/alternate/limits.h b/include/etl/stl/alternate/limits.h new file mode 100644 index 00000000..b8bf99a4 --- /dev/null +++ b/include/etl/stl/alternate/limits.h @@ -0,0 +1,533 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ALTERNATE_LIMITS_INCLUDED +#define ETL_STL_ALTERNATE_LIMITS_INCLUDED + +#include "../../platform.h" +#include "../../type_traits.h" +#include "../../char_traits.h" + +#include +#include +#include + +#define ETL_LOG2(x) (((x) * 301) / 1000) + +#if defined(ETL_IN_UNIT_TEST) +#define ETLSTD etlstd +namespace etlstd +#else +#define ETLSTD std +namespace std +#endif +{ + template class numeric_limits; + + enum float_round_style + { + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3, + }; + + enum float_denorm_style + { + denorm_indeterminate = -1, + denorm_absent = 0, + denorm_present = 1 + }; + + //*************************************************************************** + // Base for integral types. + template + class etl_integral_type + { + public: + static const bool is_specialized; + + static const int max_digits10; + + static const bool is_integer; + static const bool is_exact; + + static const int radix; + static ETL_CONSTEXPR T epsilon() { return 0; } + static ETL_CONSTEXPR T round_error() { return 0; } + + static const int digits; + static const int digits10; + + static const bool is_signed; + + static const int min_exponent; + static const int min_exponent10; + static const int max_exponent; + static const int max_exponent10; + + 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_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 const bool traps; + static const bool tinyness_before; + static const float_round_style round_style; + }; + + 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; + + //*************************************************************************** + // Base for floating point types. + template + class etl_floating_point_type + { + public: + static const bool is_specialized; + + static const bool is_signed; + static const bool is_integer; + static const bool is_exact; + + static const int radix; + + 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 const bool is_iec559; + static const bool is_bounded; + static const bool is_modulo; + + 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; + }; + + 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; + + //*************************************************************************** + // Default + template + class numeric_limits; + + //*************************************************************************** + // bool + template<> + class numeric_limits + { + public: + + static const bool is_specialized; + + 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 const bool is_signed; + static const bool is_integer; + static const bool is_exact; + + static const int radix; + static const bool epsilon() { return 0; } + static 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 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_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 const bool traps; + static const bool tinyness_before; + static const float_round_style round_style; + }; + + 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; + + //*************************************************************************** + // char + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR char min() { return CHAR_MIN; } + static ETL_CONSTEXPR char max() { return CHAR_MAX; } + static ETL_CONSTEXPR char lowest() { return CHAR_MIN; } + }; + + //*************************************************************************** + // unsigned char + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR unsigned char min() { return 0; } + static ETL_CONSTEXPR unsigned char max() { return UCHAR_MAX; } + static ETL_CONSTEXPR unsigned char lowest() { return 0; } + }; + + //*************************************************************************** + // signed char + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR signed char min() { return SCHAR_MIN; } + static ETL_CONSTEXPR signed char max() { return SCHAR_MAX; } + static ETL_CONSTEXPR signed char lowest() { return SCHAR_MIN; } + }; + + //*************************************************************************** + // char16_t + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR char16_t min() { return 0; } + static ETL_CONSTEXPR char16_t max() { return UINT_LEAST16_MAX; } + static ETL_CONSTEXPR char16_t lowest() { return 0; } + }; + + //*************************************************************************** + // char32_t + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR char32_t min() { return 0; } + static ETL_CONSTEXPR char32_t max() { return UINT_LEAST32_MAX; } + static ETL_CONSTEXPR char32_t lowest() { return 0; } + }; + + //*************************************************************************** + // wchar_t + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR wchar_t min() { return WCHAR_MIN; } + static ETL_CONSTEXPR wchar_t max() { return WCHAR_MAX; } + static ETL_CONSTEXPR wchar_t lowest() { return WCHAR_MIN; } + }; + + //*************************************************************************** + // short + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR short min() { return SHRT_MIN; } + static ETL_CONSTEXPR short max() { return SHRT_MAX; } + static ETL_CONSTEXPR short lowest() { return SHRT_MIN; } + }; + + //*************************************************************************** + // unsigned short + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR unsigned short min() { return 0; } + static ETL_CONSTEXPR unsigned short max() { return USHRT_MAX; } + static ETL_CONSTEXPR unsigned short lowest() { return 0; } + }; + + //*************************************************************************** + // int + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR int min() { return INT_MIN; } + static ETL_CONSTEXPR int max() { return INT_MAX; } + static ETL_CONSTEXPR int lowest() { return INT_MIN; } + }; + + //*************************************************************************** + // unsigned int + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR unsigned int min() { return 0; } + static ETL_CONSTEXPR unsigned int max() { return UINT_MAX; } + static ETL_CONSTEXPR unsigned int lowest() { return 0; } + }; + + //*************************************************************************** + // long + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR long min() { return LONG_MIN; } + static ETL_CONSTEXPR long max() { return LONG_MAX; } + static ETL_CONSTEXPR long lowest() { return LONG_MIN; } + }; + + //*************************************************************************** + // unsigned long + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR unsigned long min() { return 0; } + static ETL_CONSTEXPR unsigned long max() { return ULONG_MAX; } + static ETL_CONSTEXPR unsigned long lowest() { return 0; } + }; + + //*************************************************************************** + // long long + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR long long min() { return LLONG_MIN; } + static ETL_CONSTEXPR long long max() { return LLONG_MAX; } + static ETL_CONSTEXPR long long lowest() { return LLONG_MIN; } + }; + + //*************************************************************************** + // unsigned long long + template<> + class numeric_limits : public etl_integral_type + { + public: + + static ETL_CONSTEXPR unsigned long long min() { return 0; } + static ETL_CONSTEXPR unsigned long long max() { return ULLONG_MAX; } + static ETL_CONSTEXPR unsigned long long lowest() { return 0; } + }; + + //*************************************************************************** + // float + template<> + class numeric_limits : public etl_floating_point_type + { + public: + + static ETL_CONSTEXPR float min() { return FLT_MIN; } + static ETL_CONSTEXPR float max() { return FLT_MAX; } + static ETL_CONSTEXPR float lowest() { return -FLT_MAX; } + 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 const int min_exponent; + static const int min_exponent10; + static const int max_exponent; + static const int max_exponent10; + }; + + 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; + + //*************************************************************************** + // double + template<> + class numeric_limits : public etl_floating_point_type + { + public: + + static ETL_CONSTEXPR double min() { return DBL_MIN; } + static ETL_CONSTEXPR double max() { return DBL_MAX; } + static ETL_CONSTEXPR double lowest() { return -DBL_MAX; } + 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 const int min_exponent; + static const int min_exponent10; + static const int max_exponent; + static const int max_exponent10; + }; + + 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; + + //*************************************************************************** + // long double + template<> + class numeric_limits : public etl_floating_point_type + { + public: + + static ETL_CONSTEXPR long double min() { return LDBL_MIN; } + static ETL_CONSTEXPR long double max() { return LDBL_MAX; } + static ETL_CONSTEXPR long double lowest() { return -LDBL_MAX; } + 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 const int min_exponent; + static const int min_exponent10; + static const int max_exponent; + static const int max_exponent10; + }; + + 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; +} + +#endif diff --git a/include/etl/stl/alternate/utility.h b/include/etl/stl/alternate/utility.h new file mode 100644 index 00000000..4fe77726 --- /dev/null +++ b/include/etl/stl/alternate/utility.h @@ -0,0 +1,140 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ALTERNATE_UTILITY_INCLUDED +#define ETL_STL_ALTERNATE_UTILITY_INCLUDED + +#include "../../platform.h" +#include "algorithm.h" + +#if defined(ETL_IN_UNIT_TEST) +#define ETLSTD etlstd +namespace etlstd +#else +#define ETLSTD std +namespace std +#endif +{ + //****************************************************************************** + template + struct pair + { + typedef T1 first_type; + typedef T2 second_type; + + T1 first; + T2 second; + + pair() + : first(T1()), + second(T2()) + { + } + + pair(const T1& a, const T2& b) + : first(a), + second(b) + { + } + + template + pair(const pair& other) + : first(other.first), + second(other.second) + { + } + + pair(const pair& other) + : first(other.first), + second(other.second) + { + } + + void swap(pair& other) + { + ETLSTD::swap(first, other.first); + ETLSTD::swap(second, other.second); + } + }; + + //****************************************************************************** + template + inline pair make_pair(T1 a, T2 b) + { + return pair(a, b); + } + + //****************************************************************************** + template + inline void swap(pair& a, pair& b) + { + a.swap(b); + } + + //****************************************************************************** + template + inline bool operator ==(const pair& a, const pair& b) + { + return (a.first == b.first) && (a.second == b.second); + } + + template + inline bool operator !=(const pair& a, const pair& b) + { + return !(a == b); + } + + template + inline bool operator <(const pair& a, const pair& b) + { + return (a.first < b.first) || + (!(b.first < a.first) && (a.second < b.second)); + } + + template + inline bool operator >(const pair& a, const pair& b) + { + return (b < a); + } + + template + inline bool operator <=(const pair& a, const pair& b) + { + return !(b < a); + } + + template + inline bool operator >=(const pair& a, const pair& b) + { + return !(a < b); + } +} + +#endif diff --git a/include/etl/stl/functional.h b/include/etl/stl/functional.h new file mode 100644 index 00000000..f3fd0034 --- /dev/null +++ b/include/etl/stl/functional.h @@ -0,0 +1,13 @@ + +#ifndef ETL_STL_FUNCTIONAL_INCLUDED +#define ETL_STL_FUNCTIONAL_INCLUDED + +#include "../platform.h" + +#if defined(ETL_NO_STL) + #include "alternate/functional.h" +#else + #include +#endif + +#endif diff --git a/include/etl/stl/iterator.h b/include/etl/stl/iterator.h new file mode 100644 index 00000000..91299a26 --- /dev/null +++ b/include/etl/stl/iterator.h @@ -0,0 +1,43 @@ + +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_ITERATOR_INCLUDED +#define ETL_STL_ITERATOR_INCLUDED + +#include "../platform.h" + +#if defined(ETL_NO_STL) + #include "alternate/iterator.h" +#else + #include +#endif + +#endif \ No newline at end of file diff --git a/include/etl/stl/limits.h b/include/etl/stl/limits.h new file mode 100644 index 00000000..6a0ce1d4 --- /dev/null +++ b/include/etl/stl/limits.h @@ -0,0 +1,42 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_LIMITS_INCLUDED +#define ETL_STL_LIMITS_INCLUDED + +#include "../platform.h" + +#if defined(ETL_NO_STL) + #include "alternate/limits.h" +#else + #include +#endif + +#endif diff --git a/include/etl/stl/utility.h b/include/etl/stl/utility.h new file mode 100644 index 00000000..24a5990f --- /dev/null +++ b/include/etl/stl/utility.h @@ -0,0 +1,42 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_UTILITY_INCLUDED +#define ETL_STL_UTILITY_INCLUDED + +#include "../platform.h" + +#if defined(ETL_NO_STL) + #include "alternate/utility.h" +#else + #include +#endif + +#endif diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 5402cda6..10240fed 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -40,7 +40,7 @@ SOFTWARE. #include "integral_limits.h" #include "hash.h" -#include +#include "algorithm.h" ///\defgroup array array /// A wrapper for arrays @@ -104,7 +104,7 @@ namespace etl typedef T value_type; typedef TTraits traits_type; - typedef std::size_t size_type; + typedef size_t size_type; typedef const T& const_reference; typedef const T* const_pointer; typedef const T* const_iterator; diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index f0b23bfa..ee01e614 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -60,7 +60,7 @@ SOFTWARE. #include "nullptr.h" #include "static_assert.h" -#if (ETL_CPP11_SUPPORTED) +#if (ETL_CPP11_SUPPORTED) && !defined(ETL_NO_STL) #include #endif @@ -269,14 +269,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) && !defined(ETL_NO_STL) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) && !defined(ETL_NO_STL) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {}; diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index 61df9313..183d74ca 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -72,7 +72,7 @@ cog.outl("//******************************************************************** #include "nullptr.h" #include "static_assert.h" -#if (ETL_CPP11_SUPPORTED) +#if (ETL_CPP11_SUPPORTED) && !defined(ETL_NO_STL) #include #endif @@ -281,14 +281,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO) && !defined(ETL_STLPORT)) && !defined(ETL_IN_UNIT_TEST) && !defined(ETL_NO_STL) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_STLPORT) && !defined(ETL_IN_UNIT_TEST) && !defined(ETL_NO_STL) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {}; diff --git a/include/etl/u16string.h b/include/etl/u16string.h index e4b8c1af..4dd9b990 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -35,7 +35,7 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -145,7 +145,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 7a325634..3edc3465 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -35,7 +35,7 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -145,7 +145,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 0f757b0e..5dc63314 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -32,13 +32,14 @@ SOFTWARE. #define ETL_UNORDERED_MAP_INCLUDED #include -#include -#include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "container.h" #include "pool.h" #include "array.h" diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 25257d39..4db58e5a 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -32,13 +32,14 @@ SOFTWARE. #define ETL_UNORDERED_MULTIMAP_INCLUDED #include -#include -#include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "container.h" #include "pool.h" #include "vector.h" diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 11cbc07a..8e3bcd29 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -32,13 +32,14 @@ SOFTWARE. #define ETL_UNORDERED_MULTISET_INCLUDED #include -#include -#include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "container.h" #include "pool.h" #include "vector.h" diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 94473567..b1541ee5 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -32,13 +32,14 @@ SOFTWARE. #define ETL_UNORDERED_SET_INCLUDED #include -#include -#include -#include -#include -#include #include "platform.h" + +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" +#include "stl/utility.h" + #include "container.h" #include "pool.h" #include "vector.h" diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index 1c033ce5..068d0d3a 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -52,9 +52,11 @@ SOFTWARE. #define ETL_VARIANT_POOL_INCLUDED #include -#include #include "platform.h" + +#include "stl/utility.h" + #include "error_handler.h" #include "exception.h" #include "largest.h" @@ -133,7 +135,7 @@ namespace etl { } -#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) +#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) || defined(ETL_NO_STL) //************************************************************************* /// Creates the object. Default constructor. //************************************************************************* diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index cb357424..62a2f923 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -64,7 +64,6 @@ cog.outl("//******************************************************************** #define ETL_VARIANT_POOL_INCLUDED #include -#include #include "platform.h" #include "error_handler.h" @@ -74,7 +73,9 @@ cog.outl("//******************************************************************** #include "alignment.h" #include "static_assert.h" #include "type_lookup.h" -#include +#include "pool.h" + +#include "stl/utility.h" #undef ETL_FILE #define ETL_FILE "40" diff --git a/include/etl/vector.h b/include/etl/vector.h index 9eb0b83d..50b3ee30 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -35,9 +35,6 @@ SOFTWARE. #include #include -#include -#include -#include #include #include "platform.h" @@ -53,7 +50,11 @@ SOFTWARE. #include "debug_count.h" #include "private/vector_base.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#include "stl/algorithm.h" +#include "stl/iterator.h" +#include "stl/functional.h" + +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -1067,7 +1068,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* @@ -1183,7 +1184,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Constructor, from an initializer_list. //************************************************************************* diff --git a/include/etl/wstring.h b/include/etl/wstring.h index a4f7bc23..1ab83a02 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -35,7 +35,7 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #include #endif @@ -146,7 +146,7 @@ namespace etl this->assign(first, last); } -#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) +#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) //************************************************************************* /// Construct from initializer_list. //************************************************************************* diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9fb4fb86..9ac85d7a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -132,7 +132,7 @@ if (WIN32) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - list(APPEND TEST_SOURCE_FILES "test_atomic_gcc.cpp") + list(APPEND TEST_SOURCE_FILES "test_atomic_gcc_sync.cpp") endif() add_executable(etl_tests ${TEST_SOURCE_FILES} diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 20b6dfb2..7a3eee9d 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -279,6 +279,16 @@ + + + + + + + + + + @@ -383,6 +393,10 @@ + + + + diff --git a/test/etl_profile.h b/test/etl_profile.h index 906660b9..213e99ea 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -74,6 +74,8 @@ SOFTWARE. //#define ETL_MESSAGES_ARE_VIRTUAL //#define ETL_POLYMORPHIC_MESSAGES +//#define ETL_NO_STL + #ifdef _MSC_VER #include "profiles/msvc_x86.h" #else diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index b04d62fc..52984cc9 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -867,5 +867,47 @@ namespace is_same = std::equal(std::begin(output_false), std::end(output_false), std::begin(compare_false)); CHECK(is_same); } + + //========================================================================= + TEST(sort_default) + { + std::vector data(100, 0); + std::iota(data.begin(), data.end(), 1); + + for (int i = 0; i < 100; ++i) + { + std::random_shuffle(data.begin(), data.end()); + + std::vector data1 = data; + std::vector data2 = data; + + std::sort(data1.begin(), data1.end()); + etl::sort(data2.begin(), data2.end()); + + bool is_same = std::equal(data1.begin(), data1.end(), data2.begin()); + CHECK(is_same); + } + } + + //========================================================================= + TEST(sort_greater) + { + std::vector data(100, 0); + std::iota(data.begin(), data.end(), 1); + + for (int i = 0; i < 100; ++i) + { + std::random_shuffle(data.begin(), data.end()); + + std::vector data1 = data; + std::vector data2 = data; + + std::sort(data1.begin(), data1.end(), std::greater()); + etl::sort(data2.begin(), data2.end(), std::greater()); + + bool is_same = std::equal(data1.begin(), data1.end(), data2.begin()); + CHECK(is_same); + } + } }; } diff --git a/test/test_atomic_std.cpp b/test/test_atomic_std.cpp index 9af9c77e..d89872a9 100644 --- a/test/test_atomic_std.cpp +++ b/test/test_atomic_std.cpp @@ -230,7 +230,7 @@ namespace std::atomic compare(&data[0]); etl::atomic test(&data[0]); - CHECK_EQUAL((int*)compare.fetch_add(std::ptrdiff_t(10)), (int*)test.fetch_add(std::ptrdiff_t(10))); + CHECK_EQUAL((int*)compare.fetch_add(ptrdiff_t(10)), (int*)test.fetch_add(ptrdiff_t(10))); } //========================================================================= @@ -338,7 +338,7 @@ namespace std::atomic compare(&data[0]); etl::atomic test(&data[0]); - CHECK_EQUAL((int*)compare.fetch_add(std::ptrdiff_t(10)), (int*)test.fetch_add(std::ptrdiff_t(10))); + CHECK_EQUAL((int*)compare.fetch_add(ptrdiff_t(10)), (int*)test.fetch_add(ptrdiff_t(10))); } //========================================================================= diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index 74cb9b45..cbc6d376 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -182,7 +182,7 @@ namespace typedef etl::largest Largest_t; typedef etl::packet Packet_t; - + etl::queue messageQueue; int startCount; @@ -531,7 +531,7 @@ namespace // Send Start event. motorControl.receive(nmr, Recursive()); - CHECK_EQUAL(1, motorControl.messageQueue.size()); + CHECK_EQUAL(1U, motorControl.messageQueue.size()); // Send the queued message. motorControl.receive(nmr, motorControl.messageQueue.front().get()); diff --git a/test/test_no_stl_algorithm.cpp b/test/test_no_stl_algorithm.cpp new file mode 100644 index 00000000..f29b4f9d --- /dev/null +++ b/test/test_no_stl_algorithm.cpp @@ -0,0 +1,581 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#undef min +#undef max + +#include "../include/etl/stl/alternate/algorithm.h" + +#include +#include +#include + +namespace +{ + int dataEQ[10] = { 1, 1, 3, 3, 5, 5, 7, 7, 9, 9 }; + std::list dataEQL = { 1, 1, 3, 3, 5, 5, 7, 7, 9, 9 }; + + int dataS[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::list dataSL = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + int dataA[10] = { 2, 1, 4, 3, 6, 5, 8, 7, 10, 9 }; + + typedef std::vector Vector; + Vector dataV = { 2, 1, 4, 3, 6, 5, 8, 7, 10, 9 }; + + typedef std::list List; + List dataL = { 2, 1, 4, 3, 6, 5, 8, 7, 10, 9 }; + + class Data + { + public: + + Data() + : a(0), + b(0) + { + } + + Data(int a, int b) + : a(a), + b(b) + { + } + + int a; + int b; + }; + + Data dataD[10] = { Data(1, 2), Data(2, 1), Data(3, 4), Data(4, 3), Data(5, 6), Data(6, 5), Data(7, 8), Data(8, 7), Data(9, 10), Data(10, 9) }; + + bool operator ==(const Data& lhs, const Data& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b); + } + + struct StructDataPredicate + { + bool operator ()(const Data& lhs, const Data& rhs) const + { + return lhs.a < rhs.a; + } + }; + + struct StructDataEquality + { + bool operator ()(const Data& lhs, const Data& rhs) const + { + return lhs.a == rhs.a; + } + }; + + std::ostream& operator << (std::ostream& os, const Data& data_) + { + os << data_.a << "," << data_.b; + return os; + } + + struct Greater : public std::binary_function + { + bool operator()(int a, int b) const + { + return a > b; + } + }; + + SUITE(test_no_stl_algorithm) + { + //************************************************************************* + TEST(distance_non_random) + { + ptrdiff_t d1 = std::distance(dataL.begin(), dataL.end()); + ptrdiff_t d2 = etlstd::distance(dataL.begin(), dataL.end()); + + CHECK_EQUAL(d1, d2); + } + + //************************************************************************* + TEST(distance_random) + { + ptrdiff_t d1 = std::distance(dataV.begin(), dataV.end()); + ptrdiff_t d2 = etlstd::distance(dataV.begin(), dataV.end()); + + CHECK_EQUAL(d1, d2); + } + + //************************************************************************* + TEST(advance_non_random) + { + List::const_iterator itr1 = dataL.begin(); + List::const_iterator itr2 = dataL.begin(); + + std::advance(itr1, 4); + std::advance(itr2, 4); + + CHECK_EQUAL(*itr1, *itr2); + } + + //************************************************************************* + TEST(advance_random) + { + Vector::const_iterator itr1 = dataV.begin(); + Vector::const_iterator itr2 = dataV.begin(); + + std::advance(itr1, 4); + std::advance(itr2, 4); + + CHECK_EQUAL(*itr1, *itr2); + } + + //************************************************************************* + TEST(min) + { + int a = 1; + int b = 2; + + CHECK_EQUAL((std::min(a, b)), (etlstd::min(a, b))); + CHECK_EQUAL((std::min(b, a)), (etlstd::min(b, a))); + } + + //************************************************************************* + TEST(min_compare) + { + int a = 1; + int b = 2; + + CHECK_EQUAL((std::min(a, b, Greater())), (etlstd::min(a, b, Greater()))); + CHECK_EQUAL((std::min(b, a, Greater())), (etlstd::min(b, a, Greater()))); + } + + //************************************************************************* + TEST(max) + { + int a = 1; + int b = 2; + + CHECK_EQUAL((std::max(a, b)), (etlstd::max(a, b))); + CHECK_EQUAL((std::max(b, a)), (etlstd::max(b, a))); + } + + //************************************************************************* + TEST(max_compare) + { + int a = 1; + int b = 2; + + CHECK_EQUAL((std::max(a, b, Greater())), (etlstd::max(a, b, Greater()))); + CHECK_EQUAL((std::max(b, a, Greater())), (etlstd::max(b, a, Greater()))); + } + + //************************************************************************* + TEST(copy_pod_pointer) + { + int data1[10]; + int data2[10]; + + std::copy(std::begin(dataA), std::end(dataA), std::begin(data1)); + etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_non_pod_pointer) + { + Data data1[10]; + Data data2[10]; + + std::copy(std::begin(dataD), std::end(dataD), std::begin(data1)); + etlstd::copy(std::begin(dataD), std::end(dataD), std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_non_random_iterator) + { + List data1(dataL.size()); + List data2(dataL.size()); + + std::copy(std::begin(dataA), std::end(dataA), std::begin(data1)); + etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_n_pod_pointer) + { + int data1[10]; + int data2[10]; + + std::copy_n(std::begin(dataA), 10, std::begin(data1)); + etlstd::copy_n(std::begin(dataA), 10, std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_n_non_pod_pointer) + { + Data data1[10]; + Data data2[10]; + + std::copy_n(std::begin(dataD), 10, std::begin(data1)); + etlstd::copy_n(std::begin(dataD), 10, std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_n_non_random_iterator) + { + List data1(dataL.size()); + List data2(dataL.size()); + + std::copy_n(std::begin(dataA), 10, std::begin(data1)); + etlstd::copy_n(std::begin(dataA), 10, std::begin(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_backward_pod_pointer) + { + int data1[10]; + int data2[10]; + + std::copy_backward(std::begin(dataA), std::end(dataA), std::end(data1)); + etlstd::copy_backward(std::begin(dataA), std::end(dataA), std::end(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_backward_non_pod_pointer) + { + Data data1[10]; + Data data2[10]; + + std::copy_backward(std::begin(dataD), std::end(dataD), std::end(data1)); + etlstd::copy_backward(std::begin(dataD), std::end(dataD), std::end(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(copy_backward_non_random_iterator) + { + List data1(dataL.size()); + List data2(dataL.size()); + + std::copy_backward(std::begin(dataA), std::end(dataA), std::end(data1)); + etlstd::copy_backward(std::begin(dataA), std::end(dataA), std::end(data2)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(lower_bound_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + int* lb1 = std::lower_bound(std::begin(dataS), std::end(dataS), i); + int* lb2 = etlstd::lower_bound(std::begin(dataS), std::end(dataS), i); + + CHECK_EQUAL(lb1, lb2); + } + } + + //************************************************************************* + TEST(lower_bound_non_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + std::list::iterator lb1 = std::lower_bound(std::begin(dataSL), std::end(dataSL), i); + std::list::iterator lb2 = etlstd::lower_bound(std::begin(dataSL), std::end(dataSL), i); + + CHECK_EQUAL(std::distance(std::begin(dataSL), lb1), std::distance(std::begin(dataSL), lb2)); + } + } + + //************************************************************************* + TEST(upper_bound_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + int* lb1 = std::upper_bound(std::begin(dataS), std::end(dataS), i); + int* lb2 = etlstd::upper_bound(std::begin(dataS), std::end(dataS), i); + + CHECK_EQUAL(std::distance(std::begin(dataS), lb1), std::distance(std::begin(dataS), lb2)); + } + } + + //************************************************************************* + TEST(upper_bound_non_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + std::list::iterator lb1 = std::upper_bound(std::begin(dataSL), std::end(dataSL), i); + std::list::iterator lb2 = etlstd::upper_bound(std::begin(dataSL), std::end(dataSL), i); + + CHECK_EQUAL(std::distance(std::begin(dataSL), lb1), std::distance(std::begin(dataSL), lb2)); + } + } + + //************************************************************************* + TEST(equal_range_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + std::pair lb1 = std::equal_range(std::begin(dataEQ), std::end(dataEQ), i); + std::pair lb2 = etlstd::equal_range(std::begin(dataEQ), std::end(dataEQ), i); + + CHECK_EQUAL(std::distance(std::begin(dataEQ), lb1.first), std::distance(std::begin(dataEQ), lb2.first)); + CHECK_EQUAL(std::distance(lb1.first, lb1.second), std::distance(lb2.first, lb2.second)); + } + } + + //************************************************************************* + TEST(equal_range_non_random_iterator) + { + for (int i = 0; i < 11; ++i) + { + std::pair::iterator, std::list::iterator> lb1 = std::equal_range(std::begin(dataEQL), std::end(dataEQL), i); + std::pair::iterator, std::list::iterator> lb2 = etlstd::equal_range(std::begin(dataEQL), std::end(dataEQL), i); + + CHECK_EQUAL(std::distance(std::begin(dataEQL), lb1.first), std::distance(std::begin(dataEQL), lb2.first)); + CHECK_EQUAL(std::distance(lb1.first, lb1.second), std::distance(lb2.first, lb2.second)); + } + } + + //************************************************************************* + TEST(fill_non_char) + { + int data1[10]; + int data2[10]; + + std::fill(std::begin(data1), std::end(data1), 0x12345678); + etlstd::fill(std::begin(data2), std::end(data2), 0x12345678); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(fill_char) + { + unsigned char data1[10]; + unsigned char data2[10]; + + std::fill(std::begin(data1), std::end(data1), char(0x12)); + etlstd::fill(std::begin(data2), std::end(data2), char(0x12)); + + bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(swap) + { + int a = 1; + int b = 2; + + etlstd::swap(a, b); + CHECK_EQUAL(2, a); + CHECK_EQUAL(1, b); + } + + //************************************************************************* + TEST(iter_swap) + { + int a = 1; + int b = 2; + + etlstd::iter_swap(&a, &b); + CHECK_EQUAL(2, a); + CHECK_EQUAL(1, b); + } + + //************************************************************************* + TEST(equal) + { + CHECK(etlstd::equal(std::begin(dataV), std::end(dataV), std::begin(dataL))); + CHECK(!etlstd::equal(std::begin(dataSL), std::end(dataSL), std::begin(dataL))); + } + + //************************************************************************* + TEST(lexicographical_compare) + { + std::string text1("Hello World"); + std::string text2("Hello Xorld"); + + bool t1 = std::lexicographical_compare(text1.begin(), text1.end(), text2.begin(), text2.begin() + 7); + bool t2 = etlstd::lexicographical_compare(text1.begin(), text1.end(), text2.begin(), text2.begin() + 7); + + CHECK(t1 == t2); + } + + //************************************************************************* + TEST(lexicographical_compare_greater) + { + std::string text1("Hello World"); + std::string text2("Hello Xorld"); + + bool t1 = std::lexicographical_compare(text1.begin(), text1.end(), text2.begin(), text2.begin() + 7, Greater()); + bool t2 = etlstd::lexicographical_compare(text1.begin(), text1.end(), text2.begin(), text2.begin() + 7, Greater()); + + CHECK(t1 == t2); + } + + //************************************************************************* + TEST(search) + { + std::string haystack = "ABCDFEGHIJKLMNOPQRSTUVWXYZ"; + std::string needle = "KLMNO"; + + std::string::iterator itr1 = std::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin()); + std::string::iterator itr2 = etlstd::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin()); + + CHECK(itr1 == itr2); + } + + //************************************************************************* + TEST(search_predicate) + { + std::string haystack = "ABCDFEGHIJKLMNOPQRSTUVWXYZ"; + std::string needle = "KLMNO"; + + std::string::iterator itr1 = std::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin(), std::equal_to()); + std::string::iterator itr2 = etlstd::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin(), std::equal_to()); + + CHECK(itr1 == itr2); + } + + //************************************************************************* + TEST(heap) + { + Vector data1 = dataV; + Vector data2 = dataV; + + std::make_heap(data1.begin(), data1.end()); + etlstd::make_heap(data2.begin(), data2.end()); + + bool isEqual; + + CHECK(std::is_heap(data2.begin(), data2.end())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + std::pop_heap(data1.begin(), data1.end()); + etlstd::pop_heap(data2.begin(), data2.end()); + + data1.pop_back(); + data2.pop_back(); + + CHECK(std::is_heap(data1.begin(), data1.end())); + CHECK(std::is_heap(data2.begin(), data2.end())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + CHECK(std::is_heap(data2.begin(), data2.end())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + data1.push_back(5); + data2.push_back(5); + + std::push_heap(data1.begin(), data1.end()); + etlstd::push_heap(data2.begin(), data2.end()); + + CHECK(std::is_heap(data2.begin(), data2.end())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + + //************************************************************************* + TEST(heap_greater) + { + Vector data1 = dataV; + Vector data2 = dataV; + + std::make_heap(data1.begin(), data1.end(), Greater()); + etlstd::make_heap(data2.begin(), data2.end(), Greater()); + + bool isEqual; + + CHECK(std::is_heap(data2.begin(), data2.end(), Greater())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + std::pop_heap(data1.begin(), data1.end(), Greater()); + etlstd::pop_heap(data2.begin(), data2.end(), Greater()); + + data1.pop_back(); + data2.pop_back(); + + CHECK(std::is_heap(data1.begin(), data1.end(), Greater())); + CHECK(std::is_heap(data2.begin(), data2.end(), Greater())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + CHECK(std::is_heap(data2.begin(), data2.end(), Greater())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + + data1.push_back(5); + data2.push_back(5); + + std::push_heap(data1.begin(), data1.end(), Greater()); + etlstd::push_heap(data2.begin(), data2.end(), Greater()); + + CHECK(std::is_heap(data2.begin(), data2.end(), Greater())); + + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); + CHECK(isEqual); + } + }; +} diff --git a/test/test_no_stl_functional.cpp b/test/test_no_stl_functional.cpp new file mode 100644 index 00000000..8b92a715 --- /dev/null +++ b/test/test_no_stl_functional.cpp @@ -0,0 +1,78 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#undef min +#undef max + +#include "../include/etl/stl/alternate/functional.h" + +namespace +{ + template + bool compare(int a, int b) + { + return TCompare()(a, b); + } + + SUITE(test_no_stl_functional) + { + //************************************************************************* + TEST(test_less) + { + CHECK((compare>(1, 2))); + CHECK(!(compare>(2, 1))); + CHECK(!(compare>(1, 1))); + } + + //************************************************************************* + TEST(test_greater) + { + CHECK(!(compare>(1, 2))); + CHECK((compare>(2, 1))); + CHECK(!(compare>(1, 1))); + } + + //************************************************************************* + TEST(test_equal_to) + { + CHECK((compare>(1, 1))); + CHECK(!(compare>(1, 2))); + CHECK(!(compare>(2, 1))); + } + + //************************************************************************* + TEST(test_not_equal_to) + { + CHECK(!(compare>(1, 1))); + CHECK((compare>(1, 2))); + CHECK((compare>(2, 1))); + } + }; +} diff --git a/test/test_no_stl_limits.cpp b/test/test_no_stl_limits.cpp new file mode 100644 index 00000000..4035020b --- /dev/null +++ b/test/test_no_stl_limits.cpp @@ -0,0 +1,762 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#include "../include/etl/stl/alternate/limits.h" + +#include + +namespace +{ + SUITE(test_no_stl_limits) + { + //************************************************************************* + TEST(test_bool) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(STD::is_modulo, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_char) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_unsigned_char) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(true, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_signed_char) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_char16_t) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_char32_t) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_wchar_t) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(STD::is_modulo, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_short) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_unsigned_short) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(true, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_int) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_unsigned_int) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(true, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_long) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_unsigned_long) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(true, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_long_long) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_unsigned_long_long) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(STD::has_denorm_loss, ETL::has_denorm_loss); + CHECK_EQUAL(STD::has_infinity, ETL::has_infinity); + CHECK_EQUAL(STD::has_quiet_NaN, ETL::has_quiet_NaN); + CHECK_EQUAL(STD::has_signaling_NaN, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::infinity(), ETL::infinity()); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(true, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + CHECK_EQUAL(STD::tinyness_before, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + } + + //************************************************************************* + TEST(test_float) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(true, ETL::has_denorm_loss); + CHECK_EQUAL(false, ETL::has_infinity); + CHECK_EQUAL(false, ETL::has_quiet_NaN); + CHECK_EQUAL(false, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(true, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + + // CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + // CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + // CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + // CHECK_EQUAL(STD::infinity(), ETL::infinity()); + } + + //************************************************************************* + TEST(test_double) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(true, ETL::has_denorm_loss); + CHECK_EQUAL(false, ETL::has_infinity); + CHECK_EQUAL(false, ETL::has_quiet_NaN); + CHECK_EQUAL(false, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(true, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + + // CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + // CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + // CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + // CHECK_EQUAL(STD::infinity(), ETL::infinity()); + } + + //************************************************************************* + TEST(test_long_double) + { + typedef etlstd::numeric_limits ETL; + typedef std::numeric_limits STD; + + CHECK_EQUAL(STD::digits, ETL::digits); + CHECK_EQUAL(STD::digits10, ETL::digits10); + CHECK_EQUAL(STD::epsilon(), ETL::epsilon()); + CHECK_EQUAL(int(STD::has_denorm), int(ETL::has_denorm)); + CHECK_EQUAL(true, ETL::has_denorm_loss); + CHECK_EQUAL(false, ETL::has_infinity); + CHECK_EQUAL(false, ETL::has_quiet_NaN); + CHECK_EQUAL(false, ETL::has_signaling_NaN); + CHECK_EQUAL(STD::is_bounded, ETL::is_bounded); + CHECK_EQUAL(STD::is_exact, ETL::is_exact); + CHECK_EQUAL(STD::is_iec559, ETL::is_iec559); + CHECK_EQUAL(STD::is_integer, ETL::is_integer); + CHECK_EQUAL(false, ETL::is_modulo); + CHECK_EQUAL(STD::is_signed, ETL::is_signed); + CHECK_EQUAL(STD::is_specialized, ETL::is_specialized); + CHECK_EQUAL(STD::lowest(), ETL::lowest()); + CHECK_EQUAL(STD::max(), ETL::max()); + CHECK_EQUAL(STD::max_digits10, ETL::max_digits10); + CHECK_EQUAL(STD::max_exponent, ETL::max_exponent); + CHECK_EQUAL(STD::max_exponent10, ETL::max_exponent10); + CHECK_EQUAL(STD::min(), ETL::min()); + CHECK_EQUAL(STD::min_exponent, ETL::min_exponent); + CHECK_EQUAL(STD::min_exponent10, ETL::min_exponent10); + CHECK_EQUAL(STD::radix, ETL::radix); + CHECK_EQUAL(STD::round_error(), ETL::round_error()); + CHECK_EQUAL(int(STD::round_style), int(ETL::round_style)); + CHECK_EQUAL(true, ETL::tinyness_before); + CHECK_EQUAL(false, ETL::traps); + + // CHECK_EQUAL(STD::denorm_min(), ETL::denorm_min()); + // CHECK_EQUAL(STD::signaling_NaN(), ETL::signaling_NaN()); + // CHECK_EQUAL(STD::quiet_NaN(), ETL::quiet_NaN()); + // CHECK_EQUAL(STD::infinity(), ETL::infinity()); + } + }; +} diff --git a/test/test_no_stl_utility.cpp b/test/test_no_stl_utility.cpp new file mode 100644 index 00000000..441ef930 --- /dev/null +++ b/test/test_no_stl_utility.cpp @@ -0,0 +1,142 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#undef min +#undef max + +#include "../include/etl/stl/alternate/utility.h" + +namespace +{ + SUITE(test_no_stl_utility) + { + //************************************************************************* + TEST(pair_default_construct) + { + etlstd::pair p1; + + CHECK_EQUAL(int(), p1.first); + CHECK_EQUAL(double(), p1.second); + } + + //************************************************************************* + TEST(test_pair_construct) + { + etlstd::pair p1(1, 2.3); + + CHECK_EQUAL(1, p1.first); + CHECK_EQUAL(2.3, p1.second); + } + + //************************************************************************* + TEST(test_pair_copy_construct) + { + etlstd::pair p1(1, 2.3); + etlstd::pair p2(p1); + + CHECK_EQUAL(p1.first, p2.first); + CHECK_EQUAL(p1.second, p2.second); + } + + //************************************************************************* + TEST(test_pair_copy_construct_alternate) + { + etlstd::pair p1(1, 2.3f); + etlstd::pair p2(p1); + + CHECK_EQUAL(p1.first, p2.first); + CHECK_EQUAL(p1.second, p2.second); + } + + //************************************************************************* + TEST(test_make_pair) + { + etlstd::pair p1(1, 2.3); + etlstd::pair p2; + p2 = etlstd::make_pair(1, 2.3); + + CHECK_EQUAL(p1.first, p2.first); + CHECK_EQUAL(p1.second, p2.second); + } + + //************************************************************************* + TEST(test_pair_swap_member) + { + etlstd::pair p1(1, 2.3); + etlstd::pair p2(2, 3.4); + + p1.swap(p2); + + CHECK_EQUAL(2, p1.first); + CHECK_EQUAL(3.4, p1.second); + + CHECK_EQUAL(1, p2.first); + CHECK_EQUAL(2.3, p2.second); + } + + //************************************************************************* + TEST(test_pair_swap_global) + { + etlstd::pair p1(1, 2.3); + etlstd::pair p2(2, 3.4); + + etlstd::swap(p1, p2); + + CHECK_EQUAL(2, p1.first); + CHECK_EQUAL(3.4, p1.second); + + CHECK_EQUAL(1, p2.first); + CHECK_EQUAL(2.3, p2.second); + } + + //************************************************************************* + TEST(test_pair_conditional) + { + etlstd::pair p1(1, 2.3); + etlstd::pair p2(1, 2.3); + etlstd::pair p3(2, 3.4); + + CHECK(p1 == p2); + CHECK(!(p1 == p3)); + CHECK(p1 != p3); + CHECK(!(p1 != p2)); + CHECK(p1 <= p2); + CHECK(p1 <= p3); + CHECK(!(p1 < p2)); + CHECK(p1 < p3); + CHECK(!(p3 < p1)); + CHECK(p1 >= p2); + CHECK(!(p1 >= p3)); + CHECK(!(p1 > p2)); + CHECK(!(p1 > p3)); + CHECK(p3 > p1); + } + }; +} diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index d5fc33a3..36cb1401 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -385,10 +385,15 @@ + + + + + @@ -402,6 +407,16 @@ + + + + + + + + + + @@ -549,6 +564,7 @@ + ../../../unittest-cpp ../../../unittest-cpp @@ -669,6 +685,9 @@ + + + false @@ -745,6 +764,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index 78786739..52458239 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -73,6 +73,12 @@ {0bcdf7f9-8e2b-4f70-932b-bde56404f421} + + {86dc2850-2ddf-4582-9908-2436a1aa6e86} + + + {0d093ee6-686c-4c9e-856e-bdf7075ff7a6} + @@ -270,9 +276,6 @@ ETL\Containers - - ETL\Private - ETL\Utilities @@ -633,6 +636,54 @@ ETL\Profiles + + ETL\Private + + + ETL\STL\Alternate + + + ETL\STL\Alternate + + + ETL\STL + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\STL\Alternate + + + ETL\STL + + + ETL\STL + + + ETL\STL\Alternate + + + ETL\STL + + + ETL\STL\Alternate + + + ETL\STL + @@ -1046,6 +1097,18 @@ UnitTest++\Win32 + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -1095,6 +1158,9 @@ Resource Files\Make + + Source Files + From ba98ef5d79a96626b4d68a502bb436eddb9f0a2c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 25 Jul 2018 11:40:33 +0100 Subject: [PATCH 23/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/memory.h # include/etl/version.h # support/Release notes.txt --- include/etl/memory.h | 172 ++++++++++++++++++++++++----------- include/etl/version.h | 6 +- support/Release notes.txt | 6 ++ test/test_memory.cpp | 42 +++++++++ test/test_string_char.cpp | 19 ++++ test/test_string_u16.cpp | 19 ++++ test/test_string_u32.cpp | 21 ++++- test/test_string_wchar_t.cpp | 19 ++++ 8 files changed, 248 insertions(+), 56 deletions(-) diff --git a/include/etl/memory.h b/include/etl/memory.h index 0d06a1f0..de82cc95 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -31,13 +31,14 @@ SOFTWARE. #ifndef ETL_MEMORY_INCLUDED #define ETL_MEMORY_INCLUDED -#include "algorithm.h" - #include "platform.h" +#include "algorithm.h" #include "type_traits.h" #include "stl/iterator.h" +#include + ///\defgroup memory memory ///\ingroup etl namespace etl @@ -96,7 +97,7 @@ namespace etl count += int32_t(std::distance(o_begin, o_end)); std::fill(o_begin, o_end, value); - + return o_end; } @@ -340,7 +341,7 @@ namespace etl /// Default initialises N objects to uninitialised memory. ///\ingroup memory //***************************************************************************** - template + template typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n) { @@ -770,12 +771,41 @@ namespace etl }; //***************************************************************************** - /// Unique pointer. + /// Default deleter. ///\tparam T The pointed to type type. ///\ingroup memory //***************************************************************************** template - class unique_ptr + struct default_delete + { + void operator()(T* p) const + { + delete p; + } + }; + + //***************************************************************************** + /// Default deleter for arrays. + ///\tparam T The pointed to type type. + ///\ingroup memory + //***************************************************************************** + template + struct default_delete + { + template + void operator()(U* p) const + { + delete[] p; + } + }; + + //***************************************************************************** + /// Unique pointer. + ///\tparam T The pointed to type type. + ///\ingroup memory + //***************************************************************************** + template > + class unique_ptr { public: @@ -799,22 +829,32 @@ namespace etl { } #endif - + ~unique_ptr() { - delete p; + deleter(p); } ETL_CONSTEXPR pointer get() const { return p; } - + + TDeleter& get_deleter() + { + return deleter; + } + + const TDeleter& get_deleter() const + { + return deleter; + } + pointer release() - { + { pointer value = p; p = nullptr; - + return value; } @@ -826,21 +866,21 @@ namespace etl p = p_; delete value; } - + void swap(unique_ptr& value) - { + { std::swap(p, value.p); } - + ETL_CONSTEXPR explicit operator bool() const { return (p != nullptr); } - + unique_ptr& operator =(pointer p_) { reset(p_); - + return *this; } @@ -848,36 +888,36 @@ namespace etl unique_ptr& operator =(unique_ptr&& p_) { reset(p_.release()); - - return *this; + + return *this; } #endif - + ETL_CONSTEXPR reference operator *() const { return *get(); } - + ETL_CONSTEXPR pointer operator ->() const { return get(); } - + ETL_CONSTEXPR reference operator [](size_t i) const { return get()[i]; } - + ETL_CONSTEXPR bool operator== (const pointer p_) const { return p == p_; } - + ETL_CONSTEXPR bool operator== (const unique_ptr& p_) const { return p == p_.p; } - + ETL_CONSTEXPR bool operator< (const unique_ptr& p_) const { return p < p_.p; @@ -889,25 +929,26 @@ namespace etl unique_ptr(const unique_ptr&); unique_ptr& operator =(const unique_ptr&); + TDeleter deleter; + pointer p; }; - //***************************************************************************** /// Unique pointer for arrays. ///\tparam T The pointed to type type. ///\ingroup memory //***************************************************************************** - template - class unique_ptr + template + class unique_ptr { public: typedef T element_type; typedef T* pointer; typedef T& reference; - - ETL_CONSTEXPR unique_ptr() + + ETL_CONSTEXPR unique_ptr() : p(nullptr) { } @@ -916,43 +957,53 @@ namespace etl : p(p_) { } - + #if ETL_CPP11_SUPPORTED unique_ptr(unique_ptr&& p_) : p(p_.release()) { } #endif - - ~unique_ptr() + + ~unique_ptr() { - delete[] p; + deleter(p); } - + ETL_CONSTEXPR pointer get() const { return p; } - - pointer release() + + TDeleter& get_deleter() + { + return deleter; + } + + const TDeleter& get_deleter() const + { + return deleter; + } + + pointer release() { pointer value = p; p = nullptr; return value; } - + void reset(pointer p_) { assert(p_ != p); - pointer value = p; - p = p_; - delete[] value; + pointer value = p; + p = p_; + delete[] value; } void swap(unique_ptr& v) { - std::swap(p, v.p); + std::swap(p, v.p); } ETL_CONSTEXPR explicit operator bool() const @@ -963,8 +1014,8 @@ namespace etl unique_ptr& operator =(pointer p_) { reset(p_); - - return *this; + + return *this; } #if ETL_CPP11_SUPPORTED @@ -972,31 +1023,31 @@ namespace etl { reset(p_.release()); - return *this; + return *this; } #endif ETL_CONSTEXPR reference operator *() const { - return *p; + return *p; } ETL_CONSTEXPR pointer operator ->() const { - return p; + return p; } ETL_CONSTEXPR reference operator [](size_t i) const { - return p[i]; + return p[i]; } ETL_CONSTEXPR bool operator ==(const pointer p_) const { - return (p == p_); + return (p == p_); } - ETL_CONSTEXPR bool operator ==(const unique_ptr& p_) const + ETL_CONSTEXPR bool operator ==(const unique_ptr& p_) const { return (p == p_.p); } @@ -1005,14 +1056,33 @@ namespace etl { return (p < p_.p); } - + private: // Deleted. unique_ptr(const unique_ptr&); unique_ptr& operator =(const unique_ptr&); - pointer p; + TDeleter deleter; + + pointer p; + }; + + //***************************************************************************** + /// Base class for objects that require their memory to be wiped after use. + /// Erases the object's memory to zero. + /// Note: This must be the last destructor called for the derived object. + ///\tparam T The derived type. + ///\ingroup memory + //***************************************************************************** + template + struct wipe_on_destruct + { + ~wipe_on_destruct() + { + char* pobject = reinterpret_cast(static_cast(this)); + memset(pobject, 0, sizeof(T)); + } }; } diff --git a/include/etl/version.h b/include/etl/version.h index caaedbcf..933abed9 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.13.2" +#define ETL_VERSION "11.14.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 13 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MINOR 14 +#define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index e9202643..3d4b9fac 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,9 @@ +=============================================================================== +11.14.0 +Added tests for limited support for self insert for strings. +Added 'wipe_on_destruct' template class for secure wiping of objects on destruction. +Updated unique_ptr API. + =============================================================================== 11.13.2 Protected destructor for some FSM classes. diff --git a/test/test_memory.cpp b/test/test_memory.cpp index 0f5f0f4e..85eab67a 100644 --- a/test/test_memory.cpp +++ b/test/test_memory.cpp @@ -528,5 +528,47 @@ namespace CHECK_EQUAL(test_item_trivial, etl::make_copy_at(pn, test_item_trivial, count)); CHECK_EQUAL(3U, count); } + + //************************************************************************* + TEST(test_wipe_on_destruct) + { + struct Data : public etl::wipe_on_destruct + { + Data(int a_, char b_, double c_) + : a(a_), + b(b_), + c(c_) + { + } + + bool operator ==(const Data& other) const + { + return (a == other.a) && (b == other.b) && (c == other.c); + } + + int a; + char b; + double c; + }; + + std::array buffer; + buffer.fill(0); + + // Construct in-place. + ::new (buffer.data()) Data(1, 'b', 3.4); + + Data& other = *reinterpret_cast(buffer.data()); + CHECK(other == Data(1, 'b', 3.4)); + + // Cleared compare buffer. + std::array clear; + clear.fill(0); + + // Destruct; + other.~Data(); + + // Storage should be wiped. + CHECK(buffer == clear); + } }; } diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 3d9aab80..948476f3 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -48,6 +48,7 @@ namespace typedef etl::istring IText; typedef std::string Compare_Text; typedef Text::value_type value_t; + typedef etl::string<52> TextL; Compare_Text initial_text; Compare_Text less_text; @@ -867,6 +868,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_self) + { + size_t length = TextL::MAX_SIZE / 2; + + for (size_t offset = 10; offset < length; ++offset) + { + Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); + compare_text.insert(compare_text.begin() + offset, compare_text.begin() + 5, compare_text.begin() + 10); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 62de9237..81ed3a4a 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -47,6 +47,7 @@ namespace typedef etl::iu16string IText; typedef std::u16string Compare_Text; typedef Text::value_type value_t; + typedef etl::u16string<52> TextL; Compare_Text initial_text; Compare_Text less_text; @@ -866,6 +867,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_self) + { + size_t length = TextL::MAX_SIZE / 2; + + for (size_t offset = 10; offset < length; ++offset) + { + Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); + compare_text.insert(compare_text.begin() + offset, compare_text.begin() + 5, compare_text.begin() + 10); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 4cfd43f9..e3f3528e 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -47,6 +47,7 @@ namespace typedef etl::iu32string IText; typedef std::u32string Compare_Text; typedef Text::value_type value_t; + typedef etl::u32string<52> TextL; Compare_Text initial_text; Compare_Text less_text; @@ -583,8 +584,6 @@ namespace CHECK(is_equal); } - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { @@ -866,6 +865,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_self) + { + size_t length = TextL::MAX_SIZE / 2; + + for (size_t offset = 10; offset < length; ++offset) + { + Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); + compare_text.insert(compare_text.begin() + offset, compare_text.begin() + 5, compare_text.begin() + 10); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index ff538896..e1cbdad2 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -47,6 +47,7 @@ namespace typedef etl::iwstring IText; typedef std::wstring Compare_Text; typedef Text::value_type value_t; + typedef etl::wstring<52> TextL; Compare_Text initial_text; Compare_Text less_text; @@ -866,6 +867,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_self) + { + size_t length = TextL::MAX_SIZE / 2; + + for (size_t offset = 10; offset < length; ++offset) + { + Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); + compare_text.insert(compare_text.begin() + offset, compare_text.begin() + 5, compare_text.begin() + 10); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { From 8a009b6d4dcbdb4328f3e1dd8b43f17cbe1d4a2e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 28 Jul 2018 09:30:44 +0100 Subject: [PATCH 24/28] Merge remote-tracking branch 'origin/development' --- include/etl/flat_map.h | 2 +- include/etl/flat_set.h | 2 +- include/etl/version.h | 10 +++++----- support/Release notes.txt | 4 ++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index d2c78810..66ed69b4 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -300,7 +300,7 @@ namespace etl std::pair result(i_element, false); // Doesn't already exist? - if ((i_element == end() || (i_element->first != value.first))) + if ((i_element == end()) || TKeyCompare()(i_element->first, value.first) || TKeyCompare()(value.first, i_element->first)) { ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_map_full)); diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index d4dd28c0..bd58aae5 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -233,7 +233,7 @@ namespace etl std::pair result(i_element, false); // Doesn't already exist? - if ((i_element == end() || (*i_element != value))) + if ((i_element == end()) || TKeyCompare()(*i_element, value) || TKeyCompare()(value, *i_element)) { ETL_ASSERT(!refset_t::full(), ETL_ERROR(flat_set_full)); diff --git a/include/etl/version.h b/include/etl/version.h index 69ea1206..671e5301 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,13 +37,13 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.14.0" -#define ETL_VERSION_W L"11.14.0" -#define ETL_VERSION_U16 u"11.14.0" -#define ETL_VERSION_U32 U"11.14.0" +#define ETL_VERSION "11.14.1" +#define ETL_VERSION_W L"11.14.1" +#define ETL_VERSION_U16 u"11.14.1" +#define ETL_VERSION_U32 U"11.14.1" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH) #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 3d4b9fac..0df6c394 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.14.1 +Removed flat_set & flat_map reliance on equality. + =============================================================================== 11.14.0 Added tests for limited support for self insert for strings. From 85e51ee3755b031443abf7d4bcf5d794204c998b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 28 Jul 2018 21:58:30 +0100 Subject: [PATCH 25/28] Merge remote-tracking branch 'origin/development' --- CMakeLists.txt | 5 +-- include/etl/factory.h | 2 +- include/etl/flat_map.h | 10 ++++-- include/etl/flat_multimap.h | 6 ++-- include/etl/flat_multiset.h | 4 ++- include/etl/flat_set.h | 4 ++- include/etl/forward_list.h | 46 +++++++++++++-------------- include/etl/intrusive_forward_list.h | 38 +++++++++++----------- include/etl/map.h | 12 ++++--- include/etl/multimap.h | 12 ++++--- include/etl/multiset.h | 12 ++++--- include/etl/priority_queue.h | 16 ++++++---- include/etl/reference_flat_map.h | 26 ++++++++------- include/etl/reference_flat_multimap.h | 26 ++++++++------- include/etl/reference_flat_multiset.h | 22 +++++++------ include/etl/reference_flat_set.h | 20 ++++++------ include/etl/set.h | 12 ++++--- include/etl/stl/alternate/limits.h | 1 + include/etl/variant.h | 18 +++++------ include/etl/variant_pool.h | 2 +- include/etl/version.h | 10 +++--- src/binary.cpp | 4 +-- src/crc16.cpp | 2 +- src/crc16_ccitt.cpp | 2 +- src/crc16_kermit.cpp | 2 +- src/crc32.cpp | 2 +- src/crc32_c.cpp | 2 +- src/crc64_ecma.cpp | 2 +- src/crc8_ccitt.cpp | 4 +-- src/error_handler.cpp | 6 ++-- src/pearson.cpp | 4 +-- src/random.cpp | 4 +-- test/codeblocks/ETL.cbp | 10 +++--- test/data.h | 2 +- test/etl_profile.h | 4 +-- test/murmurhash3.cpp | 2 +- test/murmurhash3.h | 2 +- test/test_algorithm.cpp | 4 +-- test/test_alignment.cpp | 4 +-- test/test_array.cpp | 4 +-- test/test_array_view.cpp | 4 +-- test/test_array_wrapper.cpp | 2 +- test/test_atomic_gcc_sync.cpp | 4 +-- test/test_atomic_std.cpp | 4 +-- test/test_binary.cpp | 8 ++--- test/test_bitset.cpp | 2 +- test/test_bloom_filter.cpp | 12 +++---- test/test_bsd_checksum.cpp | 2 +- test/test_c_timer_framework.cpp | 2 +- test/test_callback_timer.cpp | 4 +-- test/test_checksum.cpp | 2 +- test/test_compare.cpp | 2 +- test/test_constant.cpp | 4 +-- test/test_container.cpp | 2 +- test/test_crc.cpp | 12 +++---- test/test_cyclic_value.cpp | 2 +- test/test_debounce.cpp | 2 +- test/test_deque.cpp | 2 +- test/test_embedded_compile.cpp | 42 ++++++++++++------------ test/test_endian.cpp | 2 +- test/test_enum_type.cpp | 2 +- test/test_error_handler.cpp | 4 +-- test/test_exception.cpp | 2 +- test/test_factory.cpp | 2 +- test/test_fixed_iterator.cpp | 2 +- test/test_flat_map.cpp | 3 +- test/test_flat_multimap.cpp | 3 +- test/test_flat_multiset.cpp | 3 +- test/test_flat_set.cpp | 3 +- test/test_fnv_1.cpp | 2 +- test/test_forward_list.cpp | 3 +- test/test_fsm.cpp | 10 +++--- test/test_function.cpp | 2 +- test/test_functional.cpp | 2 +- test/test_hash.cpp | 2 +- test/test_instance_count.cpp | 2 +- test/test_integral_limits.cpp | 2 +- test/test_intrusive_forward_list.cpp | 2 +- test/test_intrusive_links.cpp | 2 +- test/test_intrusive_list.cpp | 2 +- test/test_intrusive_queue.cpp | 4 +-- test/test_intrusive_stack.cpp | 4 +-- test/test_io_port.cpp | 2 +- test/test_iterator.cpp | 2 +- test/test_jenkins.cpp | 2 +- test/test_largest.cpp | 2 +- test/test_list.cpp | 3 +- test/test_map.cpp | 3 +- test/test_maths.cpp | 14 ++++---- test/test_memory.cpp | 4 +-- test/test_message_bus.cpp | 10 +++--- test/test_message_router.cpp | 8 ++--- test/test_message_timer.cpp | 6 ++-- test/test_multimap.cpp | 3 +- test/test_multiset.cpp | 3 +- test/test_murmur3.cpp | 2 +- test/test_no_stl_algorithm.cpp | 2 +- test/test_no_stl_functional.cpp | 2 +- test/test_no_stl_limits.cpp | 2 +- test/test_no_stl_utility.cpp | 2 +- test/test_numeric.cpp | 2 +- test/test_observer.cpp | 2 +- test/test_optional.cpp | 4 +-- test/test_packet.cpp | 8 ++--- test/test_parameter_type.cpp | 2 +- test/test_pearson.cpp | 2 +- test/test_pool.cpp | 4 +-- test/test_priority_queue.cpp | 2 +- test/test_queue.cpp | 2 +- test/test_queue_mpmc_mutex.cpp | 2 +- test/test_queue_spsc_atomic.cpp | 2 +- test/test_queue_spsc_isr.cpp | 2 +- test/test_random.cpp | 2 +- test/test_reference_flat_map.cpp | 2 +- test/test_reference_flat_multimap.cpp | 2 +- test/test_reference_flat_multiset.cpp | 2 +- test/test_reference_flat_set.cpp | 2 +- test/test_set.cpp | 3 +- test/test_smallest.cpp | 2 +- test/test_stack.cpp | 2 +- test/test_string_char.cpp | 5 +-- test/test_string_u16.cpp | 3 +- test/test_string_u32.cpp | 3 +- test/test_string_view.cpp | 12 +++---- test/test_string_wchar_t.cpp | 3 +- test/test_task_scheduler.cpp | 6 ++-- test/test_type_def.cpp | 2 +- test/test_type_lookup.cpp | 2 +- test/test_type_select.cpp | 4 +-- test/test_type_traits.cpp | 2 +- test/test_unordered_map.cpp | 2 +- test/test_unordered_multimap.cpp | 2 +- test/test_unordered_multiset.cpp | 4 +-- test/test_unordered_set.cpp | 4 +-- test/test_user_type.cpp | 2 +- test/test_utility.cpp | 2 +- test/test_variant.cpp | 2 +- test/test_variant_pool.cpp | 2 +- test/test_vector.cpp | 2 +- test/test_vector_non_trivial.cpp | 2 +- test/test_vector_pointer.cpp | 2 +- test/test_visitor.cpp | 2 +- test/test_xor_checksum.cpp | 2 +- test/test_xor_rotate_checksum.cpp | 2 +- test/vs2017/etl.vcxproj | 6 ++-- 145 files changed, 398 insertions(+), 354 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61c57638..1c03b3bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,11 +34,8 @@ add_library(etl ) target_include_directories(etl PUBLIC - include/etl - include/etl/atomic + include include/etl/profiles - PRIVATE - include/etl/private ) if (${ETL_PROFILE} STREQUAL DEFAULT) diff --git a/include/etl/factory.h b/include/etl/factory.h index 6c4e46f0..57f83eca 100644 --- a/include/etl/factory.h +++ b/include/etl/factory.h @@ -40,7 +40,7 @@ SOFTWARE. #include "alignment.h" #include "static_assert.h" #include "type_lookup.h" -#include +#include "pool.h" #if defined(ETL_COMPILER_GCC) #warning THIS CLASS IS DEPRECATED!USE VARIANT_POOL INSTEAD. diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 66ed69b4..548bd97d 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -101,13 +101,15 @@ namespace etl bool operator ()(const value_type& element, key_type key) const { - return key_compare()(element.first, key); + return comp(element.first, key); } bool operator ()(key_type key, const value_type& element) const { - return key_compare()(key, element.first); + return comp(key, element.first); } + + key_compare comp; }; public: @@ -300,7 +302,7 @@ namespace etl std::pair result(i_element, false); // Doesn't already exist? - if ((i_element == end()) || TKeyCompare()(i_element->first, value.first) || TKeyCompare()(value.first, i_element->first)) + if ((i_element == end()) || compare(i_element->first, value.first) || compare(value.first, i_element->first)) { ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_map_full)); @@ -764,6 +766,8 @@ namespace etl storage_t& storage; + TKeyCompare compare; + /// Internal debugging. ETL_DECLARE_DEBUG_COUNT; diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index e2b9a8c4..a9efbae4 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -103,13 +103,15 @@ namespace etl bool operator ()(const value_type& element, key_type key) const { - return key_compare()(element.first, key); + return comp(element.first, key); } bool operator ()(key_type key, const value_type& element) const { - return key_compare()(key, element.first); + return comp(key, element.first); } + + key_compare comp; }; public: diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 023a526a..8e946d36 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -232,7 +232,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); - iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare()); + iterator i_element = std::lower_bound(begin(), end(), value, compare); value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); @@ -605,6 +605,8 @@ namespace etl storage_t& storage; + TKeyCompare compare; + /// Internal debugging. ETL_DECLARE_DEBUG_COUNT; diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index bd58aae5..4d11ae7a 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -233,7 +233,7 @@ namespace etl std::pair result(i_element, false); // Doesn't already exist? - if ((i_element == end()) || TKeyCompare()(*i_element, value) || TKeyCompare()(value, *i_element)) + if ((i_element == end()) || compare(*i_element, value) || compare(value, *i_element)) { ETL_ASSERT(!refset_t::full(), ETL_ERROR(flat_set_full)); @@ -671,6 +671,8 @@ namespace etl storage_t& storage; + TKeyCompare compare; + /// Internal debugging. ETL_DECLARE_DEBUG_COUNT; diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 35d3a2d4..abebaa39 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -236,17 +236,17 @@ namespace etl //************************************************************************* /// Get the head node. //************************************************************************* - node_t& get_head() + node_t* get_head() { - return *start_node.next; + return start_node.next; } //************************************************************************* /// Get the head node. //************************************************************************* - const node_t& get_head() const + const node_t* get_head() const { - return *start_node.next; + return start_node.next; } //************************************************************************* @@ -329,8 +329,8 @@ namespace etl { } - iterator(node_t& node) - : p_node(&node) + iterator(node_t* node) + : p_node(node) { } @@ -417,13 +417,13 @@ namespace etl { } - const_iterator(node_t& node) - : p_node(&node) + const_iterator(node_t* node) + : p_node(node) { } - const_iterator(const node_t& node) - : p_node(&node) + const_iterator(const node_t* node) + : p_node(node) { } @@ -493,7 +493,7 @@ namespace etl //************************************************************************* iterator begin() { - return iterator(data_cast(get_head())); + return iterator(get_head()); } //************************************************************************* @@ -501,7 +501,7 @@ namespace etl //************************************************************************* const_iterator begin() const { - return const_iterator(data_cast(get_head())); + return const_iterator(get_head()); } //************************************************************************* @@ -509,7 +509,7 @@ namespace etl //************************************************************************* iterator before_begin() { - return iterator(static_cast(start_node)); + return iterator(&start_node); } //************************************************************************* @@ -517,7 +517,7 @@ namespace etl //************************************************************************* const_iterator before_begin() const { - return const_iterator(static_cast(start_node)); + return const_iterator(&start_node); } //************************************************************************* @@ -565,7 +565,7 @@ namespace etl //************************************************************************* reference front() { - return data_cast(get_head()).value; + return data_cast(*get_head()).value; } //************************************************************************* @@ -573,7 +573,7 @@ namespace etl //************************************************************************* const_reference front() const { - return data_cast(get_head()).value; + return data_cast(*get_head()).value; } //************************************************************************* @@ -780,7 +780,7 @@ namespace etl data_node_t& data_node = allocate_data_node(value); insert_node_after(*position.p_node, data_node); - return iterator(data_node); + return iterator(&data_node); } //************************************************************************* @@ -796,7 +796,7 @@ namespace etl ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); - return iterator(*p_data_node); + return iterator(p_data_node); } //************************************************************************* @@ -812,7 +812,7 @@ namespace etl ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); - return iterator(*p_data_node); + return iterator(p_data_node); } //************************************************************************* @@ -828,7 +828,7 @@ namespace etl ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); - return iterator(*p_data_node); + return iterator(p_data_node); } //************************************************************************* @@ -844,7 +844,7 @@ namespace etl ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); - return iterator(*p_data_node); + return iterator(p_data_node); } //************************************************************************* @@ -931,7 +931,7 @@ namespace etl } else { - return iterator(*p_last); + return iterator(p_last); } } else @@ -1023,7 +1023,7 @@ namespace etl return; } - node_t* last = &get_head(); + node_t* last = get_head(); node_t* current = last->next; while (current != nullptr) diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 3f6394c3..49ec0e97 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -278,17 +278,17 @@ namespace etl //************************************************************************* /// Get the head link. //************************************************************************* - link_type& get_head() + link_type* get_head() { - return *start_link.etl_next; + return start_link.etl_next; } //************************************************************************* /// Get the head link. //************************************************************************* - const link_type& get_head() const + const link_type* get_head() const { - return *start_link.etl_next; + return start_link.etl_next; } //************************************************************************* @@ -338,8 +338,8 @@ namespace etl { } - iterator(value_type& value) - : p_value(&value) + iterator(value_type* value) + : p_value(value) { } @@ -428,8 +428,8 @@ namespace etl { } - const_iterator(const value_type& value) - : p_value(&value) + const_iterator(const value_type* value) + : p_value(value) { } @@ -526,7 +526,7 @@ namespace etl //************************************************************************* iterator begin() { - return iterator(static_cast(this->get_head())); + return iterator(static_cast(this->get_head())); } //************************************************************************* @@ -534,7 +534,7 @@ namespace etl //************************************************************************* const_iterator begin() const { - return const_iterator(static_cast(this->get_head())); + return const_iterator(static_cast(this->get_head())); } //************************************************************************* @@ -542,7 +542,7 @@ namespace etl //************************************************************************* iterator before_begin() { - return iterator(static_cast(this->start_link)); + return iterator(&(static_cast(this->start_link))); } //************************************************************************* @@ -550,7 +550,7 @@ namespace etl //************************************************************************* const_iterator before_begin() const { - return const_iterator(static_cast(this->start_link)); + return const_iterator(&(static_cast(this->start_link))); } //************************************************************************* @@ -558,7 +558,7 @@ namespace etl //************************************************************************* const_iterator cbegin() const { - return const_iterator(static_cast(this->get_head())); + return const_iterator(static_cast(this->get_head())); } //************************************************************************* @@ -590,7 +590,7 @@ namespace etl //************************************************************************* reference front() { - return static_cast(this->get_head()); + return static_cast(*(this->get_head())); } //************************************************************************* @@ -598,7 +598,7 @@ namespace etl //************************************************************************* const_reference front() const { - return static_cast(this->get_head());; + return static_cast(*(this->get_head()));; } //************************************************************************* @@ -607,7 +607,7 @@ namespace etl iterator insert_after(iterator position, value_type& value) { this->insert_link_after(*position.p_value, value); - return iterator(value); + return iterator(&value); } //************************************************************************* @@ -686,7 +686,7 @@ namespace etl return; } - link_type* last = &this->get_head(); + link_type* last = this->get_head(); link_type* current = last->etl_next; while (current != nullptr) @@ -886,7 +886,7 @@ namespace etl { if (!other.empty()) { - link_type& first = other.get_head(); + link_type& first = *other.get_head(); if (&other != this) { @@ -982,7 +982,7 @@ namespace etl ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_forward_list_unsorted)); #endif - value_type* other_begin = static_cast(&other.get_head()); + value_type* other_begin = static_cast(other.get_head()); value_type* other_terminal = nullptr; value_type* before = static_cast(&this->start_link); diff --git a/include/etl/map.h b/include/etl/map.h index d1eb6d93..aa97d223 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -481,7 +481,7 @@ namespace etl { bool operator ()(const key_type& key1, const key_type& key2) const { - return key_compare()(key1, key2); + return compare(key1, key2); } }; @@ -492,7 +492,7 @@ namespace etl { bool operator ()(const value_type& value1, const value_type& value2) const { - return key_compare()(value1.first, value2.first); + return compare(value1.first, value2.first); } }; @@ -524,15 +524,15 @@ namespace etl //************************************************************************* bool node_comp(const Data_Node& node1, const Data_Node& node2) const { - return key_compare()(node1.value.first, node2.value.first); + return compare(node1.value.first, node2.value.first); } bool node_comp(const Data_Node& node, key_parameter_t key) const { - return key_compare()(node.value.first, key); + return compare(node.value.first, key); } bool node_comp(key_parameter_t key, const Data_Node& node) const { - return key_compare()(key, node.value.first); + return compare(key, node.value.first); } private: @@ -540,6 +540,8 @@ namespace etl /// The pool of data nodes used in the map. ipool* p_node_pool; + key_compare compare; + //************************************************************************* /// Downcast a Node* to a Data_Node* //************************************************************************* diff --git a/include/etl/multimap.h b/include/etl/multimap.h index b03dfdf6..c2526e17 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -638,7 +638,7 @@ namespace etl { bool operator ()(const key_type& key1, const key_type& key2) const { - return key_compare()(key1, key2); + return compare(key1, key2); } }; @@ -649,7 +649,7 @@ namespace etl { bool operator ()(const value_type& value1, const value_type& value2) const { - return key_compare()(value1.first, value2.first); + return compare(value1.first, value2.first); } }; @@ -676,17 +676,17 @@ namespace etl //************************************************************************* bool node_comp(const Data_Node& node1, const Data_Node& node2) const { - return key_compare()(node1.value.first, node2.value.first); + return compare(node1.value.first, node2.value.first); } bool node_comp(const Data_Node& node, key_parameter_t key) const { - return key_compare()(node.value.first, key); + return compare(node.value.first, key); } bool node_comp(key_parameter_t key, const Data_Node& node) const { - return key_compare()(key, node.value.first); + return compare(key, node.value.first); } private: @@ -694,6 +694,8 @@ namespace etl /// The pool of data nodes used in the multimap. ipool* p_node_pool; + key_compare compare; + //************************************************************************* /// Downcast a Node* to a Data_Node* //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 5c2b23d9..3c8e4d82 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -636,7 +636,7 @@ namespace etl { bool operator ()(key_type& key1, key_type& key2) const { - return key_compare()(key1, key2); + return compare(key1, key2); } }; @@ -647,7 +647,7 @@ namespace etl { bool operator ()(value_type& value1, value_type& value2) const { - return value_compare()(value1, value2); + return compare(value1, value2); } }; @@ -674,15 +674,15 @@ namespace etl //************************************************************************* bool node_comp(const Data_Node& node1, const Data_Node& node2) const { - return key_compare()(node1.value, node2.value); + return compare(node1.value, node2.value); } bool node_comp(const Data_Node& node, key_parameter_t key) const { - return key_compare()(node.value, key); + return compare(node.value, key); } bool node_comp(key_parameter_t key, const Data_Node& node) const { - return key_compare()(key, node.value); + return compare(key, node.value); } private: @@ -690,6 +690,8 @@ namespace etl /// The pool of data nodes used in the multiset. ipool* p_node_pool; + key_compare compare; + //************************************************************************* /// Downcast a Node* to a Data_Node* //************************************************************************* diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 6e0474b3..34bf15a3 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -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(), TCompare()); + std::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -182,7 +182,7 @@ namespace etl // Put element at end container.emplace_back(value1); // Make elements in container into heap - std::push_heap(container.begin(), container.end(), TCompare()); + std::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -199,7 +199,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(), TCompare()); + std::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -216,7 +216,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(), TCompare()); + std::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -233,7 +233,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(), TCompare()); + std::push_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -256,7 +256,7 @@ namespace etl clear(); container.assign(first, last); - std::make_heap(container.begin(), container.end(), TCompare()); + std::make_heap(container.begin(), container.end(), compare); } //************************************************************************* @@ -266,7 +266,7 @@ namespace etl void pop() { // Move largest element to end - std::pop_heap(container.begin(), container.end(), TCompare()); + std::pop_heap(container.begin(), container.end(), compare); // Actually remove largest element at end container.pop_back(); } @@ -356,6 +356,8 @@ namespace etl /// The container specified at instantiation of the priority_queue TContainer container; + + TCompare compare; }; //*************************************************************************** diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 5ff5a908..840b7497 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -329,19 +329,21 @@ namespace etl //********************************************************************* /// How to compare elements and keys. //********************************************************************* - class compare + class Compare { public: bool operator ()(const value_type& element, key_type key) const { - return key_compare()(element.first, key); + return comp(element.first, key); } bool operator ()(key_type key, const value_type& element) const { - return key_compare()(key, element.first); + return comp(key, element.first); } + + key_compare comp; }; public: @@ -690,7 +692,7 @@ namespace etl //********************************************************************* iterator lower_bound(key_parameter_t key) { - return std::lower_bound(begin(), end(), key, compare()); + return std::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -700,7 +702,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(key_parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare()); + return std::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -710,7 +712,7 @@ namespace etl //********************************************************************* iterator upper_bound(key_parameter_t key) { - return std::upper_bound(begin(), end(), key, compare()); + return std::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -720,7 +722,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(key_parameter_t key) const { - return std::upper_bound(begin(), end(), key, compare()); + return std::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -730,9 +732,9 @@ namespace etl //********************************************************************* std::pair equal_range(key_parameter_t key) { - iterator i_lower = std::lower_bound(begin(), end(), key, compare()); + iterator i_lower = std::lower_bound(begin(), end(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare())); + return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); } //********************************************************************* @@ -742,9 +744,9 @@ namespace etl //********************************************************************* std::pair equal_range(key_parameter_t key) const { - const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare()); + const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare())); + return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); } //************************************************************************* @@ -855,6 +857,8 @@ namespace etl lookup_t& lookup; + Compare compare; + //************************************************************************* /// Destructor. //************************************************************************* diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 3088aa75..88adde96 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -304,19 +304,21 @@ namespace etl //********************************************************************* /// How to compare elements and keys. //********************************************************************* - class compare + class Compare { public: bool operator ()(const value_type& element, key_type key) const { - return key_compare()(element.first, key); + return comp(element.first, key); } bool operator ()(key_type key, const value_type& element) const { - return key_compare()(key, element.first); + return comp(key, element.first); } + + key_compare comp; }; public: @@ -612,7 +614,7 @@ namespace etl //********************************************************************* iterator lower_bound(key_parameter_t key) { - return std::lower_bound(begin(), end(), key, compare()); + return std::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -622,7 +624,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(key_parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, compare()); + return std::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -632,7 +634,7 @@ namespace etl //********************************************************************* iterator upper_bound(key_parameter_t key) { - return std::upper_bound(begin(), end(), key, compare()); + return std::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -642,7 +644,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(key_parameter_t key) const { - return std::upper_bound(begin(), end(), key, compare()); + return std::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -652,9 +654,9 @@ namespace etl //********************************************************************* std::pair equal_range(key_parameter_t key) { - iterator i_lower = std::lower_bound(begin(), end(), key, compare()); + iterator i_lower = std::lower_bound(begin(), end(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare())); + return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); } //********************************************************************* @@ -664,9 +666,9 @@ namespace etl //********************************************************************* std::pair equal_range(key_parameter_t key) const { - const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare()); + const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); - return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare())); + return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); } //************************************************************************* @@ -768,6 +770,8 @@ namespace etl lookup_t& lookup; + Compare compare; + //************************************************************************* /// Destructor. //************************************************************************* diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index 11f89c8f..1cf5ca32 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -460,9 +460,9 @@ namespace etl { std::pair result(end(), false); - ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full)); + ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full)); - iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare()); + iterator i_element = std::lower_bound(begin(), end(), value, compare); if (i_element == end()) { @@ -566,7 +566,7 @@ namespace etl //********************************************************************* iterator find(parameter_t key) { - iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare()); + iterator itr = 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, TKeyCompare()); + const_iterator itr = std::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -626,7 +626,7 @@ namespace etl //********************************************************************* iterator lower_bound(parameter_t key) { - return std::lower_bound(begin(), end(), key, TKeyCompare()); + return 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, TKeyCompare()); + return 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, TKeyCompare()); + return 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, TKeyCompare()); + return std::upper_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -666,7 +666,7 @@ namespace etl //********************************************************************* std::pair equal_range(parameter_t key) { - return std::equal_range(begin(), end(), key, TKeyCompare()); + return std::equal_range(begin(), end(), key, compare); } //********************************************************************* @@ -676,7 +676,7 @@ namespace etl //********************************************************************* std::pair equal_range(parameter_t key) const { - return std::equal_range(begin(), end(), key, TKeyCompare()); + return std::equal_range(begin(), end(), key, compare); } //************************************************************************* @@ -783,6 +783,8 @@ namespace etl lookup_t& lookup; + TKeyCompare compare; + //************************************************************************* /// Destructor. //************************************************************************* diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 0247ffc5..cfbc4793 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -546,7 +546,7 @@ namespace etl //********************************************************************* iterator find(parameter_t key) { - iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare()); + iterator itr = std::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -570,7 +570,7 @@ namespace etl //********************************************************************* const_iterator find(parameter_t key) const { - const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare()); + const_iterator itr = std::lower_bound(begin(), end(), key, compare); if (itr != end()) { @@ -604,7 +604,7 @@ namespace etl //********************************************************************* iterator lower_bound(parameter_t key) { - return std::lower_bound(begin(), end(), key, TKeyCompare()); + return std::lower_bound(begin(), end(), key, compare); } //********************************************************************* @@ -614,7 +614,7 @@ namespace etl //********************************************************************* const_iterator lower_bound(parameter_t key) const { - return std::lower_bound(cbegin(), cend(), key, TKeyCompare()); + return std::lower_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -624,7 +624,7 @@ namespace etl //********************************************************************* iterator upper_bound(parameter_t key) { - return std::upper_bound(begin(), end(), key, TKeyCompare()); + return std::upper_bound(begin(), end(), key, compare); } //********************************************************************* @@ -634,7 +634,7 @@ namespace etl //********************************************************************* const_iterator upper_bound(parameter_t key) const { - return std::upper_bound(cbegin(), cend(), key, TKeyCompare()); + return std::upper_bound(cbegin(), cend(), key, compare); } //********************************************************************* @@ -644,7 +644,7 @@ namespace etl //********************************************************************* std::pair equal_range(parameter_t key) { - return std::equal_range(begin(), end(), key, TKeyCompare()); + return std::equal_range(begin(), end(), key, compare); } //********************************************************************* @@ -654,7 +654,7 @@ namespace etl //********************************************************************* std::pair equal_range(parameter_t key) const { - return std::upper_bound(cbegin(), cend(), key, TKeyCompare()); + return std::upper_bound(cbegin(), cend(), key, compare); } //************************************************************************* @@ -745,7 +745,7 @@ namespace etl result.first = i_element; // Existing element? - if (TKeyCompare()(value, *i_element) || TKeyCompare()(*i_element, value)) + if (compare(value, *i_element) || compare(*i_element, value)) { // A new one. ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_set_full)); @@ -765,6 +765,8 @@ namespace etl lookup_t& lookup; + TKeyCompare compare; + //************************************************************************* /// Destructor. //************************************************************************* diff --git a/include/etl/set.h b/include/etl/set.h index 31f0ff7d..38049700 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -474,7 +474,7 @@ namespace etl { bool operator ()(key_type& key1, key_type& key2) const { - return key_compare()(key1, key2); + return compare(key1, key2); } }; @@ -485,7 +485,7 @@ namespace etl { bool operator ()(value_type& value1, value_type& value2) const { - return value_compare()(value1, value2); + return compare(value1, value2); } }; @@ -512,17 +512,17 @@ namespace etl //************************************************************************* bool node_comp(const Data_Node& node1, const Data_Node& node2) const { - return key_compare()(node1.value, node2.value); + return compare(node1.value, node2.value); } bool node_comp(const Data_Node& node, key_parameter_t key) const { - return key_compare()(node.value, key); + return compare(node.value, key); } bool node_comp(key_parameter_t key, const Data_Node& node) const { - return key_compare()(key, node.value); + return compare(key, node.value); } private: @@ -530,6 +530,8 @@ namespace etl /// The pool of data nodes used in the set. etl::ipool* p_node_pool; + key_compare compare; + //************************************************************************* /// Downcast a Node* to a Data_Node* //************************************************************************* diff --git a/include/etl/stl/alternate/limits.h b/include/etl/stl/alternate/limits.h index b8bf99a4..680cf7f9 100644 --- a/include/etl/stl/alternate/limits.h +++ b/include/etl/stl/alternate/limits.h @@ -34,6 +34,7 @@ SOFTWARE. #include "../../platform.h" #include "../../type_traits.h" #include "../../char_traits.h" +#include "../../integral_limits.h" #include #include diff --git a/include/etl/variant.h b/include/etl/variant.h index a539fe3f..26e9c124 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -874,18 +874,18 @@ namespace etl /// Calls the supplied reader instance. /// The 'read' function appropriate to the current type is called with the stored value. //*************************************************************************** - void call(reader& reader) + void call(reader& r) { switch (type_id) { - case 0: reader.read(static_cast(data)); break; - case 1: reader.read(static_cast(data)); break; - case 2: reader.read(static_cast(data)); break; - case 3: reader.read(static_cast(data)); break; - case 4: reader.read(static_cast(data)); break; - case 5: reader.read(static_cast(data)); break; - case 6: reader.read(static_cast(data)); break; - case 7: reader.read(static_cast(data)); break; + case 0: r.read(static_cast(data)); break; + case 1: r.read(static_cast(data)); break; + case 2: r.read(static_cast(data)); break; + case 3: r.read(static_cast(data)); break; + case 4: r.read(static_cast(data)); break; + case 5: r.read(static_cast(data)); break; + case 6: r.read(static_cast(data)); break; + case 7: r.read(static_cast(data)); break; default: break; } } diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index 068d0d3a..e5b6f295 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -64,7 +64,7 @@ SOFTWARE. #include "alignment.h" #include "static_assert.h" #include "type_lookup.h" -#include +#include "pool.h" #undef ETL_FILE #define ETL_FILE "40" diff --git a/include/etl/version.h b/include/etl/version.h index 65cec320..1b6c4836 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,13 +37,13 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.14.2" -#define ETL_VERSION_W L"11.14.2" -#define ETL_VERSION_U16 u"11.14.2" -#define ETL_VERSION_U32 U"11.14.2" +#define ETL_VERSION "11.14.3" +#define ETL_VERSION_W L"11.14.3" +#define ETL_VERSION_U16 u"11.14.3" +#define ETL_VERSION_U32 U"11.14.3" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_PATCH 3 #define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH) #endif diff --git a/src/binary.cpp b/src/binary.cpp index 7f676070..0024e56e 100644 --- a/src/binary.cpp +++ b/src/binary.cpp @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "platform.h" -#include "binary.h" +#include "etl/platform.h" +#include "etl/binary.h" namespace etl { diff --git a/src/crc16.cpp b/src/crc16.cpp index 734d379b..9ac1d710 100644 --- a/src/crc16.cpp +++ b/src/crc16.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc16_ccitt.cpp b/src/crc16_ccitt.cpp index 443873a9..12b79a76 100644 --- a/src/crc16_ccitt.cpp +++ b/src/crc16_ccitt.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc16_kermit.cpp b/src/crc16_kermit.cpp index 93836b02..3c44e043 100644 --- a/src/crc16_kermit.cpp +++ b/src/crc16_kermit.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc32.cpp b/src/crc32.cpp index 6ef84f49..c9217577 100644 --- a/src/crc32.cpp +++ b/src/crc32.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc32_c.cpp b/src/crc32_c.cpp index 22700a32..1c54c3f6 100644 --- a/src/crc32_c.cpp +++ b/src/crc32_c.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc64_ecma.cpp b/src/crc64_ecma.cpp index 82a92b0e..f818611e 100644 --- a/src/crc64_ecma.cpp +++ b/src/crc64_ecma.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "platform.h" +#include "etl/platform.h" namespace etl { diff --git a/src/crc8_ccitt.cpp b/src/crc8_ccitt.cpp index 15b80cc9..5a224aff 100644 --- a/src/crc8_ccitt.cpp +++ b/src/crc8_ccitt.cpp @@ -30,8 +30,8 @@ SOFTWARE. #include -#include "platform.h" -#include "static_assert.h" +#include "etl/platform.h" +#include "etl/static_assert.h" ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); diff --git a/src/error_handler.cpp b/src/error_handler.cpp index 2107e0b5..7f3f3e0c 100644 --- a/src/error_handler.cpp +++ b/src/error_handler.cpp @@ -28,9 +28,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "platform.h" -#include "error_handler.h" -#include "nullptr.h" +#include "etl/platform.h" +#include "etl/error_handler.h" +#include "etl/nullptr.h" //***************************************************************************** /// The error function callback pointer. diff --git a/src/pearson.cpp b/src/pearson.cpp index 0852c7e5..7051d254 100644 --- a/src/pearson.cpp +++ b/src/pearson.cpp @@ -30,8 +30,8 @@ SOFTWARE. #include -#include "platform.h" -#include "static_assert.h" +#include "etl/platform.h" +#include "etl/static_assert.h" ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type"); diff --git a/src/random.cpp b/src/random.cpp index 4edb6188..ba1b0ba9 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "platform.h" -#include "random.h" +#include "etl/platform.h" +#include "etl/random.h" namespace etl { diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 7a3eee9d..a3c7d0cb 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -61,18 +61,18 @@ - - - - + + + + - + diff --git a/test/data.h b/test/data.h index 0fbf9ed6..c43769e8 100644 --- a/test/data.h +++ b/test/data.h @@ -31,7 +31,7 @@ SOFTWARE. #include -#include "instance_count.h" +#include "etl/instance_count.h" //***************************************************************************** // Default constructor. diff --git a/test/etl_profile.h b/test/etl_profile.h index 213e99ea..e5cc186b 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -77,9 +77,9 @@ SOFTWARE. //#define ETL_NO_STL #ifdef _MSC_VER - #include "profiles/msvc_x86.h" + #include "etl/profiles/msvc_x86.h" #else - #include "profiles/gcc_windows_x86.h" + #include "etl/profiles/gcc_windows_x86.h" #endif #endif diff --git a/test/murmurhash3.cpp b/test/murmurhash3.cpp index 39663531..31d812e1 100644 --- a/test/murmurhash3.cpp +++ b/test/murmurhash3.cpp @@ -7,7 +7,7 @@ // compile and run any of them on any platform, but your performance with the // non-native version will be less than optimal. -#include "platform.h" +#include "etl/platform.h" #ifdef ETL_COMPILER_GCC #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" diff --git a/test/murmurhash3.h b/test/murmurhash3.h index 42f8ef74..46ac322a 100644 --- a/test/murmurhash3.h +++ b/test/murmurhash3.h @@ -10,7 +10,7 @@ // Microsoft Visual Studio -#include "platform.h" +#include "etl/platform.h" #if defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER < 1600) diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index 52984cc9..f7eea553 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "algorithm.h" -#include "container.h" +#include "etl/algorithm.h" +#include "etl/container.h" #include #include diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index ba0b25ab..7a03a248 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "alignment.h" -#include "type_traits.h" +#include "etl/alignment.h" +#include "etl/type_traits.h" #include #include diff --git a/test/test_array.cpp b/test/test_array.cpp index 993be93b..28024f19 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -28,13 +28,13 @@ SOFTWARE. #include "UnitTest++.h" -#include "array.h" +#include "etl/array.h" #include #include #include -#include "integral_limits.h" +#include "etl/integral_limits.h" namespace { diff --git a/test/test_array_view.cpp b/test/test_array_view.cpp index 875b4bb7..1ada4ddc 100644 --- a/test/test_array_view.cpp +++ b/test/test_array_view.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "array_view.h" -#include "array.h" +#include "etl/array_view.h" +#include "etl/array.h" #include #include diff --git a/test/test_array_wrapper.cpp b/test/test_array_wrapper.cpp index b803575a..461f3190 100644 --- a/test/test_array_wrapper.cpp +++ b/test/test_array_wrapper.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "array_wrapper.h" +#include "etl/array_wrapper.h" namespace { diff --git a/test/test_atomic_gcc_sync.cpp b/test/test_atomic_gcc_sync.cpp index 9af9c77e..8f26a827 100644 --- a/test/test_atomic_gcc_sync.cpp +++ b/test/test_atomic_gcc_sync.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "platform.h" -#include "atomic/atomic_std.h" +#include "etl/platform.h" +#include "etl/atomic/atomic_std.h" #include diff --git a/test/test_atomic_std.cpp b/test/test_atomic_std.cpp index d89872a9..f1655549 100644 --- a/test/test_atomic_std.cpp +++ b/test/test_atomic_std.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "platform.h" -#include "atomic/atomic_std.h" +#include "etl/platform.h" +#include "etl/atomic/atomic_std.h" #include diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 35cd1c53..6923a0f7 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -31,10 +31,10 @@ SOFTWARE. #include #include -#include "binary.h" -#include "bitset.h" -#include "fnv_1.h" -#include "integral_limits.h" +#include "etl/binary.h" +#include "etl/bitset.h" +#include "etl/fnv_1.h" +#include "etl/integral_limits.h" // Count bits the easy way. template diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index b3991918..6e7ea3fc 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "bitset.h" +#include "etl/bitset.h" namespace { diff --git a/test/test_bloom_filter.cpp b/test/test_bloom_filter.cpp index 7a275768..77853300 100644 --- a/test/test_bloom_filter.cpp +++ b/test/test_bloom_filter.cpp @@ -31,14 +31,14 @@ SOFTWARE. #include #include -#include "bloom_filter.h" +#include "etl/bloom_filter.h" -#include "fnv_1.h" -#include "crc16.h" -#include "crc16_ccitt.h" -#include "crc32.h" +#include "etl/fnv_1.h" +#include "etl/crc16.h" +#include "etl/crc16_ccitt.h" +#include "etl/crc32.h" -#include "char_traits.h" +#include "etl/char_traits.h" struct hash1_t { diff --git a/test/test_bsd_checksum.cpp b/test/test_bsd_checksum.cpp index 0f4cadef..0197d3cf 100644 --- a/test/test_bsd_checksum.cpp +++ b/test/test_bsd_checksum.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "checksum.h" +#include "etl/checksum.h" namespace { diff --git a/test/test_c_timer_framework.cpp b/test/test_c_timer_framework.cpp index 00e98536..d332f41f 100644 --- a/test/test_c_timer_framework.cpp +++ b/test/test_c_timer_framework.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "platform.h" +#include "etl/platform.h" extern "C" { diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index d5197d3a..b0ad6fa9 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -29,8 +29,8 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "callback_timer.h" -#include "function.h" +#include "etl/callback_timer.h" +#include "etl/function.h" #include #include diff --git a/test/test_checksum.cpp b/test/test_checksum.cpp index f7a45d9d..60add3e0 100644 --- a/test/test_checksum.cpp +++ b/test/test_checksum.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "checksum.h" +#include "etl/checksum.h" namespace { diff --git a/test/test_compare.cpp b/test/test_compare.cpp index 3c2d65f5..b09d3c8d 100644 --- a/test/test_compare.cpp +++ b/test/test_compare.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "compare.h" +#include "etl/compare.h" namespace { diff --git a/test/test_constant.cpp b/test/test_constant.cpp index 6cd1587a..4f18979d 100644 --- a/test/test_constant.cpp +++ b/test/test_constant.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "constant.h" -#include "integral_limits.h" +#include "etl/constant.h" +#include "etl/integral_limits.h" #include #include diff --git a/test/test_container.cpp b/test/test_container.cpp index 3c441f95..d78e460b 100644 --- a/test/test_container.cpp +++ b/test/test_container.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "container.h" +#include "etl/container.h" #include diff --git a/test/test_crc.cpp b/test/test_crc.cpp index a376e02d..9cb3bc5b 100644 --- a/test/test_crc.cpp +++ b/test/test_crc.cpp @@ -33,12 +33,12 @@ SOFTWARE. #include #include -#include "crc8_ccitt.h" -#include "crc16.h" -#include "crc16_ccitt.h" -#include "crc16_kermit.h" -#include "crc32.h" -#include "crc64_ecma.h" +#include "etl/crc8_ccitt.h" +#include "etl/crc16.h" +#include "etl/crc16_ccitt.h" +#include "etl/crc16_kermit.h" +#include "etl/crc32.h" +#include "etl/crc64_ecma.h" namespace { diff --git a/test/test_cyclic_value.cpp b/test/test_cyclic_value.cpp index 14a9ab94..ce92742c 100644 --- a/test/test_cyclic_value.cpp +++ b/test/test_cyclic_value.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "cyclic_value.h" +#include "etl/cyclic_value.h" namespace { diff --git a/test/test_debounce.cpp b/test/test_debounce.cpp index bab33073..8424e77e 100644 --- a/test/test_debounce.cpp +++ b/test/test_debounce.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "debounce.h" +#include "etl/debounce.h" namespace { diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 869bdfcd..06a1975f 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "deque.h" +#include "etl/deque.h" #include "data.h" diff --git a/test/test_embedded_compile.cpp b/test/test_embedded_compile.cpp index 12b78f7d..4d589371 100644 --- a/test/test_embedded_compile.cpp +++ b/test/test_embedded_compile.cpp @@ -1,30 +1,30 @@ -#include "algorithm.h" -#include "alignment.h" -#include "array.h" -#include "bitset.h" -#include "container.h" -#include "crc8_ccitt.h" -#include "crc16.h" -#include "crc16_ccitt.h" -#include "crc16_kermit.h" -#include "crc32.h" -#include "crc64_ecma.h" -#include "cyclic_value.h" -#include "deque.h" -#include "io_port.h" -#include "vector.h" -#include "variant.h" -#include "list.h" -#include "map.h" -#include "integral_limits.h" -#include "constant.h" +#include "etl/algorithm.h" +#include "etl/alignment.h" +#include "etl/array.h" +#include "etl/bitset.h" +#include "etl/container.h" +#include "etl/crc8_ccitt.h" +#include "etl/crc16.h" +#include "etl/crc16_ccitt.h" +#include "etl/crc16_kermit.h" +#include "etl/crc32.h" +#include "etl/crc64_ecma.h" +#include "etl/cyclic_value.h" +#include "etl/deque.h" +#include "etl/io_port.h" +#include "etl/vector.h" +#include "etl/variant.h" +#include "etl/list.h" +#include "etl/map.h" +#include "etl/integral_limits.h" +#include "etl/constant.h" #include #if !defined(ETL_COMPILER_IAR) & !defined(ETL_COMPILER_TI) -#include "stm32f4xx.h" +#include "etl/stm32f4xx.h" #endif #if defined(COMPILER_KEIL) diff --git a/test/test_endian.cpp b/test/test_endian.cpp index 4028eb3e..fa174a85 100644 --- a/test/test_endian.cpp +++ b/test/test_endian.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include -#include "endianness.h" +#include "etl/endianness.h" namespace { diff --git a/test/test_enum_type.cpp b/test/test_enum_type.cpp index 5db8bd18..e59e8ff5 100644 --- a/test/test_enum_type.cpp +++ b/test/test_enum_type.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include -#include "enum_type.h" +#include "etl/enum_type.h" struct enum_test { diff --git a/test/test_error_handler.cpp b/test/test_error_handler.cpp index b50ce2dd..9dc07f9d 100644 --- a/test/test_error_handler.cpp +++ b/test/test_error_handler.cpp @@ -33,8 +33,8 @@ SOFTWARE. #include #include -#include "error_handler.h" -#include "exception.h" +#include "etl/error_handler.h" +#include "etl/exception.h" bool error_received; diff --git a/test/test_exception.cpp b/test/test_exception.cpp index 4fa95c34..333842c3 100644 --- a/test/test_exception.cpp +++ b/test/test_exception.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include -#include "exception.h" +#include "etl/exception.h" namespace { diff --git a/test/test_factory.cpp b/test/test_factory.cpp index 70d6a824..e11b6ef0 100644 --- a/test/test_factory.cpp +++ b/test/test_factory.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "factory.h" +#include "etl/factory.h" #include #include diff --git a/test/test_fixed_iterator.cpp b/test/test_fixed_iterator.cpp index ae580c92..4905739e 100644 --- a/test/test_fixed_iterator.cpp +++ b/test/test_fixed_iterator.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include #include -#include "fixed_iterator.h" +#include "etl/fixed_iterator.h" template std::ostream& operator << (std::ostream& os, const etl::fixed_iterator& fi) diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index c290da7f..456bf688 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -40,7 +40,7 @@ SOFTWARE. #include "data.h" -#include "flat_map.h" +#include "etl/flat_map.h" namespace { @@ -309,6 +309,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), SIZE); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index 2c2486cb..7a7a3380 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "flat_multimap.h" +#include "etl/flat_multimap.h" namespace { @@ -286,6 +286,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), SIZE); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index e9bccba0..00cac75d 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "flat_multiset.h" +#include "etl/flat_multiset.h" namespace { @@ -255,6 +255,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), SIZE); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index 1e0e9982..a5983cf3 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "flat_set.h" +#include "etl/flat_set.h" namespace { @@ -267,6 +267,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), SIZE); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_fnv_1.cpp b/test/test_fnv_1.cpp index fd6d6c27..a852dce9 100644 --- a/test/test_fnv_1.cpp +++ b/test/test_fnv_1.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "fnv_1.h" +#include "etl/fnv_1.h" namespace { diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index 98827bb3..cb795c93 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -31,7 +31,7 @@ SOFTWARE. #include "data.h" -#include "forward_list.h" +#include "etl/forward_list.h" #include #include @@ -87,6 +87,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index cbc6d376..0418a862 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -28,11 +28,11 @@ SOFTWARE. #include "UnitTest++.h" -#include "fsm.h" -#include "enum_type.h" -#include "container.h" -#include "packet.h" -#include "queue.h" +#include "etl/fsm.h" +#include "etl/enum_type.h" +#include "etl/container.h" +#include "etl/packet.h" +#include "etl/queue.h" #include diff --git a/test/test_function.cpp b/test/test_function.cpp index d82e3cae..cc92263c 100644 --- a/test/test_function.cpp +++ b/test/test_function.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "function.h" +#include "etl/function.h" //***************************************************************************** const int VALUE = 1; diff --git a/test/test_functional.cpp b/test/test_functional.cpp index 8a3ce993..8e2cd1a5 100644 --- a/test/test_functional.cpp +++ b/test/test_functional.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "functional.h" +#include "etl/functional.h" #include #include diff --git a/test/test_hash.cpp b/test/test_hash.cpp index c9fbc425..1a4e024d 100644 --- a/test/test_hash.cpp +++ b/test/test_hash.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "hash.h" +#include "etl/hash.h" namespace { diff --git a/test/test_instance_count.cpp b/test/test_instance_count.cpp index 72e5512c..6a0b817b 100644 --- a/test/test_instance_count.cpp +++ b/test/test_instance_count.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "instance_count.h" +#include "etl/instance_count.h" #include #include diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index 8a23abf8..d461053f 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "integral_limits.h" +#include "etl/integral_limits.h" namespace { diff --git a/test/test_intrusive_forward_list.cpp b/test/test_intrusive_forward_list.cpp index 982e6e74..b2d3f9d0 100644 --- a/test/test_intrusive_forward_list.cpp +++ b/test/test_intrusive_forward_list.cpp @@ -31,7 +31,7 @@ SOFTWARE. #include "data.h" -#include "intrusive_forward_list.h" +#include "etl/intrusive_forward_list.h" #include #include diff --git a/test/test_intrusive_links.cpp b/test/test_intrusive_links.cpp index d98570be..b9304ca8 100644 --- a/test/test_intrusive_links.cpp +++ b/test/test_intrusive_links.cpp @@ -31,7 +31,7 @@ SOFTWARE. #include "data.h" -#include "intrusive_links.h" +#include "etl/intrusive_links.h" namespace { diff --git a/test/test_intrusive_list.cpp b/test/test_intrusive_list.cpp index 4d85c00a..382c771c 100644 --- a/test/test_intrusive_list.cpp +++ b/test/test_intrusive_list.cpp @@ -31,7 +31,7 @@ SOFTWARE. #include "data.h" -#include "intrusive_list.h" +#include "etl/intrusive_list.h" #include #include diff --git a/test/test_intrusive_queue.cpp b/test/test_intrusive_queue.cpp index 3c6f5849..ebd37ad8 100644 --- a/test/test_intrusive_queue.cpp +++ b/test/test_intrusive_queue.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "intrusive_queue.h" -#include "intrusive_links.h" +#include "etl/intrusive_queue.h" +#include "etl/intrusive_links.h" #include diff --git a/test/test_intrusive_stack.cpp b/test/test_intrusive_stack.cpp index f6340479..5b752a87 100644 --- a/test/test_intrusive_stack.cpp +++ b/test/test_intrusive_stack.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "intrusive_stack.h" -#include "intrusive_links.h" +#include "etl/intrusive_stack.h" +#include "etl/intrusive_links.h" #include diff --git a/test/test_io_port.cpp b/test/test_io_port.cpp index 398c5bc8..88223339 100644 --- a/test/test_io_port.cpp +++ b/test/test_io_port.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "io_port.h" +#include "etl/io_port.h" #include #include diff --git a/test/test_iterator.cpp b/test/test_iterator.cpp index 1505b972..728fb09b 100644 --- a/test/test_iterator.cpp +++ b/test/test_iterator.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "iterator.h" +#include "etl/iterator.h" //#include diff --git a/test/test_jenkins.cpp b/test/test_jenkins.cpp index 1f6aa80e..3b2f8647 100644 --- a/test/test_jenkins.cpp +++ b/test/test_jenkins.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "jenkins.h" +#include "etl/jenkins.h" template uint32_t jenkins(TIterator begin, TIterator end) diff --git a/test/test_largest.cpp b/test/test_largest.cpp index 48eec18a..f420ede1 100644 --- a/test/test_largest.cpp +++ b/test/test_largest.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "largest.h" +#include "etl/largest.h" #include diff --git a/test/test_list.cpp b/test/test_list.cpp index a96e1127..02305747 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "list.h" +#include "etl/list.h" #include "data.h" @@ -98,6 +98,7 @@ namespace CHECK_EQUAL(data.size(), size_t(0)); CHECK(data.empty()); CHECK_EQUAL(data.max_size(), SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_map.cpp b/test/test_map.cpp index 1881f0e2..c1cdedec 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -36,7 +36,7 @@ SOFTWARE. #include #include -#include "map.h" +#include "etl/map.h" static const size_t MAX_SIZE = 10; @@ -181,6 +181,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), MAX_SIZE); CHECK_EQUAL(data.max_size(), MAX_SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_maths.cpp b/test/test_maths.cpp index 4d42f3c6..636fe335 100644 --- a/test/test_maths.cpp +++ b/test/test_maths.cpp @@ -28,13 +28,13 @@ SOFTWARE. #include "UnitTest++.h" -#include "log.h" -#include "power.h" -#include "fibonacci.h" -#include "factorial.h" -#include "sqrt.h" -#include "permutations.h" -#include "combinations.h" +#include "etl/log.h" +#include "etl/power.h" +#include "etl/fibonacci.h" +#include "etl/factorial.h" +#include "etl/sqrt.h" +#include "etl/permutations.h" +#include "etl/combinations.h" namespace { diff --git a/test/test_memory.cpp b/test/test_memory.cpp index 85eab67a..a0448891 100644 --- a/test/test_memory.cpp +++ b/test/test_memory.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include "UnitTest++.h" -#include "memory.h" -#include "debug_count.h" +#include "etl/memory.h" +#include "etl/debug_count.h" #include #include diff --git a/test/test_message_bus.cpp b/test/test_message_bus.cpp index 42ad6118..2bf23e94 100644 --- a/test/test_message_bus.cpp +++ b/test/test_message_bus.cpp @@ -29,11 +29,11 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "message_router.h" -#include "message_bus.h" -#include "queue.h" -#include "largest.h" -#include "packet.h" +#include "etl/message_router.h" +#include "etl/message_bus.h" +#include "etl/queue.h" +#include "etl/largest.h" +#include "etl/packet.h" //*************************************************************************** // The set of messages. diff --git a/test/test_message_router.cpp b/test/test_message_router.cpp index 45598673..60f19273 100644 --- a/test/test_message_router.cpp +++ b/test/test_message_router.cpp @@ -29,10 +29,10 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "message_router.h" -#include "queue.h" -#include "largest.h" -#include "packet.h" +#include "etl/message_router.h" +#include "etl/queue.h" +#include "etl/largest.h" +#include "etl/packet.h" //*************************************************************************** // The set of messages. diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index 392cd31a..c457e759 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -29,9 +29,9 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "message_router.h" -#include "message_bus.h" -#include "message_timer.h" +#include "etl/message_router.h" +#include "etl/message_bus.h" +#include "etl/message_timer.h" #include #include diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index 9954afbc..018ff277 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include #include -#include "multimap.h" +#include "etl/multimap.h" static const size_t MAX_SIZE = 10; @@ -181,6 +181,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), MAX_SIZE); CHECK_EQUAL(data.max_size(), MAX_SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index 03813ba0..14982819 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include #include -#include "multiset.h" +#include "etl/multiset.h" static const size_t MAX_SIZE = 10; @@ -173,6 +173,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), MAX_SIZE); CHECK_EQUAL(data.max_size(), MAX_SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index d1185459..a4a61a5c 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include #include -#include "murmur3.h" +#include "etl/murmur3.h" namespace { diff --git a/test/test_no_stl_algorithm.cpp b/test/test_no_stl_algorithm.cpp index f29b4f9d..23ae4ef9 100644 --- a/test/test_no_stl_algorithm.cpp +++ b/test/test_no_stl_algorithm.cpp @@ -31,7 +31,7 @@ SOFTWARE. #undef min #undef max -#include "../include/etl/stl/alternate/algorithm.h" +#include "etl/stl/alternate/algorithm.h" #include #include diff --git a/test/test_no_stl_functional.cpp b/test/test_no_stl_functional.cpp index 8b92a715..90eb26e1 100644 --- a/test/test_no_stl_functional.cpp +++ b/test/test_no_stl_functional.cpp @@ -31,7 +31,7 @@ SOFTWARE. #undef min #undef max -#include "../include/etl/stl/alternate/functional.h" +#include "etl/stl/alternate/functional.h" namespace { diff --git a/test/test_no_stl_limits.cpp b/test/test_no_stl_limits.cpp index 4035020b..21df7ce4 100644 --- a/test/test_no_stl_limits.cpp +++ b/test/test_no_stl_limits.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "../include/etl/stl/alternate/limits.h" +#include "etl/stl/alternate/limits.h" #include diff --git a/test/test_no_stl_utility.cpp b/test/test_no_stl_utility.cpp index 441ef930..d4d10d67 100644 --- a/test/test_no_stl_utility.cpp +++ b/test/test_no_stl_utility.cpp @@ -31,7 +31,7 @@ SOFTWARE. #undef min #undef max -#include "../include/etl/stl/alternate/utility.h" +#include "etl/stl/alternate/utility.h" namespace { diff --git a/test/test_numeric.cpp b/test/test_numeric.cpp index 761e4f87..a594de23 100644 --- a/test/test_numeric.cpp +++ b/test/test_numeric.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "numeric.h" +#include "etl/numeric.h" #include #include diff --git a/test/test_observer.cpp b/test/test_observer.cpp index b23a1359..3f8d62f6 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "observer.h" +#include "etl/observer.h" //***************************************************************************** // Notification1 diff --git a/test/test_optional.cpp b/test/test_optional.cpp index a8b2d665..35884641 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -31,8 +31,8 @@ SOFTWARE. #include #include -#include "optional.h" -#include "vector.h" +#include "etl/optional.h" +#include "etl/vector.h" #include "data.h" typedef TestDataNDC Data; diff --git a/test/test_packet.cpp b/test/test_packet.cpp index 010754a7..5ccecf13 100644 --- a/test/test_packet.cpp +++ b/test/test_packet.cpp @@ -29,10 +29,10 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "packet.h" -#include "largest.h" -#include "queue.h" -#include "pool.h" +#include "etl/packet.h" +#include "etl/largest.h" +#include "etl/queue.h" +#include "etl/pool.h" namespace { diff --git a/test/test_parameter_type.cpp b/test/test_parameter_type.cpp index add018ba..f4c445ae 100644 --- a/test/test_parameter_type.cpp +++ b/test/test_parameter_type.cpp @@ -31,7 +31,7 @@ SOFTWARE. #include #include -#include "parameter_type.h" +#include "etl/parameter_type.h" namespace { diff --git a/test/test_pearson.cpp b/test/test_pearson.cpp index 5ab1df1b..c4416764 100644 --- a/test/test_pearson.cpp +++ b/test/test_pearson.cpp @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include "pearson.h" +#include "etl/pearson.h" const size_t HASH_SIZE = 8; typedef etl::pearson::value_type hash_t; diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 8f14c5f2..fbd98816 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -35,8 +35,8 @@ SOFTWARE. #include #include -#include "pool.h" -#include "largest.h" +#include "etl/pool.h" +#include "etl/largest.h" #if defined(ETL_COMPILER_GCC) #pragma GCC diagnostic push diff --git a/test/test_priority_queue.cpp b/test/test_priority_queue.cpp index c8fd99e6..84aa1ee8 100644 --- a/test/test_priority_queue.cpp +++ b/test/test_priority_queue.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "priority_queue.h" +#include "etl/priority_queue.h" namespace { diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 09333a5c..0369f46b 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "queue.h" +#include "etl/queue.h" namespace { diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index 9b8b7bee..ef15fee4 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include #include -#include "queue_mpmc_mutex.h" +#include "etl/queue_mpmc_mutex.h" #if defined(ETL_COMPILER_MICROSOFT) #include diff --git a/test/test_queue_spsc_atomic.cpp b/test/test_queue_spsc_atomic.cpp index 4e5542a4..1d49cca4 100644 --- a/test/test_queue_spsc_atomic.cpp +++ b/test/test_queue_spsc_atomic.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "queue_spsc_atomic.h" +#include "etl/queue_spsc_atomic.h" #if defined(ETL_COMPILER_MICROSOFT) #include diff --git a/test/test_queue_spsc_isr.cpp b/test/test_queue_spsc_isr.cpp index 91667eb9..00623103 100644 --- a/test/test_queue_spsc_isr.cpp +++ b/test/test_queue_spsc_isr.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "queue_spsc_isr.h" +#include "etl/queue_spsc_isr.h" #include #include diff --git a/test/test_random.cpp b/test/test_random.cpp index 738e2a90..4c77912b 100644 --- a/test/test_random.cpp +++ b/test/test_random.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "random.h" +#include "etl/random.h" #include #include diff --git a/test/test_reference_flat_map.cpp b/test/test_reference_flat_map.cpp index bfcd7cda..4e0988a7 100644 --- a/test/test_reference_flat_map.cpp +++ b/test/test_reference_flat_map.cpp @@ -40,7 +40,7 @@ SOFTWARE. #include "data.h" -#include "reference_flat_map.h" +#include "etl/reference_flat_map.h" namespace { diff --git a/test/test_reference_flat_multimap.cpp b/test/test_reference_flat_multimap.cpp index c9bc8e55..58d7fc71 100644 --- a/test/test_reference_flat_multimap.cpp +++ b/test/test_reference_flat_multimap.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "reference_flat_multimap.h" +#include "etl/reference_flat_multimap.h" namespace { diff --git a/test/test_reference_flat_multiset.cpp b/test/test_reference_flat_multiset.cpp index 72c1511b..056e6a80 100644 --- a/test/test_reference_flat_multiset.cpp +++ b/test/test_reference_flat_multiset.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "reference_flat_multiset.h" +#include "etl/reference_flat_multiset.h" namespace { diff --git a/test/test_reference_flat_set.cpp b/test/test_reference_flat_set.cpp index ff943446..a38b3b4e 100644 --- a/test/test_reference_flat_set.cpp +++ b/test/test_reference_flat_set.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "data.h" -#include "reference_flat_set.h" +#include "etl/reference_flat_set.h" namespace { diff --git a/test/test_set.cpp b/test/test_set.cpp index 773aeea5..57bfc7ea 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -36,7 +36,7 @@ SOFTWARE. #include #include -#include "set.h" +#include "etl/set.h" static const size_t MAX_SIZE = 10; @@ -184,6 +184,7 @@ namespace CHECK(data.empty()); CHECK_EQUAL(data.capacity(), MAX_SIZE); CHECK_EQUAL(data.max_size(), MAX_SIZE); + CHECK(data.begin() == data.end()); } //************************************************************************* diff --git a/test/test_smallest.cpp b/test/test_smallest.cpp index 3a9a4aad..aa27cd45 100644 --- a/test/test_smallest.cpp +++ b/test/test_smallest.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "smallest.h" +#include "etl/smallest.h" #include diff --git a/test/test_stack.cpp b/test/test_stack.cpp index 74a1a164..ea7f1685 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include "data.h" -#include "stack.h" +#include "etl/stack.h" namespace { diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 948476f3..ff90ca11 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -32,8 +32,8 @@ SOFTWARE. #include #include -#include "cstring.h" -#include "fnv_1.h" +#include "etl/cstring.h" +#include "etl/fnv_1.h" #undef STR #define STR(x) x @@ -94,6 +94,7 @@ namespace CHECK(text.empty()); CHECK_EQUAL(text.capacity(), SIZE); CHECK_EQUAL(text.max_size(), SIZE); + CHECK(text.begin() == text.end()); } //************************************************************************* diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 81ed3a4a..da37ee5d 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "u16string.h" +#include "etl/u16string.h" #undef STR #define STR(x) u##x @@ -93,6 +93,7 @@ namespace CHECK(text.empty()); CHECK_EQUAL(text.capacity(), SIZE); CHECK_EQUAL(text.max_size(), SIZE); + CHECK(text.begin() == text.end()); } //************************************************************************* diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index e3f3528e..0df0425a 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "u32string.h" +#include "etl/u32string.h" #undef STR #define STR(x) U##x @@ -93,6 +93,7 @@ namespace CHECK(text.empty()); CHECK_EQUAL(text.capacity(), SIZE); CHECK_EQUAL(text.max_size(), SIZE); + CHECK(text.begin() == text.end()); } //************************************************************************* diff --git a/test/test_string_view.cpp b/test/test_string_view.cpp index 7d2f796c..353f8031 100644 --- a/test/test_string_view.cpp +++ b/test/test_string_view.cpp @@ -28,12 +28,12 @@ SOFTWARE. #include "UnitTest++.h" -#include "string_view.h" -#include "cstring.h" -#include "wstring.h" -#include "u16string.h" -#include "u32string.h" -#include "hash.h" +#include "etl/string_view.h" +#include "etl/cstring.h" +#include "etl/wstring.h" +#include "etl/u16string.h" +#include "etl/u32string.h" +#include "etl/hash.h" #include #include diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index e1cbdad2..f347c5d5 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include #include -#include "wstring.h" +#include "etl/wstring.h" #undef STR #define STR(x) L##x @@ -93,6 +93,7 @@ namespace CHECK(text.empty()); CHECK_EQUAL(text.capacity(), SIZE); CHECK_EQUAL(text.max_size(), SIZE); + CHECK(text.begin() == text.end()); } //************************************************************************* diff --git a/test/test_task_scheduler.cpp b/test/test_task_scheduler.cpp index 38f505c6..7772857d 100644 --- a/test/test_task_scheduler.cpp +++ b/test/test_task_scheduler.cpp @@ -32,9 +32,9 @@ SOFTWARE. #include #include -#include "task.h" -#include "scheduler.h" -#include "container.h" +#include "etl/task.h" +#include "etl/scheduler.h" +#include "etl/container.h" typedef std::vector WorkList_t; diff --git a/test/test_type_def.cpp b/test/test_type_def.cpp index deaa90a9..dbeb32dd 100644 --- a/test/test_type_def.cpp +++ b/test/test_type_def.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include -#include "type_def.h" +#include "etl/type_def.h" namespace { diff --git a/test/test_type_lookup.cpp b/test/test_type_lookup.cpp index c944a9bd..1d6a2015 100644 --- a/test/test_type_lookup.cpp +++ b/test/test_type_lookup.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "type_lookup.h" +#include "etl/type_lookup.h" #include diff --git a/test/test_type_select.cpp b/test/test_type_select.cpp index 7ea7ecff..dec01aea 100644 --- a/test/test_type_select.cpp +++ b/test/test_type_select.cpp @@ -29,8 +29,8 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "type_select.h" -#include "null_type.h" +#include "etl/type_select.h" +#include "etl/null_type.h" #include diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index cd57f45d..25304d95 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -38,7 +38,7 @@ namespace std } #endif -#include "type_traits.h" +#include "etl/type_traits.h" #include namespace diff --git a/test/test_unordered_map.cpp b/test/test_unordered_map.cpp index 470fbecd..c5f5c73c 100644 --- a/test/test_unordered_map.cpp +++ b/test/test_unordered_map.cpp @@ -39,7 +39,7 @@ SOFTWARE. #include "data.h" -#include "unordered_map.h" +#include "etl/unordered_map.h" namespace { diff --git a/test/test_unordered_multimap.cpp b/test/test_unordered_multimap.cpp index d04dc25f..65106b71 100644 --- a/test/test_unordered_multimap.cpp +++ b/test/test_unordered_multimap.cpp @@ -39,7 +39,7 @@ SOFTWARE. #include "data.h" -#include "unordered_multimap.h" +#include "etl/unordered_multimap.h" namespace { diff --git a/test/test_unordered_multiset.cpp b/test/test_unordered_multiset.cpp index 0fddfcee..71f069dd 100644 --- a/test/test_unordered_multiset.cpp +++ b/test/test_unordered_multiset.cpp @@ -39,8 +39,8 @@ SOFTWARE. #include "data.h" -#include "unordered_multiset.h" -#include "checksum.h" +#include "etl/unordered_multiset.h" +#include "etl/checksum.h" namespace { diff --git a/test/test_unordered_set.cpp b/test/test_unordered_set.cpp index e658451c..55f28f82 100644 --- a/test/test_unordered_set.cpp +++ b/test/test_unordered_set.cpp @@ -38,8 +38,8 @@ SOFTWARE. #include "data.h" -#include "unordered_set.h" -#include "checksum.h" +#include "etl/unordered_set.h" +#include "etl/checksum.h" namespace { diff --git a/test/test_user_type.cpp b/test/test_user_type.cpp index 0e3e5da7..c7eb5a6d 100644 --- a/test/test_user_type.cpp +++ b/test/test_user_type.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include -#include "user_type.h" +#include "etl/user_type.h" ETL_DECLARE_USER_TYPE(CompassDirection, int) ETL_USER_TYPE(North, 0) diff --git a/test/test_utility.cpp b/test/test_utility.cpp index 08700fe0..ac29ed19 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "utility.h" +#include "etl/utility.h" namespace { diff --git a/test/test_variant.cpp b/test/test_variant.cpp index 07a96cdb..305fda0d 100644 --- a/test/test_variant.cpp +++ b/test/test_variant.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "variant.h" +#include "etl/variant.h" #include #include diff --git a/test/test_variant_pool.cpp b/test/test_variant_pool.cpp index 4578c8d3..65a5bc4b 100644 --- a/test/test_variant_pool.cpp +++ b/test/test_variant_pool.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "UnitTest++.h" #include "ExtraCheckMacros.h" -#include "variant_pool.h" +#include "etl/variant_pool.h" #include #include diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 9b753a15..b740f328 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "vector.h" +#include "etl/vector.h" namespace { diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index 2d1d89e3..bfd099b0 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -32,7 +32,7 @@ #include #include -#include "vector.h" +#include "etl/vector.h" #include "data.h" namespace diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index d35cc045..dc5a5a33 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "vector.h" +#include "etl/vector.h" namespace { diff --git a/test/test_visitor.cpp b/test/test_visitor.cpp index 325a0622..befc438d 100644 --- a/test/test_visitor.cpp +++ b/test/test_visitor.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "UnitTest++.h" -#include "visitor.h" +#include "etl/visitor.h" //***************************************************************************** // Pre-declare the data types. diff --git a/test/test_xor_checksum.cpp b/test/test_xor_checksum.cpp index 1d451064..207d2699 100644 --- a/test/test_xor_checksum.cpp +++ b/test/test_xor_checksum.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "checksum.h" +#include "etl/checksum.h" namespace { diff --git a/test/test_xor_rotate_checksum.cpp b/test/test_xor_rotate_checksum.cpp index 43f50436..485f9972 100644 --- a/test/test_xor_rotate_checksum.cpp +++ b/test/test_xor_rotate_checksum.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include -#include "checksum.h" +#include "etl/checksum.h" namespace { diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 36cb1401..e79c511c 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -161,7 +161,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test false @@ -203,7 +203,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp\UnitTest++;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp\UnitTest++;../../include;../../include/etl/c;../../test false @@ -245,7 +245,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test From 0b4543f48249232dfa834a311d63d3ee34b48993 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 29 Jul 2018 13:38:09 +0100 Subject: [PATCH 26/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h --- include/etl/memory_model.h | 36 +- include/etl/priority_queue.h | 6 +- include/etl/queue.h | 96 ++-- include/etl/queue_mpmc_mutex.h | 78 ++-- include/etl/queue_spsc_atomic.h | 103 +++-- include/etl/queue_spsc_isr.h | 68 +-- include/etl/version.h | 12 +- support/Release notes.txt | 12 + test/codeblocks/ETL.cbp | 4 + test/test_queue_memory_model_small.cpp | 589 +++++++++++++++++++++++++ test/test_queue_mpmc_mutex.cpp | 20 +- test/test_queue_mpmc_mutex_small.cpp | 460 +++++++++++++++++++ test/test_queue_spsc_atomic_small.cpp | 330 ++++++++++++++ test/test_queue_spsc_isr_small.cpp | 587 ++++++++++++++++++++++++ test/vs2017/etl.vcxproj | 4 + test/vs2017/etl.vcxproj.filters | 12 + 16 files changed, 2261 insertions(+), 156 deletions(-) create mode 100644 test/test_queue_memory_model_small.cpp create mode 100644 test/test_queue_mpmc_mutex_small.cpp create mode 100644 test/test_queue_spsc_atomic_small.cpp create mode 100644 test/test_queue_spsc_isr_small.cpp diff --git a/include/etl/memory_model.h b/include/etl/memory_model.h index 07bfc73f..5b474597 100644 --- a/include/etl/memory_model.h +++ b/include/etl/memory_model.h @@ -32,14 +32,44 @@ SOFTWARE. #define ETL_MEMORY_MODEL_INCLUDED #include "user_type.h" +#include +#include "type_lookup.h" namespace etl { ETL_DECLARE_USER_TYPE(memory_model, int) - ETL_USER_TYPE(MM_SMALL, 0) - ETL_USER_TYPE(MM_MEDIUM, 1) - ETL_USER_TYPE(MM_LARGE, 2) + ETL_USER_TYPE(MEMORY_MODEL_SMALL, 0) + ETL_USER_TYPE(MEMORY_MODEL_MEDIUM, 1) + ETL_USER_TYPE(MEMORY_MODEL_LARGE, 2) + ETL_USER_TYPE(MEMORY_MODEL_HUGE, 3) ETL_END_USER_TYPE(memory_model) + + template + struct size_type_lookup; + + template <> + struct size_type_lookup + { + typedef uint_least8_t type; + }; + + template <> + struct size_type_lookup + { + typedef uint_least16_t type; + }; + + template <> + struct size_type_lookup + { + typedef uint_least32_t type; + }; + + template <> + struct size_type_lookup + { + typedef uint_least64_t type; + }; } #endif diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 34bf15a3..02eb6922 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -319,7 +319,7 @@ namespace etl /// Returns the remaining capacity. ///\return The remaining capacity. //************************************************************************* - size_t available() const + size_type available() const { return container.max_size() - container.size(); } @@ -372,7 +372,9 @@ namespace etl { public: - static const size_t MAX_SIZE = SIZE; + typedef typename TContainer::size_type size_type; + + static const size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue.h b/include/etl/queue.h index 4a533d8c..fdf4da19 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -43,6 +43,8 @@ SOFTWARE. #include "debug_count.h" #include "type_traits.h" #include "parameter_type.h" +#include "memory_model.h" +#include "integral_limits.h" #undef ETL_FILE #define ETL_FILE "13" @@ -102,11 +104,13 @@ namespace etl /// The base class for all queues. ///\ingroup queue //*************************************************************************** + template class queue_base { public: - typedef size_t size_type; ///< The type used for determining the size of queue. + /// The type used for determining the size of queue. + typedef typename etl::size_type_lookup::type size_type; //************************************************************************* /// Returns the current number of items in the queue. @@ -154,7 +158,7 @@ namespace etl /// Returns the remaining capacity. ///\return The remaining capacity. //************************************************************************* - size_t available() const + size_type available() const { return max_size() - size(); } @@ -217,8 +221,8 @@ namespace etl ETL_RESET_DEBUG_COUNT; } - size_type in; ///< Where to input new data. - size_type out; ///< Where to get the oldest data. + size_type in; ///< Where to input new data. + size_type out; ///< Where to get the oldest data. size_type current_size; ///< The number of items in the queue. const size_type CAPACITY; ///< The maximum number of items in the queue. ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. @@ -236,25 +240,32 @@ namespace etl /// \warning This queue cannot be used for concurrent access from multiple threads. /// \tparam T The type of value that the queue holds. //*************************************************************************** - template - class iqueue : public etl::queue_base + template + class iqueue : public etl::queue_base { - public: - - typedef T value_type; ///< The type stored in the queue. - 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 T* pointer; ///< A pointer to the type used in the queue. - typedef const T* const_pointer; ///< A const pointer to the type used in the queue. - typedef queue_base::size_type size_type; ///< The type used for determining the size of the queue. - private: - typedef typename etl::parameter_type::type parameter_t; - typedef typename etl::queue_base base_t; + typedef typename etl::parameter_type::type parameter_t; + typedef typename etl::queue_base base_t; public: + typedef T value_type; ///< The type stored in the queue. + 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 T* pointer; ///< A pointer to the type used in the queue. + typedef const T* const_pointer; ///< A const pointer to the type used in the queue. + typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue. + + using base_t::in; + using base_t::out; + using base_t::CAPACITY; + using base_t::current_size; + using base_t::full; + using base_t::empty; + using base_t::add_in; + using base_t::del_out; + //************************************************************************* /// Gets a reference to the value at the front of the queue.
/// \return A reference to the value at the front of the queue. @@ -302,7 +313,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif ::new (&p_buffer[in]) T(value); - base_t::add_in(); + add_in(); } //************************************************************************* @@ -319,7 +330,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif - base_t::add_in(); + add_in(); return p_buffer[next]; } @@ -336,7 +347,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif ::new (&p_buffer[in]) T(value1); - base_t::add_in(); + add_in(); } //************************************************************************* @@ -351,7 +362,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif ::new (&p_buffer[in]) T(value1, value2); - base_t::add_in(); + add_in(); } //************************************************************************* @@ -366,7 +377,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif ::new (&p_buffer[in]) T(value1, value2, value3); - base_t::add_in(); + add_in(); } //************************************************************************* @@ -381,7 +392,7 @@ namespace etl ETL_ASSERT(!full(), ETL_ERROR(queue_full)); #endif ::new (&p_buffer[in]) T(value1, value2, value3, value4); - base_t::add_in(); + add_in(); } //************************************************************************* @@ -398,7 +409,7 @@ namespace etl while (current_size > 0) { p_buffer[out].~T(); - base_t::del_out(); + del_out(); } in = 0; @@ -417,7 +428,7 @@ namespace etl ETL_ASSERT(!empty(), ETL_ERROR(queue_empty)); #endif p_buffer[out].~T(); - base_t::del_out(); + del_out(); } //************************************************************************* @@ -466,9 +477,9 @@ namespace etl { clear(); - size_t index = other.out; + size_type index = other.out; - for (size_t i = 0; i < other.size(); ++i) + for (size_type i = 0; i < other.size(); ++i) { push(other.p_buffer[index]); index = (index == (CAPACITY - 1)) ? 0 : index + 1; @@ -479,7 +490,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* iqueue(T* p_buffer_, size_type max_size_) - : queue_base(max_size_), + : base_t(max_size_), p_buffer(p_buffer_) { } @@ -511,21 +522,30 @@ namespace etl ///\ingroup queue /// A fixed capacity queue. /// This queue does not support concurrent access by different threads. - /// \tparam T The type this queue should support. - /// \tparam SIZE The maximum capacity of the queue. + /// \tparam T The type this queue should support. + /// \tparam SIZE The maximum capacity of the queue. + /// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables. //*************************************************************************** - template - class queue : public etl::iqueue + template + class queue : public etl::iqueue { + private: + + typedef etl::iqueue base_t; + public: - static const size_t MAX_SIZE = SIZE; + typedef typename base_t::size_type size_type; + + ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); + + static const size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. //************************************************************************* queue() - : etl::iqueue(reinterpret_cast(&buffer[0]), SIZE) + : base_t(reinterpret_cast(&buffer[0]), SIZE) { } @@ -533,9 +553,9 @@ namespace etl /// Copy constructor //************************************************************************* queue(const queue& rhs) - : etl::iqueue(reinterpret_cast(&buffer[0]), SIZE) + : base_t(reinterpret_cast(&buffer[0]), SIZE) { - etl::iqueue::clone(rhs); + base_t::clone(rhs); } //************************************************************************* @@ -543,7 +563,7 @@ namespace etl //************************************************************************* ~queue() { - etl::iqueue::clear(); + base_t::clear(); } //************************************************************************* @@ -553,7 +573,7 @@ namespace etl { if (&rhs != this) { - etl::iqueue::clone(rhs); + base_t::clone(rhs); } return *this; diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index f6951406..16ec5e53 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -38,20 +38,26 @@ SOFTWARE. #include "alignment.h" #include "parameter_type.h" #include "mutex.h" +#include "memory_model.h" +#include "integral_limits.h" #undef ETL_FILE #define ETL_FILE "48" namespace etl { + template class queue_mpmc_mutex_base { public: + /// The type used for determining the size of queue. + typedef typename etl::size_type_lookup::type size_type; + //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t capacity() const + size_type capacity() const { return MAX_SIZE; } @@ -59,14 +65,14 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t max_size() const + size_type max_size() const { return MAX_SIZE; } protected: - queue_mpmc_mutex_base(size_t max_size_) + queue_mpmc_mutex_base(size_type max_size_) : write_index(0), read_index(0), current_size(0), @@ -77,7 +83,7 @@ namespace etl //************************************************************************* /// Calculate the next index. //************************************************************************* - static size_t get_next_index(size_t index, size_t maximum) + static size_type get_next_index(size_type index, size_type maximum) { ++index; @@ -89,10 +95,10 @@ namespace etl return index; } - size_t write_index; ///< Where to input new data. - size_t read_index; ///< Where to get the oldest data. - size_t current_size; ///< The current size of the queue. - const size_t MAX_SIZE; ///< The maximum number of items in the queue. + size_type write_index; ///< Where to input new data. + size_type read_index; ///< Where to get the oldest data. + size_type current_size; ///< The current size of the queue. + const size_type MAX_SIZE; ///< The maximum number of items in the queue. //************************************************************************* /// Destructor. @@ -121,19 +127,26 @@ namespace etl /// This queue supports concurrent access by one producer and one consumer. /// \tparam T The type of value that the queue_mpmc_mutex holds. //*************************************************************************** - template - class iqueue_mpmc_mutex : public queue_mpmc_mutex_base + template + class iqueue_mpmc_mutex : public queue_mpmc_mutex_base { - protected: + private: - typedef typename etl::parameter_type::type parameter_t; + typedef typename etl::parameter_type::type parameter_t; + typedef etl::queue_mpmc_mutex_base base_t; public: - typedef T value_type; ///< The type stored in the queue. - 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 size_t size_type; ///< The type used for determining the size of the queue. + typedef T value_type; ///< The type stored in the queue. + 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 base_t::size_type size_type; ///< The type used for determining the size of the queue. + + using base_t::write_index; + using base_t::read_index; + using base_t::current_size; + using base_t::MAX_SIZE; + using base_t::get_next_index; //************************************************************************* /// Push a value to the queue. @@ -199,7 +212,7 @@ namespace etl { access.lock(); - size_t result = (current_size == 0); + size_type result = (current_size == 0); access.unlock(); @@ -213,7 +226,7 @@ namespace etl { access.lock(); - size_t result = (current_size == MAX_SIZE); + size_type result = (current_size == MAX_SIZE); access.unlock(); @@ -223,11 +236,11 @@ namespace etl //************************************************************************* /// How many items in the queue? //************************************************************************* - size_t size() const + size_type size() const { access.lock(); - size_t result = current_size; + size_type result = current_size; access.unlock(); @@ -237,11 +250,11 @@ namespace etl //************************************************************************* /// How much free space available in the queue. //************************************************************************* - size_t available() const + size_type available() const { access.lock(); - size_t result = MAX_SIZE - current_size; + size_type result = MAX_SIZE - current_size; access.unlock(); @@ -254,7 +267,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* iqueue_mpmc_mutex(T* p_buffer_, size_type max_size_) - : queue_mpmc_mutex_base(max_size_), + : base_t(max_size_), p_buffer(p_buffer_) { } @@ -335,17 +348,24 @@ namespace etl ///\ingroup queue_mpmc /// A fixed capacity mpmc queue. /// This queue supports concurrent access by one producer and one consumer. - /// \tparam T The type this queue should support. - /// \tparam SIZE The maximum capacity of the queue. + /// \tparam T The type this queue should support. + /// \tparam SIZE The maximum capacity of the queue. + /// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables. //*************************************************************************** - template - class queue_mpmc_mutex : public etl::iqueue_mpmc_mutex + template + class queue_mpmc_mutex : public etl::iqueue_mpmc_mutex { - typedef etl::iqueue_mpmc_mutex base_t; + private: + + typedef etl::iqueue_mpmc_mutex base_t; public: - static const size_t MAX_SIZE = SIZE; + typedef typename base_t::size_type size_type; + + ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); + + static const size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index dfe32fc0..44eeb918 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -38,16 +38,22 @@ SOFTWARE. #include "alignment.h" #include "parameter_type.h" #include "atomic.h" +#include "memory_model.h" +#include "integral_limits.h" #undef ETL_FILE #define ETL_FILE "47" namespace etl { + template class queue_spsc_atomic_base { public: + /// The type used for determining the size of queue. + typedef typename etl::size_type_lookup::type size_type; + //************************************************************************* /// Is the queue empty? /// Accurate from the 'pop' thread. @@ -65,7 +71,7 @@ namespace etl //************************************************************************* bool full() const { - size_t next_index = get_next_index(write.load(etl::memory_order_acquire), RESERVED); + size_type next_index = get_next_index(write.load(etl::memory_order_acquire), RESERVED); return (next_index == read.load(etl::memory_order_acquire)); } @@ -74,12 +80,12 @@ namespace etl /// How many items in the queue? /// Due to concurrency, this is a guess. //************************************************************************* - size_t size() const + size_type size() const { - size_t write_index = write.load(etl::memory_order_acquire); - size_t read_index = read.load(etl::memory_order_acquire); + size_type write_index = write.load(etl::memory_order_acquire); + size_type read_index = read.load(etl::memory_order_acquire); - size_t n; + size_type n; if (write_index >= read_index) { @@ -97,7 +103,7 @@ namespace etl /// How much free space available in the queue. /// Due to concurrency, this is a guess. //************************************************************************* - size_t available() const + size_type available() const { return RESERVED - size() - 1; } @@ -105,7 +111,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t capacity() const + size_type capacity() const { return RESERVED - 1; } @@ -113,14 +119,14 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t max_size() const + size_type max_size() const { return RESERVED - 1; } protected: - queue_spsc_atomic_base(size_t reserved_) + queue_spsc_atomic_base(size_type reserved_) : write(0), read(0), RESERVED(reserved_) @@ -130,7 +136,7 @@ namespace etl //************************************************************************* /// Calculate the next index. //************************************************************************* - static size_t get_next_index(size_t index, size_t maximum) + static size_type get_next_index(size_type index, size_type maximum) { ++index; @@ -142,9 +148,9 @@ namespace etl return index; } - etl::atomic_size_t write; ///< Where to input new data. - etl::atomic_size_t read; ///< Where to get the oldest data. - const size_t RESERVED; ///< The maximum number of items in the queue. + etl::atomic write; ///< Where to input new data. + etl::atomic read; ///< Where to get the oldest data. + const size_type RESERVED; ///< The maximum number of items in the queue. private: @@ -163,7 +169,7 @@ namespace etl } #endif }; - + //*************************************************************************** ///\ingroup queue_spsc_atomic ///\brief This is the base for all queue_spscs that contain a particular type. @@ -175,27 +181,33 @@ namespace etl /// This queue supports concurrent access by one producer and one consumer. /// \tparam T The type of value that the queue_spsc_atomic holds. //*************************************************************************** - template - class iqueue_spsc_atomic : public queue_spsc_atomic_base + template + class iqueue_spsc_atomic : public queue_spsc_atomic_base { private: - typedef typename etl::parameter_type::type parameter_t; + typedef typename etl::parameter_type::type parameter_t; + typedef typename etl::queue_spsc_atomic_base base_t; public: - typedef T value_type; ///< The type stored in the queue. - 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 size_t size_type; ///< The type used for determining the size of the queue. + typedef T value_type; ///< The type stored in the queue. + 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 base_t::size_type size_type; ///< The type used for determining the size of the queue. + + using base_t::write; + using base_t::read; + using base_t::RESERVED; + using base_t::get_next_index; //************************************************************************* /// Push a value to the queue. //************************************************************************* bool push(parameter_t value) { - size_t write_index = write.load(etl::memory_order_relaxed); - size_t next_index = get_next_index(write_index, RESERVED); + size_type write_index = write.load(etl::memory_order_relaxed); + size_type next_index = get_next_index(write_index, RESERVED); if (next_index != read.load(etl::memory_order_acquire)) { @@ -205,7 +217,7 @@ namespace etl return true; } - + // Queue is full. return false; } @@ -214,16 +226,16 @@ namespace etl /// Pop a value from the queue. //************************************************************************* bool pop(reference value) - { - size_t read_index = read.load(etl::memory_order_relaxed); - - if (read_index == write.load(etl::memory_order_acquire)) + { + size_type read_index = read.load(etl::memory_order_relaxed); + + if (read_index == write.load(etl::memory_order_acquire)) { // Queue is empty return false; } - size_t next_index = get_next_index(read_index, RESERVED); + size_type next_index = get_next_index(read_index, RESERVED); value = p_buffer[read_index]; p_buffer[read_index].~T(); @@ -238,7 +250,7 @@ namespace etl //************************************************************************* bool pop() { - size_t read_index = read.load(etl::memory_order_relaxed); + size_type read_index = read.load(etl::memory_order_relaxed); if (read_index == write.load(etl::memory_order_acquire)) { @@ -246,7 +258,7 @@ namespace etl return false; } - size_t next_index = get_next_index(read_index, RESERVED); + size_type next_index = get_next_index(read_index, RESERVED); p_buffer[read_index].~T(); @@ -274,7 +286,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* iqueue_spsc_atomic(T* p_buffer_, size_type reserved_) - : queue_spsc_atomic_base(reserved_), + : base_t(reserved_), p_buffer(p_buffer_) { } @@ -292,19 +304,30 @@ namespace etl ///\ingroup queue_spsc /// A fixed capacity spsc queue. /// This queue supports concurrent access by one producer and one consumer. - /// \tparam T The type this queue should support. - /// \tparam SIZE The maximum capacity of the queue. + /// \tparam T The type this queue should support. + /// \tparam SIZE The maximum capacity of the queue. + /// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables. //*************************************************************************** - template - class queue_spsc_atomic : public iqueue_spsc_atomic + template + class queue_spsc_atomic : public iqueue_spsc_atomic { - typedef etl::iqueue_spsc_atomic base_t; + private: - static const size_t RESERVED_SIZE = SIZE + 1; + typedef typename etl::iqueue_spsc_atomic base_t; public: - static const size_t MAX_SIZE = SIZE; + typedef typename base_t::size_type size_type; + + private: + + static const size_type RESERVED_SIZE = size_type(SIZE + 1); + + public: + + ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max - 1)), "Size too large for memory model"); + + static const size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. @@ -329,4 +352,4 @@ namespace etl }; }; -#endif \ No newline at end of file +#endif diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 2b89603d..dc5922cb 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -37,13 +37,15 @@ SOFTWARE. #include "platform.h" #include "alignment.h" #include "parameter_type.h" +#include "memory_model.h" +#include "integral_limits.h" #undef ETL_FILE #define ETL_FILE "46" namespace etl { - template + template class queue_spsc_isr_base { protected: @@ -52,10 +54,12 @@ namespace etl public: + /// The type used for determining the size of queue. + typedef typename etl::size_type_lookup::type size_type; + typedef T value_type; ///< The type stored in the queue. 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 size_t size_type; ///< The type used for determining the size of the queue. //************************************************************************* /// Push a value to the queue from an ISR. @@ -85,7 +89,7 @@ namespace etl /// How much free space available in the queue. /// Called from ISR. //************************************************************************* - size_t available_from_isr() const + size_type available_from_isr() const { return MAX_SIZE - current_size; } @@ -123,7 +127,7 @@ namespace etl /// How many items in the queue? /// Called from ISR. //************************************************************************* - size_t size_from_isr() const + size_type size_from_isr() const { return current_size; } @@ -131,7 +135,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t capacity() const + size_type capacity() const { return MAX_SIZE; } @@ -139,7 +143,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - size_t max_size() const + size_type max_size() const { return MAX_SIZE; } @@ -219,7 +223,7 @@ namespace etl //************************************************************************* /// Calculate the next index. //************************************************************************* - static size_t get_next_index(size_t index, size_t maximum) + static size_type get_next_index(size_type index, size_type maximum) { ++index; @@ -266,19 +270,20 @@ namespace etl /// This queue supports concurrent access by one producer and one consumer. /// \tparam T The type of value that the queue_spsc_isr holds. //*************************************************************************** - template - class iqueue_spsc_isr : public queue_spsc_isr_base + template + class iqueue_spsc_isr : public queue_spsc_isr_base { private: - typedef typename queue_spsc_isr_base::parameter_t parameter_t; + typedef queue_spsc_isr_base base_t; + typedef typename base_t::parameter_t parameter_t; public: - typedef typename queue_spsc_isr_base::value_type value_type; ///< The type stored in the queue. - typedef typename queue_spsc_isr_base::reference reference; ///< A reference to the type used in the queue. - typedef typename queue_spsc_isr_base::const_reference const_reference; ///< A const reference to the type used in the queue. - typedef typename queue_spsc_isr_base::size_type size_type; ///< The type used for determining the size of the queue. + typedef typename base_t::value_type value_type; ///< The type stored in the queue. + typedef typename base_t::reference reference; ///< A reference to the type used in the queue. + typedef typename base_t::const_reference const_reference; ///< A const reference to the type used in the queue. + typedef typename base_t::size_type size_type; ///< The type used for determining the size of the queue. //************************************************************************* /// Push a value to the queue. @@ -344,7 +349,7 @@ namespace etl { TAccess::lock(); - size_t result = (this->current_size == 0); + size_type result = (this->current_size == 0); TAccess::unlock(); @@ -358,7 +363,7 @@ namespace etl { TAccess::lock(); - size_t result = (this->current_size == this->MAX_SIZE); + size_type result = (this->current_size == this->MAX_SIZE); TAccess::unlock(); @@ -368,11 +373,11 @@ namespace etl //************************************************************************* /// How many items in the queue? //************************************************************************* - size_t size() const + size_type size() const { TAccess::lock(); - size_t result = this->current_size; + size_type result = this->current_size; TAccess::unlock(); @@ -382,11 +387,11 @@ namespace etl //************************************************************************* /// How much free space available in the queue. //************************************************************************* - size_t available() const + size_type available() const { TAccess::lock(); - size_t result = this->MAX_SIZE - this->current_size; + size_type result = this->MAX_SIZE - this->current_size; TAccess::unlock(); @@ -399,7 +404,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* iqueue_spsc_isr(T* p_buffer_, size_type max_size_) - : queue_spsc_isr_base(p_buffer_, max_size_) + : base_t(p_buffer_, max_size_) { } @@ -416,18 +421,25 @@ namespace etl ///\ingroup queue_spsc /// A fixed capacity spsc queue. /// This queue supports concurrent access by one producer and one consumer. - /// \tparam T The type this queue should support. - /// \tparam SIZE The maximum capacity of the queue. - /// \tparam TAccess The type that will lock and unlock interrupts. + /// \tparam T The type this queue should support. + /// \tparam SIZE The maximum capacity of the queue. + /// \tparam TAccess The type that will lock and unlock interrupts. + /// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables. //*************************************************************************** - template - class queue_spsc_isr : public etl::iqueue_spsc_isr + template + class queue_spsc_isr : public etl::iqueue_spsc_isr { - typedef etl::iqueue_spsc_isr base_t; + private: + + typedef etl::iqueue_spsc_isr base_t; public: - static const size_t MAX_SIZE = SIZE; + typedef typename base_t::size_type size_type; + + ETL_STATIC_ASSERT((SIZE <= etl::integral_limits::max), "Size too large for memory model"); + + static const size_type MAX_SIZE = size_type(SIZE); //************************************************************************* /// Default constructor. diff --git a/include/etl/version.h b/include/etl/version.h index 1b6c4836..531de754 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,13 +37,13 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.14.3" -#define ETL_VERSION_W L"11.14.3" -#define ETL_VERSION_U16 u"11.14.3" -#define ETL_VERSION_U32 U"11.14.3" +#define ETL_VERSION "11.15.0" +#define ETL_VERSION_W L"11.15.0" +#define ETL_VERSION_U16 u"11.15.0" +#define ETL_VERSION_U32 U"11.15.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 3 +#define ETL_VERSION_MINOR 15 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH) #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 07decddd..fde6c598 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,15 @@ +=============================================================================== +11.15.0 +Added 'memory model' selection for queues to allow more efficient implementations. + +Maximum queue sizes: +MEMORY_MODEL_SMALL 255 (254 for queue_spsc_atomic) +MEMORY_MODEL_MEDIUM 65535 +MEMORY_MODEL_LARGE 2147483647 +MEMORY_MODEL_HUGE 9223372036854775807 + +Fixed syntax errors highlighted by GCC v8 + =============================================================================== 11.14.2 Removed reference_flat_set & reference_flat_map reliance on equality. diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index a3c7d0cb..cbbcc3ec 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -406,9 +406,13 @@ + + + + diff --git a/test/test_queue_memory_model_small.cpp b/test/test_queue_memory_model_small.cpp new file mode 100644 index 00000000..e60e9181 --- /dev/null +++ b/test/test_queue_memory_model_small.cpp @@ -0,0 +1,589 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#include + +#include "etl/queue.h" + +namespace +{ + struct Item + { + Item(char c_, int i_, double d_) + : c(c_), + i(i_), + d(d_) + { + } + + char c; + int i; + double d; + }; + + bool operator == (const Item& lhs, const Item& rhs) + { + return (lhs.c == rhs.c) && (lhs.i == rhs.i) && (lhs.d == rhs.d); + } + + struct ItemNTD + { + ItemNTD() + { + p = new char; + } + + ItemNTD(const ItemNTD&) + : p(new char) + { + } + + ~ItemNTD() + { + delete p; + } + + char* p; + }; + + typedef etl::queue QueueInt; + typedef etl::iqueue IQueueInt; + + typedef etl::queue QueueItemNTD; + typedef etl::iqueue IQueueItemNTD; + + typedef etl::queue QueueInt255; + + SUITE(test_queue) + { + //************************************************************************* + TEST(test_copy_constructor) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + QueueInt queue2(queue); + + CHECK(queue.size() == queue2.size()); + + while (!queue.empty()) + { + CHECK_EQUAL(queue.front(), queue2.front()); + queue.pop(); + queue2.pop(); + } + } + + //************************************************************************* + TEST(test_delete_via_iqueue) + { + QueueInt* pqueue = new QueueInt; + + IQueueInt* piqueue = pqueue; + + piqueue->push(1); + piqueue->push(2); + piqueue->push(3); + piqueue->push(4); + + delete piqueue; + } + + //************************************************************************* + TEST(test_size) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + + CHECK_EQUAL(3U, queue.size()); + } + + //************************************************************************* + TEST(test_clear) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + + // Do it again to check that clear() didn't screw up the internals. + queue.push(1); + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + } + + //************************************************************************* + TEST(test_clear_non_pod) + { + QueueItemNTD queue; + + queue.push(ItemNTD()); + queue.push(ItemNTD()); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + + // Do it again to check that clear() didn't screw up the internals. + queue.push(ItemNTD()); + queue.push(ItemNTD()); + CHECK_EQUAL(2U, queue.size()); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + } + + //************************************************************************* + TEST(test_empty) + { + QueueInt queue; + + CHECK(queue.empty()); + + queue.push(1); + + CHECK(!queue.empty()); + } + + //************************************************************************* + TEST(test_full) + { + QueueInt queue; + + CHECK(!queue.full()); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + CHECK(queue.full()); + } + + //************************************************************************* + TEST(test_front) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + + CHECK_EQUAL(1, queue.front()); + + queue.pop(); + CHECK_EQUAL(2, queue.front()); + + queue.pop(); + CHECK_EQUAL(3, queue.front()); + } + + //************************************************************************* + TEST(test_front_const) + { + QueueInt queue; + const QueueInt& constQueue = queue; + + queue.push(1); + queue.push(2); + queue.push(3); + + CHECK_EQUAL(1, constQueue.front()); + + queue.pop(); + CHECK_EQUAL(2, constQueue.front()); + + queue.pop(); + CHECK_EQUAL(3, constQueue.front()); + } + + //************************************************************************* + TEST(test_back) + { + QueueInt queue; + + queue.push(1); + CHECK_EQUAL(1, queue.back()); + + queue.push(2); + CHECK_EQUAL(2, queue.back()); + + queue.push(3); + CHECK_EQUAL(3, queue.back()); + } + + //************************************************************************* + TEST(test_back_const) + { + QueueInt queue; + const QueueInt& constQueue = queue; + + queue.push(1); + CHECK_EQUAL(1, constQueue.back()); + + queue.push(2); + CHECK_EQUAL(2, constQueue.back()); + + queue.push(3); + CHECK_EQUAL(3, constQueue.back()); + } + + //************************************************************************* + TEST(test_push) + { + QueueInt queue; + + queue.push(1); + CHECK_EQUAL(1U, queue.size()); + + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + + CHECK_EQUAL(1, queue.front()); + + queue.pop(); + CHECK_EQUAL(2, queue.front()); + } + + //************************************************************************* + TEST(test_push_255) + { + QueueInt255 queue; + + for (int i = 0; i < 255; ++i) + { + queue.push(i); + } + + CHECK_EQUAL(255U, queue.size()); + } + + //************************************************************************* + TEST(test_push_void) + { + QueueInt queue; + + queue.push() = 1; + CHECK_EQUAL(1U, queue.size()); + + queue.push() = 2; + CHECK_EQUAL(2U, queue.size()); + + CHECK_EQUAL(1, queue.front()); + + queue.pop(); + CHECK_EQUAL(2, queue.front()); + } + + //************************************************************************* + TEST(test_push_excess) + { + QueueInt queue; + + for (size_t i = 0; i < queue.max_size(); ++i) + { + queue.push(1); + } + + CHECK_THROW(queue.push(1), etl::queue_full); + } + + //************************************************************************* + TEST(test_multiple_push) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + + bool pass = true; + + if (queue.front() != 1) + { + pass = false; + } + + queue.pop(); + + if (queue.front() != 2) + { + pass = false; + } + + queue.pop(); + + if (queue.front() != 3) + { + pass = false; + } + + CHECK(pass); + } + + //************************************************************************* + TEST(test_multiple_emplace) + { + etl::queue queue; + + queue.emplace('a', 1, 1.2); + queue.emplace('b', 2, 3.4); + queue.emplace('c', 3, 5.6); + queue.emplace('d', 4, 7.8); + + CHECK(queue.front() == Item('a', 1, 1.2)); + queue.pop(); + CHECK(queue.front() == Item('b', 2, 3.4)); + queue.pop(); + CHECK(queue.front() == Item('c', 3, 5.6)); + queue.pop(); + CHECK(queue.front() == Item('d', 4, 7.8)); + queue.pop(); + } + + //************************************************************************* + TEST(test_multiple_push_void) + { + QueueInt queue; + + queue.push() = 1; + queue.push() = 2; + queue.push() = 3; + + bool pass = true; + + if (queue.front() != 1) + { + pass = false; + } + + queue.pop(); + + if (queue.front() != 2) + { + pass = false; + } + + queue.pop(); + + if (queue.front() != 3) + { + pass = false; + } + + CHECK(pass); + } + + //************************************************************************* + TEST(test_pop) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.pop(); + CHECK_EQUAL(1U, queue.size()); + } + + //************************************************************************* + TEST(test_pop_into) + { + QueueInt queue; + + int i; + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + queue.pop_into(i); + CHECK_EQUAL(1, i); + CHECK_EQUAL(3U, queue.size()); + + queue.pop_into(i); + CHECK_EQUAL(2, i); + CHECK_EQUAL(2U, queue.size()); + + queue.pop_into(i); + CHECK_EQUAL(3, i); + CHECK_EQUAL(1U, queue.size()); + + queue.pop_into(i); + CHECK_EQUAL(4, i); + CHECK_EQUAL(0U, queue.size()); + } + + //************************************************************************* + TEST(test_pop_into_queue) + { + QueueInt queue1; + QueueInt queue2; + + queue1.push(1); + queue1.push(2); + queue1.push(3); + queue1.push(4); + + queue1.pop_into(queue2); + CHECK_EQUAL(1U, queue2.size()); + CHECK_EQUAL(1, queue2.front()); + CHECK_EQUAL(1, queue2.back()); + + queue1.pop_into(queue2); + CHECK_EQUAL(2U, queue2.size()); + CHECK_EQUAL(1, queue2.front()); + CHECK_EQUAL(2, queue2.back()); + + queue1.pop_into(queue2); + CHECK_EQUAL(3U, queue2.size()); + CHECK_EQUAL(1, queue2.front()); + CHECK_EQUAL(3, queue2.back()); + + queue1.pop_into(queue2); + CHECK_EQUAL(4U, queue2.size()); + CHECK_EQUAL(1, queue2.front()); + CHECK_EQUAL(4, queue2.back()); + + int i; + + queue2.pop_into(i); + CHECK_EQUAL(1, i); + + queue2.pop_into(i); + CHECK_EQUAL(2, i); + + queue2.pop_into(i); + CHECK_EQUAL(3, i); + + queue2.pop_into(i); + CHECK_EQUAL(4, i); + } + + //************************************************************************* + TEST(test_pop_exception) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.pop(); + queue.pop(); + + CHECK_THROW(queue.pop(), etl::queue_empty); + } + + //************************************************************************* + TEST(test_assignment) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + QueueInt queue2; + + queue2 = queue; + + CHECK(queue.size() == queue2.size()); + + while (!queue.empty()) + { + CHECK_EQUAL(queue.front(), queue2.front()); + queue.pop(); + queue2.pop(); + } + } + + //************************************************************************* + TEST(test_assignment_interface) + { + QueueInt queue1; + + queue1.push(1); + queue1.push(2); + queue1.push(3); + queue1.push(4); + + QueueInt queue2; + + IQueueInt& iqueue1 = queue1; + IQueueInt& iqueue2 = queue2; + + iqueue2 = iqueue1; + + CHECK(queue1.size() == queue2.size()); + + while (!queue1.empty()) + { + CHECK_EQUAL(queue1.front(), queue2.front()); + queue1.pop(); + queue2.pop(); + } + } + + //************************************************************************* + TEST(test_self_assignment) + { + QueueInt queue; + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + queue = queue; + + CHECK(queue.max_size() == queue.size()); + + CHECK_EQUAL(1, queue.front()); + queue.pop(); + + CHECK_EQUAL(2, queue.front()); + queue.pop(); + + CHECK_EQUAL(3, queue.front()); + queue.pop(); + + CHECK_EQUAL(4, queue.front()); + queue.pop(); + } + }; +} diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index ef15fee4..75c1be5c 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -69,17 +69,17 @@ namespace int d; }; - bool operator ==(const Data& lhs, const Data& rhs) - { - return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); - } +// bool operator ==(const Data& lhs, const Data& rhs) +// { +// return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); +// } - std::ostream& operator <<(std::ostream& os, const Data& data) - { - os << data.a << " " << data.b << " " << data.c << " " << data.d; - - return os; - } +// std::ostream& operator <<(std::ostream& os, const Data& data) +// { +// os << data.a << " " << data.b << " " << data.c << " " << data.d; +// +// return os; +// } SUITE(test_queue_mpmc_mutex) { diff --git a/test/test_queue_mpmc_mutex_small.cpp b/test/test_queue_mpmc_mutex_small.cpp new file mode 100644 index 00000000..0c57c332 --- /dev/null +++ b/test/test_queue_mpmc_mutex_small.cpp @@ -0,0 +1,460 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#include +#include +#include +#include +#include +#include + +#include "etl/queue_mpmc_mutex.h" + +#if defined(ETL_COMPILER_MICROSOFT) + #include +#endif + +#define REALTIME_TEST 1 + +namespace +{ + struct Data + { + Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) + : a(a_), + b(b_), + c(c_), + d(d_) + { + } + + Data() + : a(0), + b(0), + c(0), + d(0) + { + } + + int a; + int b; + int c; + int d; + }; + + typedef etl::queue_mpmc_mutex QueueInt; + typedef etl::iqueue_mpmc_mutex IQueueInt; + + typedef etl::queue_mpmc_mutex QueueInt255; + +// bool operator ==(const Data& lhs, const Data& rhs) +// { +// return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); +// } + +// std::ostream& operator <<(std::ostream& os, const Data& data) +// { +// os << data.a << " " << data.b << " " << data.c << " " << data.d; +// +// return os; +// } + + SUITE(test_queue_mpmc_mutex) + { + //************************************************************************* + TEST(test_constructor) + { + QueueInt queue; + + CHECK_EQUAL(4U, queue.max_size()); + CHECK_EQUAL(4U, queue.capacity()); + } + + //************************************************************************* + TEST(test_size_push_pop) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + CHECK_EQUAL(4U, queue.available()); + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + CHECK_EQUAL(1U, queue.size()); + CHECK_EQUAL(3U, queue.available()); + + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + CHECK_EQUAL(2U, queue.available()); + + queue.push(3); + CHECK_EQUAL(3U, queue.size()); + CHECK_EQUAL(1U, queue.available()); + + queue.push(4); + CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(0U, queue.available()); + + CHECK(!queue.push(5)); + CHECK(!queue.push(5)); + + int i; + + CHECK(queue.pop(i)); + CHECK_EQUAL(1, i); + CHECK_EQUAL(3U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(2, i); + CHECK_EQUAL(2U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(3, i); + CHECK_EQUAL(1U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(4, i); + CHECK_EQUAL(0U, queue.size()); + + CHECK(!queue.pop(i)); + CHECK(!queue.pop(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_iqueue) + { + QueueInt queue; + + IQueueInt& iqueue = queue; + + CHECK_EQUAL(0U, iqueue.size()); + + iqueue.push(1); + CHECK_EQUAL(1U, iqueue.size()); + + iqueue.push(2); + CHECK_EQUAL(2U, iqueue.size()); + + iqueue.push(3); + CHECK_EQUAL(3U, iqueue.size()); + + iqueue.push(4); + CHECK_EQUAL(4U, iqueue.size()); + + CHECK(!iqueue.push(5)); + CHECK(!iqueue.push(5)); + + int i; + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(1, i); + CHECK_EQUAL(3U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(2, i); + CHECK_EQUAL(2U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(3, i); + CHECK_EQUAL(1U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(4, i); + CHECK_EQUAL(0U, iqueue.size()); + + CHECK(!iqueue.pop(i)); + CHECK(!iqueue.pop(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_void) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + CHECK_EQUAL(1U, queue.size()); + + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + + queue.push(3); + CHECK_EQUAL(3U, queue.size()); + + queue.push(4); + CHECK_EQUAL(4U, queue.size()); + + CHECK(!queue.push(5)); + CHECK(!queue.push(5)); + + CHECK(queue.pop()); + CHECK_EQUAL(3U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(2U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(1U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(0U, queue.size()); + + CHECK(!queue.pop()); + CHECK(!queue.pop()); + } + + //************************************************************************* + TEST(test_push_255) + { + QueueInt255 queue; + + for (int i = 0; i < 255; ++i) + { + queue.push(i); + } + + CHECK_EQUAL(255U, queue.size()); + } + + //************************************************************************* + TEST(test_clear) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + queue.push(2); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + + // Do it again to check that clear() didn't screw up the internals. + queue.push(1); + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + } + + //************************************************************************* + TEST(test_empty) + { + QueueInt queue; + CHECK(queue.empty()); + + queue.push(1); + CHECK(!queue.empty()); + + queue.clear(); + CHECK(queue.empty()); + + queue.push(1); + CHECK(!queue.empty()); + } + + //************************************************************************* + TEST(test_full) + { + QueueInt queue; + CHECK(!queue.full()); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + CHECK(queue.full()); + + queue.clear(); + CHECK(!queue.full()); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + CHECK(queue.full()); + } + + //========================================================================= +#if REALTIME_TEST && defined(ETL_COMPILER_MICROSOFT) + #if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported + #define SET_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL) + #define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1); + #define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2); + #define FIX_PROCESSOR_AFFINITY3 SetThreadAffinityMask(GetCurrentThread(), 4); + #define FIX_PROCESSOR_AFFINITY4 SetThreadAffinityMask(GetCurrentThread(), 8); + #else + #error No thread priority modifier defined + #endif + + etl::queue_mpmc_mutex queue; + + const size_t LENGTH = 100000; + + std::vector push1; + std::vector push2; + + std::vector pop1; + std::vector pop2; + + volatile std::atomic_bool start; + + void push_thread1() + { + FIX_PROCESSOR_AFFINITY1; + SET_THREAD_PRIORITY; + + size_t count = 0; + int value = 0; + + while (!start.load()); + + while (count < (LENGTH / 2)) + { + if (queue.push(value)) + { + push1.push_back(value); + ++count; + ++value; + } + } + } + + void push_thread2() + { + FIX_PROCESSOR_AFFINITY2; + SET_THREAD_PRIORITY; + + size_t count = 0; + int value = LENGTH / 2; + + while (!start.load()); + + while (count < (LENGTH / 2)) + { + if (queue.push(value)) + { + push2.push_back(value); + ++count; + ++value; + } + } + } + + void pop_thread1() + { + FIX_PROCESSOR_AFFINITY3; + SET_THREAD_PRIORITY; + + size_t count = 0; + + while (!start.load()); + + while (count < (LENGTH / 2)) + { + int i; + + if (queue.pop(i)) + { + pop1.push_back(i); + ++count; + } + } + } + + void pop_thread2() + { + FIX_PROCESSOR_AFFINITY4; + SET_THREAD_PRIORITY; + + size_t count = 0; + + while (!start.load()); + + while (count < (LENGTH / 2)) + { + int i; + + if (queue.pop(i)) + { + pop2.push_back(i); + ++count; + } + } + } + + TEST(queue_threads) + { + push1.reserve(LENGTH / 2); + push2.reserve(LENGTH / 2);; + + pop1.reserve(LENGTH / 2);; + pop2.reserve(LENGTH / 2);; + + start = false; + + std::thread t1(push_thread1); + std::thread t2(push_thread2); + std::thread t3(pop_thread1); + std::thread t4(pop_thread2); + + start.store(true); + + // Join the threads with the main thread + t1.join(); + t2.join(); + t3.join(); + t4.join(); + + // Combine input vectors. + std::vector push; + push.insert(push.end(), push1.begin(), push1.end()); + push.insert(push.end(), push2.begin(), push2.end()); + std::sort(push.begin(), push.end()); + + // Combine output vectors. + std::vector pop; + pop.insert(pop.end(), pop1.begin(), pop1.end()); + pop.insert(pop.end(), pop2.begin(), pop2.end()); + std::sort(pop.begin(), pop.end()); + + CHECK_EQUAL(LENGTH, push.size()); + CHECK_EQUAL(LENGTH, pop.size()); + + for (size_t i = 0; i < LENGTH; ++i) + { + CHECK_EQUAL(push[i], pop[i]); + CHECK_EQUAL(i, pop[i]); + } + } +#endif + }; +} diff --git a/test/test_queue_spsc_atomic_small.cpp b/test/test_queue_spsc_atomic_small.cpp new file mode 100644 index 00000000..fd8a5274 --- /dev/null +++ b/test/test_queue_spsc_atomic_small.cpp @@ -0,0 +1,330 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#include +#include +#include + +#include "etl/queue_spsc_atomic.h" + +#if defined(ETL_COMPILER_MICROSOFT) + #include +#endif + +#define REALTIME_TEST 0 + +namespace +{ + typedef etl::queue_spsc_atomic QueueInt; + typedef etl::iqueue_spsc_atomic IQueueInt; + + typedef etl::queue_spsc_atomic QueueInt254; + + SUITE(test_queue_atomic) + { + //************************************************************************* + TEST(test_constructor) + { + QueueInt queue; + + CHECK_EQUAL(4U, queue.max_size()); + CHECK_EQUAL(4U, queue.capacity()); + } + + //************************************************************************* + TEST(test_size_push_pop) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + CHECK_EQUAL(4U, queue.available()); + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + CHECK_EQUAL(1U, queue.size()); + CHECK_EQUAL(3U, queue.available()); + + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + CHECK_EQUAL(2U, queue.available()); + + queue.push(3); + CHECK_EQUAL(3U, queue.size()); + CHECK_EQUAL(1U, queue.available()); + + queue.push(4); + CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(0U, queue.available()); + + CHECK(!queue.push(5)); + CHECK(!queue.push(5)); + + int i; + + CHECK(queue.pop(i)); + CHECK_EQUAL(1, i); + CHECK_EQUAL(3U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(2, i); + CHECK_EQUAL(2U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(3, i); + CHECK_EQUAL(1U, queue.size()); + + CHECK(queue.pop(i)); + CHECK_EQUAL(4, i); + CHECK_EQUAL(0U, queue.size()); + + CHECK(!queue.pop(i)); + CHECK(!queue.pop(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_iqueue) + { + QueueInt queue; + + IQueueInt& iqueue = queue; + + CHECK_EQUAL(0U, iqueue.size()); + + iqueue.push(1); + CHECK_EQUAL(1U, iqueue.size()); + + iqueue.push(2); + CHECK_EQUAL(2U, iqueue.size()); + + iqueue.push(3); + CHECK_EQUAL(3U, iqueue.size()); + + iqueue.push(4); + CHECK_EQUAL(4U, iqueue.size()); + + CHECK(!iqueue.push(5)); + CHECK(!iqueue.push(5)); + + int i; + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(1, i); + CHECK_EQUAL(3U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(2, i); + CHECK_EQUAL(2U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(3, i); + CHECK_EQUAL(1U, iqueue.size()); + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(4, i); + CHECK_EQUAL(0U, iqueue.size()); + + CHECK(!iqueue.pop(i)); + CHECK(!iqueue.pop(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_void) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + CHECK_EQUAL(1U, queue.size()); + + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + + queue.push(3); + CHECK_EQUAL(3U, queue.size()); + + queue.push(4); + CHECK_EQUAL(4U, queue.size()); + + CHECK(!queue.push(5)); + CHECK(!queue.push(5)); + + CHECK(queue.pop()); + CHECK_EQUAL(3U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(2U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(1U, queue.size()); + + CHECK(queue.pop()); + CHECK_EQUAL(0U, queue.size()); + + CHECK(!queue.pop()); + CHECK(!queue.pop()); + } + + //************************************************************************* + TEST(test_push_254) + { + QueueInt254 queue; + + for (int i = 0; i < 254; ++i) + { + queue.push(i); + } + + CHECK_EQUAL(254U, queue.size()); + } + + //************************************************************************* + TEST(test_clear) + { + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + queue.push(2); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + + // Do it again to check that clear() didn't screw up the internals. + queue.push(1); + queue.push(2); + CHECK_EQUAL(2U, queue.size()); + queue.clear(); + CHECK_EQUAL(0U, queue.size()); + } + + //************************************************************************* + TEST(test_empty) + { + QueueInt queue; + CHECK(queue.empty()); + + queue.push(1); + CHECK(!queue.empty()); + + queue.clear(); + CHECK(queue.empty()); + + queue.push(1); + CHECK(!queue.empty()); + } + + //************************************************************************* + TEST(test_full) + { + QueueInt queue; + CHECK(!queue.full()); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + CHECK(queue.full()); + + queue.clear(); + CHECK(!queue.full()); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + CHECK(queue.full()); + } + + //========================================================================= +#if REALTIME_TEST && defined(ETL_COMPILER_MICROSOFT) + #if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported + #define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1); + #define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2); + #else + #error No thread priority modifier defined + #endif + + size_t ticks = 0; + + etl::queue_spsc_atomic queue; + + const size_t LENGTH = 1000000; + + void timer_event() + { + FIX_PROCESSOR_AFFINITY1; + + const size_t TICK = 1; + size_t tick = TICK; + ticks = 1; + + while (ticks <= LENGTH) + { + if (queue.push(ticks)) + { + ++ticks; + } + } + } + + TEST(queue_threads) + { + FIX_PROCESSOR_AFFINITY2; + + std::vector tick_list; + tick_list.reserve(LENGTH); + + std::thread t1(timer_event); + + while (tick_list.size() < LENGTH) + { + int i; + + if (queue.pop(i)) + { + tick_list.push_back(i); + } + } + + // Join the thread with the main thread + t1.join(); + + CHECK_EQUAL(LENGTH, tick_list.size()); + + for (size_t i = 0; i < LENGTH; ++i) + { + CHECK_EQUAL(i + 1, tick_list[i]); + } + } +#endif + }; +} diff --git a/test/test_queue_spsc_isr_small.cpp b/test/test_queue_spsc_isr_small.cpp new file mode 100644 index 00000000..3895b3d0 --- /dev/null +++ b/test/test_queue_spsc_isr_small.cpp @@ -0,0 +1,587 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" + +#include "etl/queue_spsc_isr.h" + +#include +#include +#include + +#if defined(ETL_COMPILER_MICROSOFT) +#include +#endif + +#define REALTIME_TEST 0 + +namespace +{ + class Access + { + public: + + static void clear() + { + called_lock = false; + called_unlock = false; + } + + static void lock() + { + called_lock = true; + } + + static void unlock() + { + called_unlock = true; + } + + static bool called_lock; + static bool called_unlock; + }; + + bool Access::called_lock; + bool Access::called_unlock; + + typedef etl::queue_spsc_isr QueueInt; + typedef etl::iqueue_spsc_isr IQueueInt; + + typedef etl::queue_spsc_isr QueueInt255; + + SUITE(test_queue_isr) + { + //************************************************************************* + TEST(test_constructor) + { + Access::clear(); + + QueueInt queue; + + CHECK_EQUAL(4U, queue.max_size()); + CHECK_EQUAL(4U, queue.capacity()); + + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + } + + //************************************************************************* + TEST(test_size_push_pop) + { + Access::clear(); + + QueueInt queue; + + CHECK_EQUAL(0U, queue.size_from_isr()); + + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + Access::clear(); + + CHECK_EQUAL(4U, queue.available_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + Access::clear(); + + CHECK_EQUAL(0U, queue.size()); + + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + Access::clear(); + + CHECK_EQUAL(4U, queue.available()); + + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + Access::clear(); + + queue.push_from_isr(1); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, queue.size_from_isr()); + CHECK_EQUAL(3U, queue.available_from_isr()); + + Access::clear(); + + queue.push(2); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(2U, queue.size_from_isr()); + CHECK_EQUAL(2U, queue.available_from_isr()); + + Access::clear(); + + queue.push(3); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, queue.size_from_isr()); + CHECK_EQUAL(1U, queue.available_from_isr()); + + Access::clear(); + + queue.push(4); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(4U, queue.size_from_isr()); + CHECK_EQUAL(0U, queue.available_from_isr()); + + Access::clear(); + + CHECK(!queue.push(5)); + CHECK(!queue.push_from_isr(5)); + + Access::clear(); + + int i; + + CHECK(queue.pop(i)); + CHECK_EQUAL(1, i); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr(i)); + CHECK_EQUAL(2, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(2U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr(i)); + CHECK_EQUAL(3, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr(i)); + CHECK_EQUAL(4, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(0U, queue.size_from_isr()); + + Access::clear(); + + CHECK(!queue.pop(i)); + CHECK(!queue.pop_from_isr(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_iqueue) + { + Access::clear(); + + QueueInt queue; + + IQueueInt& iqueue = queue; + + CHECK_EQUAL(0U, iqueue.size_from_isr()); + + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + Access::clear(); + + CHECK_EQUAL(0U, iqueue.size()); + + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + Access::clear(); + + iqueue.push_from_isr(1); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, iqueue.size_from_isr()); + + Access::clear(); + + iqueue.push(2); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(2U, iqueue.size_from_isr()); + + Access::clear(); + + iqueue.push(3); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, iqueue.size_from_isr()); + + Access::clear(); + + iqueue.push(4); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(4U, iqueue.size_from_isr()); + + Access::clear(); + + CHECK(!iqueue.push(5)); + CHECK(!iqueue.push_from_isr(5)); + + Access::clear(); + + int i; + + CHECK(iqueue.pop(i)); + CHECK_EQUAL(1, i); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, iqueue.size_from_isr()); + + Access::clear(); + + CHECK(iqueue.pop_from_isr(i)); + CHECK_EQUAL(2, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(2U, iqueue.size_from_isr()); + + Access::clear(); + + CHECK(iqueue.pop_from_isr(i)); + CHECK_EQUAL(3, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, iqueue.size_from_isr()); + + Access::clear(); + + CHECK(iqueue.pop_from_isr(i)); + CHECK_EQUAL(4, i); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(0U, iqueue.size_from_isr()); + + Access::clear(); + + CHECK(!iqueue.pop(i)); + CHECK(!iqueue.pop_from_isr(i)); + } + + //************************************************************************* + TEST(test_size_push_pop_void) + { + Access::clear(); + + QueueInt queue; + + CHECK_EQUAL(0U, queue.size_from_isr()); + + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + Access::clear(); + + CHECK_EQUAL(0U, queue.size()); + + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + Access::clear(); + + queue.push_from_isr(1); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, queue.size_from_isr()); + + Access::clear(); + + queue.push(2); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(2U, queue.size_from_isr()); + + Access::clear(); + + queue.push(3); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, queue.size_from_isr()); + + Access::clear(); + + queue.push(4); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(4U, queue.size_from_isr()); + + Access::clear(); + + CHECK(!queue.push(5)); + CHECK(!queue.push_from_isr(5)); + + Access::clear(); + + CHECK(queue.pop()); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(3U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(2U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(1U, queue.size_from_isr()); + + Access::clear(); + + CHECK(queue.pop_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + CHECK_EQUAL(0U, queue.size_from_isr()); + + Access::clear(); + + CHECK(!queue.pop()); + CHECK(!queue.pop_from_isr()); + } + + //************************************************************************* + TEST(test_push_255) + { + QueueInt255 queue; + + for (int i = 0; i < 255; ++i) + { + queue.push(i); + } + + CHECK_EQUAL(255U, queue.size()); + } + + //************************************************************************* + TEST(test_clear) + { + Access::clear(); + + QueueInt queue; + + CHECK_EQUAL(0U, queue.size()); + + queue.push(1); + queue.push(2); + queue.clear(); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + CHECK_EQUAL(0U, queue.size()); + + Access::clear(); + + // Do it again to check that clear() didn't screw up the internals. + queue.push_from_isr(1); + queue.push_from_isr(2); + CHECK_EQUAL(2U, queue.size_from_isr()); + queue.clear_from_isr(); + CHECK_EQUAL(0U, queue.size_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + } + + //************************************************************************* + TEST(test_empty) + { + Access::clear(); + + QueueInt queue; + + CHECK(queue.empty()); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + queue.push(1); + + Access::clear(); + + CHECK(!queue.empty()); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + queue.clear(); + Access::clear(); + + CHECK(queue.empty_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + queue.push(1); + + Access::clear(); + + CHECK(!queue.empty_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + } + + //************************************************************************* + TEST(test_full) + { + Access::clear(); + + QueueInt queue; + + CHECK(!queue.full()); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + Access::clear(); + + CHECK(queue.full()); + CHECK(Access::called_lock); + CHECK(Access::called_unlock); + + queue.clear(); + Access::clear(); + + CHECK(!queue.full_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + + queue.push(1); + queue.push(2); + queue.push(3); + queue.push(4); + + Access::clear(); + + CHECK(queue.full_from_isr()); + CHECK(!Access::called_lock); + CHECK(!Access::called_unlock); + } + + //========================================================================= +#if REALTIME_TEST && defined(ETL_COMPILER_MICROSOFT) + #if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported + #define RAISE_THREAD_PRIORITY SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) + #define FIX_PROCESSOR_AFFINITY SetThreadAffinityMask(GetCurrentThread(), 1); + #else + #error No thread priority modifier defined + #endif + + size_t ticks = 0; + + struct ThreadLock + { + static void lock() + { + mutex.lock(); + } + + static void unlock() + { + mutex.unlock(); + } + + static std::mutex mutex; + }; + + std::mutex ThreadLock::mutex; + + etl::queue_spsc_isr queue; + + const size_t LENGTH = 1000; + + void timer_thread() + { + RAISE_THREAD_PRIORITY; + FIX_PROCESSOR_AFFINITY; + + const size_t TICK = 1; + size_t tick = TICK; + ticks = 1; + + while (ticks <= LENGTH) + { + if (ThreadLock::mutex.try_lock()) + { + if (queue.push_from_isr(ticks)) + { + ++ticks; + } + + ThreadLock::mutex.unlock(); + } + + Sleep(0); + } + } + + TEST(queue_threads) + { + FIX_PROCESSOR_AFFINITY; + + std::vector tick_list; + tick_list.reserve(LENGTH); + + std::thread t1(timer_thread); + + while (tick_list.size() < LENGTH) + { + int i; + + if (queue.pop(i)) + { + tick_list.push_back(i); + } + } + + // Join the thread with the main thread + t1.join(); + + CHECK_EQUAL(LENGTH, tick_list.size()); + + for (size_t i = 0; i < LENGTH; ++i) + { + CHECK_EQUAL(i + 1, tick_list[i]); + } + } +#endif + }; +} diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index e79c511c..89fd056b 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -704,9 +704,13 @@ + + + + true true diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index 52458239..31d549a3 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -1109,6 +1109,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + From bec1e40c55fdd2182347a9f08d926ef3b8d304bc Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 9 Aug 2018 20:51:46 +0100 Subject: [PATCH 27/28] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # support/Release notes.txt --- .../ArmTimerCallbacks.uvprojx | 2 +- .../ArmTimerCallbacks - C++/etl_profile.h | 5 +++-- examples/ArmTimerCallbacks - C++/main.cpp | 19 +++++++++++++++++-- include/etl/atomic/atomic_gcc_sync.h | 2 +- include/etl/debug_count.h | 18 ++++-------------- include/etl/stl/iterator.h | 2 +- include/etl/version.h | 8 ++++---- support/Release notes.txt | 5 +++++ test/test_io_port.cpp | 11 +++++++++-- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx index ed494f20..b7fa094b 100644 --- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx +++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx @@ -336,7 +336,7 @@ - ..\..\src;..\ArmTimerCallbacks - C++ + ..\..\include;..\ArmTimerCallbacks - C++ diff --git a/examples/ArmTimerCallbacks - C++/etl_profile.h b/examples/ArmTimerCallbacks - C++/etl_profile.h index 4560ba1e..a2e2f33f 100644 --- a/examples/ArmTimerCallbacks - C++/etl_profile.h +++ b/examples/ArmTimerCallbacks - C++/etl_profile.h @@ -9,13 +9,14 @@ #define ETL_IVECTOR_REPAIR_ENABLE #define ETL_IDEQUE_REPAIR_ENABLE #define ETL_IN_UNIT_TEST +#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK #if (__CC_ARM == 1) // ARM5 compiler - #include "profiles/armv5.h" + #include "etl/profiles/armv5.h" #else // ARM6 compiler - #include "profiles/armv6.h" + #include "etl/profiles/armv6.h" #endif #endif diff --git a/examples/ArmTimerCallbacks - C++/main.cpp b/examples/ArmTimerCallbacks - C++/main.cpp index 05f19b17..d2d0e5a3 100644 --- a/examples/ArmTimerCallbacks - C++/main.cpp +++ b/examples/ArmTimerCallbacks - C++/main.cpp @@ -9,8 +9,23 @@ extern "C" #include "stm32f4xx.h" // Device header } -#include "function.h" -#include "callback_timer.h" +#include "etl/function.h" +#include "etl/callback_timer.h" +#include "etl/vector.h" + +struct FP +{ + void (*function)(); +}; + +static etl::vector power_callbacks; + +void register_poweroff_callback(void (*function)()) +{ + FP fp = { function }; + power_callbacks.push_back(fp); +} + const int N_TIMERS = 4; diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index d26005b2..725c44ac 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -34,7 +34,7 @@ SOFTWARE. #include "../static_assert.h" #include "../nullptr.h" -#include +//#include #include #pragma GCC diagnostic push diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index b603b00c..66b40530 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -84,25 +84,15 @@ namespace etl return *this; } - inline debug_count& operator +=(int32_t n) - { - count += n; - return *this; - } - - inline debug_count& operator -=(int32_t n) - { - count -= n; - return *this; - } - - inline debug_count& operator +=(size_t n) + template + inline debug_count& operator +=(T n) { count += int32_t(n); return *this; } - inline debug_count& operator -=(size_t n) + template + inline debug_count& operator -=(T n) { count -= int32_t(n); return *this; diff --git a/include/etl/stl/iterator.h b/include/etl/stl/iterator.h index 91299a26..56f2e5d6 100644 --- a/include/etl/stl/iterator.h +++ b/include/etl/stl/iterator.h @@ -40,4 +40,4 @@ SOFTWARE. #include #endif -#endif \ No newline at end of file +#endif diff --git a/include/etl/version.h b/include/etl/version.h index 531de754..a89a8969 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.15.0" -#define ETL_VERSION_W L"11.15.0" -#define ETL_VERSION_U16 u"11.15.0" -#define ETL_VERSION_U32 U"11.15.0" +#define ETL_VERSION "11.15.1" +#define ETL_VERSION_W L"11.15.1" +#define ETL_VERSION_U16 u"11.15.1" +#define ETL_VERSION_U32 U"11.15.1" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 15 #define ETL_VERSION_PATCH 0 diff --git a/support/Release notes.txt b/support/Release notes.txt index fde6c598..f977f9d7 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +11.15.1 +io_port_test Fixed unaligned access error. +debug_count Removed typed += & -= operators and replaced with templates. + =============================================================================== 11.15.0 Added 'memory model' selection for queues to allow more efficient implementations. diff --git a/test/test_io_port.cpp b/test/test_io_port.cpp index 88223339..4634e8da 100644 --- a/test/test_io_port.cpp +++ b/test/test_io_port.cpp @@ -95,7 +95,14 @@ namespace //************************************************************************* TEST(test_dynamic_io_port) { - uint8_t memory[7]; + union U + { + uint16_t dummy; + uint8_t memory[7]; + } u; + + uint8_t* memory = &u.memory[0]; + memory[0] = 0x12; memory[1] = 0x00; memory[2] = 0x00; @@ -104,7 +111,7 @@ namespace memory[5] = 0x9A; memory[6] = 0x00; - dynamic_serial_port port(memory); + dynamic_serial_port port(&u.memory[0]); uint8_t rxdata = port.rxdata; CHECK_EQUAL(memory[0], rxdata); From d345709c3cd68e096621777b8848659b52f3d26c Mon Sep 17 00:00:00 2001 From: Arek Sredzki Date: Tue, 14 Aug 2018 23:43:20 -0700 Subject: [PATCH 28/28] Exchange use of deprecated/removed std::bind1st for std::bind when c++11 is used #86 (#87) * Exchange use of deprecated/removed std::bind1st for std::bind when c++11 is used #86 * Use ETL_CPP11_SUPPORTED instead of checking cpp verison --- include/etl/algorithm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index a45f66cd..f808db86 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -617,7 +617,11 @@ namespace etl for (TIterator1 i = begin1; i != end1; ++i) { +#if ETL_CPP11_SUPPORTED + 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))) +#endif { size_t n = std::count(begin2, end2, *i); @@ -650,7 +654,11 @@ namespace etl { for (TIterator1 i = begin1; i != end1; ++i) { +#if ETL_CPP11_SUPPORTED + 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))) +#endif { size_t n = std::count(begin2, end2, *i);