From 0acd537a7e1877e46b81535d46aaa574cd10aef2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 15 Nov 2021 09:31:20 +0000 Subject: [PATCH] Updates --- include/etl/algorithm.h | 37 ++++++++++++++++++++++--------------- include/etl/platform.h | 8 ++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 0f635f8c..5a3bd4ff 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -142,18 +142,18 @@ namespace etl #elif ETL_FORCE_CONSTEXPR_ALGORITHMS template ETL_CONSTEXPR14 - typename etl::enable_if::type + typename etl::enable_if::type copy(TIterator1 sb, TIterator1 se, TIterator2 db) { - typedef typename etl::iterator_traits::value_type value_t; - typedef typename etl::iterator_traits::difference_type difference_t; + while (sb != se) + { + *db++ = *sb++; + } - difference_t count = (se - sb); - - return TIterator2(__builtin_memmove(db, sb, sizeof(value_t) * count)) + count; + return db; } #else template @@ -418,7 +418,7 @@ namespace etl difference_t count = (se - sb); TIterator2 db = de - count; - return TIterator2(__builin_memmove(db, sb, sizeof(value_t) * count)) + count; + return TIterator2(__builtin_memmove(db, sb, sizeof(value_t) * count)) + count; } #else // pointer and pod @@ -710,7 +710,7 @@ namespace etl #elif defined(ETL_FORCE_CONSTEXPR_ALGORITHMS) template ETL_CONSTEXPR14 - typename etl::enable_if::type + typename etl::enable_if::type fill_n(TIterator first, TSize count, const TValue& value) { while (count != 0) @@ -777,6 +777,7 @@ namespace etl //*************************************************************************** // equal + // Not pointer types or not trivially copyable. template ETL_NODISCARD ETL_CONSTEXPR14 @@ -798,6 +799,8 @@ namespace etl } #if ETL_USE_BUILTIN_MEMCMP + // Using builtins. + // Pointer types and trivially copyable. template ETL_NODISCARD ETL_CONSTEXPR14 @@ -812,13 +815,15 @@ namespace etl return (__builtin_memcmp(first1, first2, sizeof(value_t) * (last1 - first1)) == 0); } #elif ETL_FORCE_CONSTEXPR_ALGORITHMS + // Forced constexpr. + // Not pointer types or not trivially copyable. template ETL_NODISCARD ETL_CONSTEXPR14 - typename etl::enable_if::type + typename etl::enable_if::type equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) { while (first1 != last1) @@ -832,6 +837,7 @@ namespace etl return true; } #else + // Pointer types and trivially copyable. template ETL_NODISCARD typename etl::enable_if ETL_NODISCARD ETL_CONSTEXPR14 diff --git a/include/etl/platform.h b/include/etl/platform.h index d37f1959..a4736b46 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -211,6 +211,14 @@ SOFTWARE. #define ETL_CONSTINIT #endif +#if !defined(ETL_USING_INITIALIZER_LIST) + #if ETL_CPP11_SUPPORTED && ETL_USING_STL && ETL_NOT_USING_STLPORT + #define ETL_USING_INITIALIZER_LIST 1 + #else + #define ETL_USING_INITIALIZER_LIST 0 + #endif +#endif + // Check for availability of certain builtins #include "profiles/determine_builtin_support.h"