diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx
index f89a79e0..7b7077f4 100644
--- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx
+++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx
@@ -11,7 +11,7 @@
0x4
ARM-ADS
6130001::V6.13.1::.\ARMCLANG
- 1
+ 0
STM32F401RETx
@@ -312,7 +312,7 @@
1
- 7
+ 1
0
0
1
@@ -321,7 +321,7 @@
1
0
0
- 3
+ 2
0
0
1
diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h
index 690a802b..a9960120 100644
--- a/include/etl/algorithm.h
+++ b/include/etl/algorithm.h
@@ -32,34 +32,1299 @@ SOFTWARE.
#define ETL_ALGORITHM_INCLUDED
///\defgroup algorithm algorithm
-/// Reverse engineered algorithms from C++ 0x11
+/// Including reverse engineered algorithms from C++ 0x11, 0x14, 0x17
/// Additional new variants of certain algorithms.
///\ingroup utilities
-#include "stl/algorithm.h"
-#include "stl/utility.h"
-#include "stl/iterator.h"
-#include "stl/functional.h"
-
#include
+#include
#include "platform.h"
-#include "iterator.h"
#include "type_traits.h"
#include "container.h"
+#include "iterator.h"
+#include "functional.h"
+#include "utility.h"
+#if !defined(ETL_NO_STL)
+ #include
+ #include
+ #include
+ #include
+#endif
+
+//*****************************************************************************
+// Algorithms defined by the ETL
+//*****************************************************************************
namespace etl
{
+// We can't have std::swap and etl::swap templates coexisting in the unit tests
+// as the compiler will be unable to decide of which one to use, due to ADL.
+#if defined(ETL_NO_STL) && !defined(ETL_IN_UNIT_TEST)
+ //***************************************************************************
+ // swap
+#if ETL_CPP11_SUPPORTED
+ template
+ void swap(T& a, T& b)
+ {
+ T temp(etl::move(a));
+ a = etl::move(b);
+ b = etl::move(temp);
+ }
+#else
+ template
+ void swap(T& a, T& b)
+ {
+ T temp(a);
+ a = b;
+ b = temp;
+ }
+#endif
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // iter_swap
+ template
+ void iter_swap(TIterator1 a, TIterator2 b)
+ {
+ typename etl::iterator_traits::value_type c = *a;
+ *a = *b;
+ *b = c;
+ }
+#else
+ //***************************************************************************
+ // iter_swap
+ template
+ void iter_swap(TIterator1 a, TIterator2 b)
+ {
+ std::iter_swap(a, b);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // swap_ranges
+ template
+ TIterator2 swap_ranges(T1terator1 first1,
+ T1terator1 last1,
+ TIterator2 first2)
+ {
+ while (first1 != last1)
+ {
+ iter_swap(first1++, first2++);
+ }
+
+ return first2;
+ }
+#else
+ //***************************************************************************
+ // swap_ranges
+ template
+ TIterator2 swap_ranges(T1terator1 first1,
+ T1terator1 last1,
+ TIterator2 first2)
+ {
+ return std::swap_ranges(first1, last1, first2);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // copy
+ // Pointer
+ template
+ typename etl::enable_if::value &&
+ etl::is_pointer::value &&
+ etl::is_pod::value_type>::value, TIterator2>::type
+ copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ typedef typename etl::iterator_traits::value_type value_t;
+ typedef typename etl::iterator_traits::difference_type difference_t;
+
+ difference_t count = (se - sb);
+
+ return TIterator2(memmove(db, sb, sizeof(value_t) * count)) + count;
+ }
+
+ // Other iterator
+ template
+ typename etl::enable_if::value ||
+ !etl::is_pointer::value ||
+ !etl::is_pod::value_type>::value, TIterator2>::type
+ copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ while (sb != se)
+ {
+ *db++ = *sb++;
+ }
+
+ return db;
+ }
+#else
+ //***************************************************************************
+ // copy
+ template
+ TIterator2 copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ return std::copy(sb, se, db);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // reverse_copy
+ template
+ TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ while (sb != se)
+ {
+ *(db++) = *(--se);
+ }
+
+ return db;
+ }
+#else
+ //***************************************************************************
+ // reverse_copy
+ template
+ TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ return std::reverse_copy(sb, se, db);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ // copy_n
+ // Pointer
+ template
+ typename etl::enable_if::value &&
+ etl::is_pointer::value &&
+ etl::is_pod::value_type>::value, TIterator2>::type
+ copy_n(TIterator1 sb, TSize count, TIterator2 db)
+ {
+ typedef typename etl::iterator_traits::value_type value_t;
+
+ return TIterator2(memmove(db, sb, sizeof(value_t) * count)) + count;
+ }
+
+ // Other iterator
+ template
+ typename etl::enable_if::value ||
+ !etl::is_pointer::value ||
+ !etl::is_pod::value_type>::value, TIterator2>::type
+ copy_n(TIterator1 sb, TSize count, TIterator2 db)
+ {
+ while (count != 0)
+ {
+ *db++ = *sb++;
+ --count;
+ }
+
+ return db;
+ }
+#else
+ //***************************************************************************
+ /// copy_n
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ TOutputIterator copy_n(TInputIterator i_begin,
+ TSize n,
+ TOutputIterator o_begin)
+ {
+ return std::copy_n(i_begin, n, o_begin);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // copy_backward
+ // Pointer
+ template
+ typename etl::enable_if::value &&
+ etl::is_pointer::value &&
+ etl::is_pod::value_type>::value, TIterator2>::type
+ copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
+ {
+ typedef typename etl::iterator_traits::value_type value_t;
+
+ const size_t length = (se - sb);
+
+ return TIterator2(memmove(de - length, sb, sizeof(value_t) * length));
+ }
+
+ // Other iterator
+ template
+ typename etl::enable_if::value ||
+ !etl::is_pointer::value ||
+ !etl::is_pod::value_type>::value, TIterator2>::type
+ copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
+ {
+ while (se != sb)
+ {
+ *(--de) = *(--se);
+ }
+
+ return de;
+ }
+#else
+ //***************************************************************************
+ // copy_backward
+ template
+ TIterator2 copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
+ {
+ return std::copy_backward(sb, se, de);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // move
+ template
+ TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ while (sb != se)
+ {
+ *db++ = etl::move(*sb++);
+ }
+
+ return db;
+ }
+#else
+ //***************************************************************************
+ // move
+ template
+ TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
+ {
+ return std::move(sb, se, db);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // move_backward
+ template
+ TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
+ {
+ while (sb != se)
+ {
+ *(--de) = etl::move(*(--se));
+ }
+
+ return de;
+ }
+#else
+ //***************************************************************************
+ // move_backward
+ template
+ TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
+ {
+ return std::move_backward(sb, se, de);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // reverse
+ // Pointers
+ template
+ typename etl::enable_if::value, void>::type
+ reverse(TIterator b, TIterator e)
+ {
+ if (b != e)
+ {
+ while (b < --e)
+ {
+ etl::iter_swap(b, e);
+ ++b;
+ }
+ }
+ }
+
+ // Other
+ template
+ typename etl::enable_if::value, void>::type
+ reverse(TIterator b, TIterator e)
+ {
+ while ((b != e) && (b != --e))
+ {
+ etl::iter_swap(b++, e);
+ }
+ }
+#else
+ //***************************************************************************
+ // reverse
+ template
+ void reverse(TIterator b, TIterator e)
+ {
+ std::reverse(b, e);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // lower_bound
+ template
+ ETL_NODISCARD
+ TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ typedef typename etl::iterator_traits::difference_type difference_t;
+
+ difference_t count = etl::distance(first, last);
+
+ while (count > 0)
+ {
+ TIterator itr = first;
+ difference_t step = count / 2;
+
+ etl::advance(itr, step);
+
+ if (compare(*itr, value))
+ {
+ first = ++itr;
+ count -= step + 1;
+ }
+ else
+ {
+ count = step;
+ }
+ }
+
+ return first;
+ }
+
+ template
+ ETL_NODISCARD
+ TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
+ {
+ typedef etl::less::value_type> compare;
+
+ return etl::lower_bound(first, last, value, compare());
+ }
+#else
+ //***************************************************************************
+ // lower_bound
+ template
+ ETL_NODISCARD
+ TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ return std::lower_bound(first, last, value, compare);
+ }
+
+ template
+ ETL_NODISCARD
+ TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
+ {
+ return std::lower_bound(first, last, value);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // upper_bound
+ template
+ ETL_NODISCARD
+ TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ typedef typename etl::iterator_traits::difference_type difference_t;
+
+ difference_t count = etl::distance(first, last);
+
+ while (count > 0)
+ {
+ TIterator itr = first;
+ difference_t step = count / 2;
+
+ etl::advance(itr, step);
+
+ if (!compare(value, *itr))
+ {
+ first = ++itr;
+ count -= step + 1;
+ }
+ else
+ {
+ count = step;
+ }
+ }
+
+ return first;
+ }
+
+ template
+ ETL_NODISCARD
+ TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
+ {
+ typedef etl::less::value_type> compare;
+
+ return etl::upper_bound(first, last, value, compare());
+ }
+#else
+ //***************************************************************************
+ // upper_bound
+ template
+ ETL_NODISCARD
+ TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ return std::upper_bound(first, last, value, compare);
+ }
+
+ template
+ ETL_NODISCARD
+ TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
+ {
+ return std::upper_bound(first, last, value);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // equal_range
+ template
+ ETL_NODISCARD
+ ETL_OR_STD::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare),
+ etl::upper_bound(first, last, value, compare));
+ }
+
+ template
+ ETL_NODISCARD
+ ETL_OR_STD::pair equal_range(TIterator first, TIterator last, const TValue& value)
+ {
+ typedef etl::less::value_type> compare;
+
+ return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare()),
+ etl::upper_bound(first, last, value, compare()));
+ }
+#else
+ //***************************************************************************
+ // equal_range
+ template
+ ETL_NODISCARD
+ std::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ {
+ return std::equal_range(first, last, value, compare);
+ }
+
+ template
+ ETL_NODISCARD
+ std::pair equal_range(TIterator first, TIterator last, const TValue& value)
+ {
+ return std::equal_range(first, last, value);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // find_if
+ template
+ ETL_NODISCARD
+ TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ {
+ while (first != last)
+ {
+ if (predicate(*first))
+ {
+ return first;
+ }
+
+ ++first;
+ }
+
+ return last;
+ }
+#else
+ //***************************************************************************
+ // find_if
+ template
+ ETL_NODISCARD
+ TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ {
+ return std::find_if(first, last, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // find
+ template
+ ETL_NODISCARD
+ TIterator find(TIterator first, TIterator last, const T& value)
+ {
+ while (first != last)
+ {
+ if (*first == value)
+ {
+ return first;
+ }
+
+ ++first;
+ }
+
+ return last;
+ }
+#else
+ //***************************************************************************
+ // find
+ template
+ ETL_NODISCARD
+ TIterator find(TIterator first, TIterator last, const T& value)
+ {
+ return std::find(first, last, value);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // fill
+ template
+ typename etl::enable_if::value || etl::is_same::value) || !etl::is_pointer::value, void>::type
+ fill(TIterator first, TIterator last, const TValue& value)
+ {
+ while (first != last)
+ {
+ *first++ = value;
+ }
+ }
+
+ template
+ typename etl::enable_if<(etl::is_same::value || etl::is_same::value) && etl::is_pointer::value, void>::type
+ fill(TIterator first, TIterator last, const TValue& value)
+ {
+ memset(first, value, last - first);
+ }
+#else
+ //***************************************************************************
+ // fill
+ template
+ void fill(TIterator first, TIterator last, const TValue& value)
+ {
+ std::fill(first, last, value);
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // fill_n
+ template
+ typename etl::enable_if::value || etl::is_same::value) || !etl::is_pointer::value, TIterator>::type
+ fill_n(TIterator first, TSize count, const TValue& value)
+ {
+ for (TSize i = 0; i < count; ++i)
+ {
+ *first++ = value;
+ }
+
+ return first;
+ }
+
+ template
+ typename etl::enable_if<(etl::is_same::value || etl::is_same::value) && etl::is_pointer::value, void>::type
+ fill_n(TIterator first, TSize count, const TValue& value)
+ {
+ memset(first, value, count);
+ }
+#else
+ //***************************************************************************
+ // fill_n
+ template
+ TIterator fill_n(TIterator first, TSize count, const TValue& value)
+ {
+ return std::fill_n(first, count, value);;
+ }
+#endif
+
+#if defined(ETL_NO_STL)
+ //***************************************************************************
+ // count
+ template
+ ETL_NODISCARD
+ typename etl::iterator_traits::difference_type count(TIterator first, TIterator last, const T& value)
+ {
+ typename iterator_traits::difference_type n = 0;
+
+ while (first != last)
+ {
+ if (*first == value)
+ {
+ ++n;
+ }
+
+ ++first;
+ }
+
+ return n;
+ }
+#else
+ //***************************************************************************
+ // count
+ template
+ ETL_NODISCARD
+ typename std::iterator_traits::difference_type count(TIterator first, TIterator last, const T& value)
+ {
+ return std::count(first, last, value);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // count_if
+ template
+ ETL_NODISCARD
+ typename etl::iterator_traits::difference_type count_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ {
+ typename iterator_traits::difference_type n = 0;
+
+ while (first != last)
+ {
+ if (predicate(*first))
+ {
+ ++n;
+ }
+
+ ++first;
+ }
+
+ return n;
+ }
+#else
+ //***************************************************************************
+ // count_if
+ template
+ ETL_NODISCARD
+ typename std::iterator_traits::difference_type count_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ {
+ return std::count_if(first, last, predicate);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // equal
+ template
+ ETL_NODISCARD
+ typename etl::enable_if::value || !etl::is_pointer::value || !etl::is_pod::value_type>::value, bool>::type
+ equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
+ {
+ while (first1 != last1)
+ {
+ if (*first1++ != *first2++)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ template
+ ETL_NODISCARD
+ typename etl::enable_if::value && etl::is_pointer::value && etl::is_pod::value_type>::value, bool>::type
+ equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
+ {
+ typedef typename etl::iterator_traits::value_type value_t;
+
+ return (memcmp(first1, first2, sizeof(value_t) * (last1 - first1)) == 0);
+ }
+#else
+ //***************************************************************************
+ // equal
+ template
+ ETL_NODISCARD
+ bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
+ {
+ return std::equal(first1, last1, first2);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // lexicographical_compare
+ template
+ ETL_NODISCARD
+ bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
+ TIterator2 first2, TIterator2 last2,
+ TCompare compare)
+ {
+ while ((first1 != last1) && (first2 != last2))
+ {
+ if (compare(*first1, *first2))
+ {
+ return true;
+ }
+
+ if (compare(*first2, *first1))
+ {
+ return false;
+ }
+
+ ++first1;
+ ++first2;
+ }
+
+ return (first1 == last1) && (first2 != last2);
+ }
+
+ //***************************************************************************
+ // lexicographical_compare
+ template
+ ETL_NODISCARD
+ bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
+ TIterator2 first2, TIterator2 last2)
+ {
+ typedef etl::less::value_type> compare;
+
+ return etl::lexicographical_compare(first1, last1, first2, last2, compare());
+ }
+#else
+ //***************************************************************************
+ // lexicographical_compare
+ template
+ ETL_NODISCARD
+ bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
+ TIterator2 first2, TIterator2 last2,
+ TCompare compare)
+ {
+ return std::lexicographical_compare(first1, last1, first2, last2, compare);
+ }
+
+ //***************************************************************************
+ // lexicographical_compare
+ template
+ ETL_NODISCARD
+ bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
+ TIterator2 first2, TIterator2 last2)
+ {
+ return std::lexicographical_compare(first1, last1, first2, last2);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // min
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& min(const T& a, const T& b, TCompare compare)
+ {
+ return (compare(a, b)) ? a : b;
+ }
+
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& min(const T& a, const T& b)
+ {
+ typedef etl::less compare;
+
+ return etl::min(a, b, compare());
+ }
+#else
+ //***************************************************************************
+ // min
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& min(const T& a, const T& b, TCompare compare)
+ {
+ return std::min(a, b, compare);
+ }
+
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& min(const T& a, const T& b)
+ {
+ return std::min(a, b);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // max
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& max(const T& a, const T& b, TCompare compare)
+ {
+ return (compare(a, b)) ? b : a;
+ }
+
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& max(const T& a, const T& b)
+ {
+ typedef etl::less compare;
+
+ return etl::max(a, b, compare());
+ }
+#else
+ //***************************************************************************
+ // max
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& max(const T& a, const T& b, TCompare compare)
+ {
+ return std::max(a, b, compare);
+ }
+
+ template
+ ETL_NODISCARD
+ ETL_CONSTEXPR const T& max(const T& a, const T& b)
+ {
+ return std::max(a, b);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // transform
+ template
+ TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
+ {
+ while (first1 != last1)
+ {
+ *d_first++ = unary_operation(*first1++);
+ }
+
+ return d_first;
+ }
+
+ template
+ TIteratorOut transform(TIteratorIn1 first1, TIteratorIn1 last1, TIteratorIn2 first2, TIteratorOut d_first, TBinaryOperation binary_operation)
+ {
+ while (first1 != last1)
+ {
+ *d_first++ = binary_operation(*first1++, *first2++);
+ }
+
+ return d_first;
+ }
+#else
+ //***************************************************************************
+ // transform
+ template
+ TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
+ {
+ return std::transform(first1, last1, d_first, unary_operation);;
+ }
+
+ template
+ TIteratorOut transform(TIteratorIn1 first1, TIteratorIn1 last1, TIteratorIn2 first2, TIteratorOut d_first, TBinaryOperation binary_operation)
+ {
+ return std::transform(first1, last1, first2, d_first, binary_operation);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // Heap
+ namespace private_heap
+ {
+ // Push Heap Helper
+ template
+ void push_heap(TIterator first, TDistance value_index, TDistance top_index, TValue value, TCompare compare)
+ {
+ TDistance parent = (value_index - 1) / 2;
+
+ while ((value_index > top_index) && compare(first[parent], value))
+ {
+ first[value_index] = first[parent];
+ value_index = parent;
+ parent = (value_index - 1) / 2;
+ }
+
+ first[value_index] = value;
+ }
+
+ // Adjust Heap Helper
+ template
+ void adjust_heap(TIterator first, TDistance value_index, TDistance length, TValue value, TCompare compare)
+ {
+ TDistance top_index = value_index;
+ TDistance child2nd = (2 * value_index) + 2;
+
+ while (child2nd < length)
+ {
+ if (compare(first[child2nd], first[child2nd - 1]))
+ {
+ child2nd--;
+ }
+
+ first[value_index] = first[child2nd];
+ value_index = child2nd;
+ child2nd = 2 * (child2nd + 1);
+ }
+
+ if (child2nd == length)
+ {
+ first[value_index] = first[child2nd - 1];
+ value_index = child2nd - 1;
+ }
+
+ push_heap(first, value_index, top_index, value, compare);
+ }
+
+ // Is Heap Helper
+ template
+ bool is_heap(const TIterator first, const TDistance n, TCompare compare)
+ {
+ TDistance parent = 0;
+
+ for (TDistance child = 1; child < n; ++child)
+ {
+ if (compare(first[parent], first[child]))
+ {
+ return false;
+ }
+
+ if ((child & 1) == 0)
+ {
+ ++parent;
+ }
+ }
+
+ return true;
+ }
+ }
+
+ // Pop Heap
+ template
+ void pop_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ typedef typename etl::iterator_traits::value_type value_t;
+ typedef typename etl::iterator_traits::difference_type distance_t;
+
+ value_t value = last[-1];
+ last[-1] = first[0];
+
+ private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), value, compare);
+ }
+
+ // Pop Heap
+ template
+ void pop_heap(TIterator first, TIterator last)
+ {
+ typedef etl::less::value_type> compare;
+
+ etl::pop_heap(first, last, compare());
+ }
+
+ // Push Heap
+ template
+ void push_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ typedef typename etl::iterator_traits::difference_type difference_t;
+ typedef typename etl::iterator_traits::value_type value_t;
+
+ private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(*(last - 1)), compare);
+ }
+
+ // Push Heap
+ template
+ void push_heap(TIterator first, TIterator last)
+ {
+ typedef etl::less::value_type> compare;
+
+ etl::push_heap(first, last, compare());
+ }
+
+ // Make Heap
+ template
+ void make_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ typedef typename etl::iterator_traits::difference_type difference_t;
+
+ if ((last - first) < 2)
+ {
+ return;
+ }
+
+ difference_t length = last - first;
+ difference_t parent = (length - 2) / 2;
+
+ while (true)
+ {
+ private_heap::adjust_heap(first, parent, length, *(first + parent), compare);
+
+ if (parent == 0)
+ {
+ return;
+ }
+
+ --parent;
+ }
+ }
+
+ // Make Heap
+ template
+ void make_heap(TIterator first, TIterator last)
+ {
+ typedef etl::less::value_type> compare;
+
+ etl::make_heap(first, last, compare());
+ }
+
+ // Is Heap
+ template
+ ETL_NODISCARD
+ bool is_heap(TIterator first, TIterator last)
+ {
+ typedef etl::less::value_type> compare;
+
+ return private_heap::is_heap(first, last - first, compare());
+ }
+
+ // Is Heap
+ template
+ ETL_NODISCARD
+ bool is_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ return private_heap::is_heap(first, last - first, compare);
+ }
+#else
+ //***************************************************************************
+ // Heap
+ // Pop Heap
+ template
+ void pop_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ std::pop_heap(first, last, compare);
+ }
+
+ // Pop Heap
+ template
+ void pop_heap(TIterator first, TIterator last)
+ {
+ std::pop_heap(first, last);
+ }
+
+ // Push Heap
+ template
+ void push_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ std::push_heap(first, last, compare);
+ }
+
+ // Push Heap
+ template
+ void push_heap(TIterator first, TIterator last)
+ {
+ std::push_heap(first, last);
+ }
+
+ // Make Heap
+ template
+ void make_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ std::make_heap(first, last, compare);
+ }
+
+ // Make Heap
+ template
+ void make_heap(TIterator first, TIterator last)
+ {
+ std::make_heap(first, last);
+ }
+
+ // Is Heap
+ template
+ ETL_NODISCARD
+ bool is_heap(TIterator first, TIterator last)
+ {
+ return std::is_heap(first, last);
+ }
+
+ // Is Heap
+ template
+ ETL_NODISCARD
+ bool is_heap(TIterator first, TIterator last, TCompare compare)
+ {
+ return std::is_heap(first, last, compare);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // Search
+ template
+ ETL_NODISCARD
+ TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
+ {
+ while (true)
+ {
+ TIterator1 itr = first;
+ TIterator2 search_itr = search_first;
+
+ while (true)
+ {
+ if (search_itr == search_last)
+ {
+ return first;
+ }
+
+ if (itr == last)
+ {
+ return last;
+ }
+
+ if (!compare(*itr, *search_itr))
+ {
+ break;
+ }
+
+ ++itr;
+ ++search_itr;
+ }
+
+ ++first;
+ }
+ }
+
+ // Search
+ template
+ ETL_NODISCARD
+ TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
+ {
+ typedef etl::equal_to::value_type> compare;
+
+ return etl::search(first, last, search_first, search_last, compare());
+ }
+#else
+ //***************************************************************************
+ // Search
+ template
+ ETL_NODISCARD
+ TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
+ {
+ return std::search(first, last, search_first, search_last, compare);
+ }
+
+ // Search
+ template
+ ETL_NODISCARD
+ TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
+ {
+ return std::search(first, last, search_first, search_last);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // Rotate
+ template
+ TIterator rotate(TIterator first, TIterator middle, TIterator last)
+ {
+ using ETL_OR_STD::swap; // Allow ADL
+
+ TIterator next = middle;
+
+ while (first != next)
+ {
+ using ETL_OR_STD::swap;
+
+ swap(*first++, *next++);
+
+ if (next == last)
+ {
+ next = middle;
+ }
+ else if (first == middle)
+ {
+ middle = next;
+ }
+ }
+
+ return first;
+ }
+#else
+ //***************************************************************************
+ // Rotate
+ template
+ TIterator rotate(TIterator first, TIterator middle, TIterator last)
+ {
+ return std::rotate(first, middle, last);
+ }
+#endif
+
+#if defined (ETL_NO_STL)
+ //***************************************************************************
+ // find_end
+ // Predicate
+ template
+ ETL_NODISCARD
+ TIterator1 find_end(TIterator1 b, TIterator1 e,
+ TIterator2 sb, TIterator2 se,
+ TPredicate predicate)
+ {
+ if (sb == se)
+ {
+ return e;
+ }
+
+ TIterator1 result = e;
+
+ while (true)
+ {
+ TIterator1 new_result = etl::search(b, e, sb, se, predicate);
+
+ if (new_result == e)
+ {
+ break;
+ }
+ else
+ {
+ result = new_result;
+ b = result;
+ ++b;
+ }
+ }
+ return result;
+ }
+
+ // Default
+ template
+ ETL_NODISCARD
+ TIterator1 find_end(TIterator1 b, TIterator1 e,
+ TIterator2 sb, TIterator2 se)
+ {
+ typedef etl::equal_to::value_type> predicate;
+
+ return find_end(b, e, sb, se, predicate());
+ }
+#else
+ //***************************************************************************
+ // find_end
+ // Predicate
+ template
+ ETL_NODISCARD
+ TIterator1 find_end(TIterator1 b, TIterator1 e,
+ TIterator2 sb, TIterator2 se,
+ TPredicate predicate)
+ {
+ return std::find_end(b, e, sb, se, predicate);
+ }
+
+ // Default
+ template
+ ETL_NODISCARD
+ TIterator1 find_end(TIterator1 b, TIterator1 e,
+ TIterator2 sb, TIterator2 se)
+ {
+ return std::find_end(b, e, sb, se);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
/// Finds the greatest and the smallest element in the range (begin, end).
///
///\ingroup algorithm
//***************************************************************************
- template
- ETL_PAIR minmax_element(TIterator begin,
- TIterator end,
- TCompare compare)
+ template
+ ETL_NODISCARD
+ ETL_OR_STD::pair minmax_element(TIterator begin,
+ TIterator end,
+ TCompare compare)
{
TIterator minimum = begin;
TIterator maximum = begin;
@@ -79,7 +1344,7 @@ namespace etl
++begin;
}
- return ETL_PAIR(minimum, maximum);
+ return ETL_OR_STD::pair(minimum, maximum);
}
//***************************************************************************
@@ -88,24 +1353,56 @@ namespace etl
///
//***************************************************************************
template
- ETL_PAIR minmax_element(TIterator begin,
- TIterator end)
+ ETL_NODISCARD
+ ETL_OR_STD::pair minmax_element(TIterator begin,
+ TIterator end)
{
- typedef typename ETL_STD::iterator_traits::value_type value_t;
+ typedef typename etl::iterator_traits::value_type value_t;
- return etl::minmax_element(begin, end, ETL_STD::less());
+ return etl::minmax_element(begin, end, etl::less());
+ }
+#else
+ //***************************************************************************
+/// Finds the greatest and the smallest element in the range (begin, end).
+///
+///\ingroup algorithm
+//***************************************************************************
+ template
+ ETL_NODISCARD
+ std::pair minmax_element(TIterator begin,
+ TIterator end,
+ TCompare compare)
+ {
+ return std::minmax_element(begin, end, compare);
}
+
+ //***************************************************************************
+ /// minmax_element
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ std::pair minmax_element(TIterator begin,
+ TIterator end)
+ {
+ return std::minmax_element(begin, end);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
/// minmax
///\ingroup algorithm
///
//***************************************************************************
template
- ETL_PAIR minmax(const T& a,
- const T& b)
+ ETL_NODISCARD
+ ETL_OR_STD::pair minmax(const T& a,
+ const T& b)
{
- return (b < a) ? ETL_PAIR(b, a) : ETL_PAIR(a, b);
+ return (b < a) ? ETL_OR_STD::pair(b, a) : ETL_OR_STD::pair(a, b);
}
//***************************************************************************
@@ -113,21 +1410,51 @@ namespace etl
///\ingroup algorithm
///
//***************************************************************************
- template
- ETL_PAIR minmax(const T& a,
- const T& b,
- TCompare compare)
+ template
+ ETL_NODISCARD
+ ETL_OR_STD::pair minmax(const T& a,
+ const T& b,
+ TCompare compare)
{
- return compare(b, a) ? ETL_PAIR(b, a) : ETL_PAIR(a, b);
+ return compare(b, a) ? ETL_OR_STD::pair(b, a) : ETL_OR_STD::pair(a, b);
+ }
+#else
+ //***************************************************************************
+ /// minmax
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ std::pair minmax(const T& a,
+ const T& b)
+ {
+ return std::minmax(a, b);
}
+ //***************************************************************************
+ /// minmax
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ std::pair minmax(const T& a,
+ const T& b,
+ TCompare compare)
+ {
+ return std::minmax(a, b, compare);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
/// is_sorted_until
///\ingroup algorithm
///
//***************************************************************************
template
+ ETL_NODISCARD
TIterator is_sorted_until(TIterator begin,
TIterator end)
{
@@ -154,8 +1481,8 @@ namespace etl
///\ingroup algorithm
///
//***************************************************************************
- template
+ template
+ ETL_NODISCARD
TIterator is_sorted_until(TIterator begin,
TIterator end,
TCompare compare)
@@ -177,13 +1504,43 @@ namespace etl
return end;
}
+#else
+ //***************************************************************************
+ /// is_sorted_until
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ TIterator is_sorted_until(TIterator begin,
+ TIterator end)
+ {
+ return std::is_sorted_until(begin, end);
+ }
+ //***************************************************************************
+ /// is_sorted_until
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ TIterator is_sorted_until(TIterator begin,
+ TIterator end,
+ TCompare compare)
+ {
+ return std::is_sorted_until(begin, end, compare);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
/// is_sorted
///\ingroup algorithm
///
//***************************************************************************
template
+ ETL_NODISCARD
bool is_sorted(TIterator begin,
TIterator end)
{
@@ -195,158 +1552,416 @@ namespace etl
///\ingroup algorithm
///
//***************************************************************************
- template
+ template
+ ETL_NODISCARD
bool is_sorted(TIterator begin,
TIterator end,
TCompare compare)
{
return etl::is_sorted_until(begin, end, compare) == end;
}
-
+#else
//***************************************************************************
- /// copy
- /// A form of copy where the smallest of the two ranges is used.
- /// There is currently no STL equivalent.
- /// Specialisation for random access iterators.
- ///\param i_begin Beginning of the input range.
- ///\param i_end End of the input range.
- ///\param o_begin Beginning of the output range.
- ///\param o_end End of the output range.
+ /// is_sorted
///\ingroup algorithm
+ ///
//***************************************************************************
- template
- typename etl::enable_if::value &&
- etl::is_random_iterator::value, TOutputIterator>::type
- copy(TInputIterator i_begin,
- TInputIterator i_end,
- TOutputIterator o_begin,
- TOutputIterator o_end)
+ template
+ ETL_NODISCARD
+ bool is_sorted(TIterator begin,
+ TIterator end)
{
- size_t s_size = ETL_STD::distance(i_begin, i_end);
- size_t d_size = ETL_STD::distance(o_begin, o_end);
- size_t size = (s_size < d_size) ? s_size : d_size;
-
- return ETL_STD::copy(i_begin, i_begin + size, o_begin);
+ return std::is_sorted(begin, end);
}
//***************************************************************************
- /// copy
- /// A form of copy where the smallest of the two ranges is used.
- /// There is currently no STL equivalent.
- /// Specialisation for non random access iterators.
- ///\param i_begin Beginning of the input range.
- ///\param i_end End of the input range.
- ///\param o_begin Beginning of the output range.
- ///\param o_end End of the output range.
+ /// is_sorted
///\ingroup algorithm
+ ///
//***************************************************************************
- template
- typename etl::enable_if::value ||
- !etl::is_random_iterator::value, TOutputIterator>::type
- copy(TInputIterator i_begin,
- TInputIterator i_end,
- TOutputIterator o_begin,
- TOutputIterator o_end)
+ template
+ ETL_NODISCARD
+ bool is_sorted(TIterator begin,
+ TIterator end,
+ TCompare compare)
{
- while ((i_begin != i_end) && (o_begin != o_end))
+ return std::is_sorted(begin, end, compare);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// find_if_not
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ TIterator find_if_not(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ while (begin != end)
{
- *o_begin++ = *i_begin++;
+ if (!predicate(*begin))
+ {
+ return begin;
+ }
+
+ ++begin;
}
- return o_begin;
+ return end;
}
-
+#else
//***************************************************************************
- /// copy_n (Random input iterators)
+ /// find_if_not
///\ingroup algorithm
- ///
+ ///
//***************************************************************************
- template
- typename etl::enable_if::value, TOutputIterator>::type
- copy_n(TInputIterator i_begin,
- TSize n,
- TOutputIterator o_begin)
+ template
+ ETL_NODISCARD
+ TIterator find_if_not(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
{
- return ETL_STD::copy(i_begin, i_begin + n, o_begin);
+ return std::find_if_not(begin, end, predicate);
}
+#endif
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
- /// copy_n (Non-random input iterators)
+ /// is_permutation
///\ingroup algorithm
- ///
+ ///
//***************************************************************************
- template
- typename etl::enable_if::value, TOutputIterator>::type
- copy_n(TInputIterator i_begin,
- TSize n,
- TOutputIterator o_begin)
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2)
{
- while (n-- > 0)
+ if (begin1 != end1)
{
- *o_begin++ = *i_begin++;
+ TIterator2 end2 = begin2;
+
+ etl::advance(end2, etl::distance(begin1, end1));
+
+ for (TIterator1 i = begin1; i != end1; ++i)
+ {
+ if (i == etl::find(begin1, i, *i))
+ {
+ size_t n = etl::count(begin2, end2, *i);
+
+ if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
+ {
+ return false;
+ }
+ }
+ }
}
- return o_begin;
+ return true;
}
//***************************************************************************
- /// copy_n
- /// A form of copy_n where the smallest of the two ranges is used.
+ /// is_permutation
///\ingroup algorithm
+ ///
//***************************************************************************
- template
- TOutputIterator copy_n(TInputIterator i_begin,
- TSize n,
- TOutputIterator o_begin,
- TOutputIterator o_end)
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TBinaryPredicate predicate)
{
- while ((n-- > 0) && (o_begin != o_end))
+ if (begin1 != end1)
{
- *o_begin++ = *i_begin++;
+ TIterator2 end2 = begin2;
+
+ etl::advance(end2, etl::distance(begin1, end1));
+
+ for (TIterator1 i = begin1; i != end1; ++i)
+ {
+ if (i == etl::find_if(begin1, i, etl::bind1st(predicate, *i)))
+ {
+ size_t n = etl::count(begin2, end2, *i);
+
+ if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
+ {
+ return false;
+ }
+ }
+ }
}
- return o_begin;
+ return true;
}
//***************************************************************************
- /// copy_n
- /// A form of copy_n where the smallest of the two ranges is used.
+ /// is_permutation
///\ingroup algorithm
+ ///
//***************************************************************************
- template
- TOutputIterator copy_n(TInputIterator i_begin,
- TSize1 n1,
- TOutputIterator o_begin,
- TSize2 n2)
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TIterator2 end2)
{
- while ((n1-- > 0) && (n2-- > 0))
+ if (begin1 != end1)
{
- *o_begin++ = *i_begin++;
+ for (TIterator1 i = begin1; i != end1; ++i)
+ {
+ if (i == etl::find(begin1, i, *i))
+ {
+ size_t n = etl::count(begin2, end2, *i);
+
+ if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
+ {
+ return false;
+ }
+ }
+ }
}
- return o_begin;
+ return true;
}
+ //***************************************************************************
+ /// is_permutation
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TIterator2 end2,
+ TBinaryPredicate predicate)
+ {
+ if (begin1 != end1)
+ {
+ for (TIterator1 i = begin1; i != end1; ++i)
+ {
+ if (i == etl::find_if(begin1, i, etl::bind1st(predicate, *i)))
+ {
+ size_t n = etl::count(begin2, end2, *i);
+
+ if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+#else
+ //***************************************************************************
+ /// is_permutation
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2)
+ {
+ return std::is_permutation(begin1, end1, begin2);
+ }
+
+ //***************************************************************************
+ /// is_permutation
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TBinaryPredicate predicate)
+ {
+ return std::is_permutation(begin1, end1, begin2, predicate);
+ }
+
+ //***************************************************************************
+ /// is_permutation
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TIterator2 end2)
+ {
+ return std::is_permutation(begin1, end1, begin2, end2);
+ }
+
+ //***************************************************************************
+ /// is_permutation
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_permutation(TIterator1 begin1,
+ TIterator1 end1,
+ TIterator2 begin2,
+ TIterator2 end2,
+ TBinaryPredicate predicate)
+ {
+ return std::is_permutation(begin1, end1, begin2, end2, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// is_partitioned
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_partitioned(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ while (begin != end)
+ {
+ if (!predicate(*begin++))
+ {
+ break;
+ }
+ }
+
+ while (begin != end)
+ {
+ if (predicate(*begin++))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+#else
+ //***************************************************************************
+ /// is_partitioned
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool is_partitioned(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ return std::is_partitioned(begin, end, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// partition_point
+ ///
+ ///\ingroup algorithm
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ TIterator partition_point(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ while (begin != end)
+ {
+ if (!predicate(*begin))
+ {
+ return begin;
+ }
+
+ ++begin;
+ }
+
+ return begin;
+ }
+#else
+ //***************************************************************************
+ /// partition_point
+ ///
+ ///\ingroup algorithm
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ TIterator partition_point(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ return std::partition_point(begin, end, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// Copies the elements from the range (begin, end) to two different ranges
+ /// depending on the value returned by the predicate.
+ ///
+ ///\ingroup algorithm
+ //***************************************************************************
+ template
+ ETL_OR_STD::pair partition_copy(TSource begin,
+ TSource end,
+ TDestinationTrue destination_true,
+ TDestinationFalse destination_false,
+ TUnaryPredicate predicate)
+ {
+ while (begin != end)
+ {
+ if (predicate(*begin))
+ {
+ *destination_true++ = *begin++;
+ }
+ else
+ {
+ *destination_false++ = *begin++;
+ }
+ }
+
+ return ETL_OR_STD::pair(destination_true, destination_false);
+ }
+#else
+ //***************************************************************************
+ /// Copies the elements from the range (begin, end) to two different ranges
+ /// depending on the value returned by the predicate.
+ ///
+ ///\ingroup algorithm
+ //***************************************************************************
+ template
+ std::pair partition_copy(TSource begin,
+ TSource end,
+ TDestinationTrue destination_true,
+ TDestinationFalse destination_false,
+ TUnaryPredicate predicate)
+ {
+ return std::partition_copy(begin, end, destination_true, destination_false, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
//***************************************************************************
/// copy_if
///\ingroup algorithm
///
//***************************************************************************
- template
+ template
TOutputIterator copy_if(TIterator begin,
TIterator end,
TOutputIterator out,
@@ -364,21 +1979,230 @@ namespace etl
return out;
}
+#else
+ //***************************************************************************
+ /// copy_if
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ TOutputIterator copy_if(TIterator begin,
+ TIterator end,
+ TOutputIterator out,
+ TUnaryPredicate predicate)
+ {
+ return std::copy_if(begin, end, out, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// all_of
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool all_of(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ return etl::find_if_not(begin, end, predicate) == end;
+ }
+#else
+ //***************************************************************************
+ /// all_of
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool all_of(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ return std::all_of(begin, end, predicate);
+ }
+#endif
+
+#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
+ //***************************************************************************
+ /// any_of
+ ///\ingroup algorithm
+ ///
+ //***************************************************************************
+ template
+ ETL_NODISCARD
+ bool any_of(TIterator begin,
+ TIterator end,
+ TUnaryPredicate predicate)
+ {
+ return etl::find_if(begin, end, predicate) != end;
+ }
+#else
+ //***************************************************************************
+ /// any_of
+ ///\ingroup algorithm
+ ///