From 37d2d9e08498f5c81ba30bc54b327a85264872c5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 29 Apr 2018 20:23:22 +0100 Subject: [PATCH] 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 +