Skip to content

Commit f3c6a31

Browse files
author
John Wellbelove
committed
Sync to 20.38.10
1 parent 241e140 commit f3c6a31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2053
-211
lines changed

Diff for: library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Embedded Template Library - ETL",
2+
"name": "Embedded Template Library - Arduino",
33
"version": "20.38.10",
44
"authors": {
55
"name": "John Wellbelove",

Diff for: library.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name=Embedded Template Library ETL
2-
version=20.38.2
1+
name=Embedded Template Library - Arduino
2+
version=20.38.10
33
author= John Wellbelove <[email protected]>
44
maintainer=John Wellbelove <[email protected]>
55
license=MIT

Diff for: src/etl/algorithm.h

+45-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,37 @@ namespace etl
8888
//*****************************************************************************
8989
namespace etl
9090
{
91+
namespace private_algorithm
92+
{
93+
template <bool use_swap>
94+
struct swap_impl;
95+
96+
// Generic swap
97+
template <>
98+
struct swap_impl<false>
99+
{
100+
template <typename TIterator1, typename TIterator2>
101+
static void do_swap(TIterator1 a, TIterator2 b)
102+
{
103+
typename etl::iterator_traits<TIterator1>::value_type tmp = *a;
104+
*a = *b;
105+
*b = tmp;
106+
}
107+
};
108+
109+
// Specialised swap
110+
template <>
111+
struct swap_impl<true>
112+
{
113+
template <typename TIterator1, typename TIterator2>
114+
static void do_swap(TIterator1 a, TIterator2 b)
115+
{
116+
using ETL_OR_STD::swap; // Allow ADL
117+
swap(*a, *b);
118+
}
119+
};
120+
}
121+
91122
//***************************************************************************
92123
// iter_swap
93124
//***************************************************************************
@@ -99,8 +130,20 @@ namespace etl
99130
#endif
100131
void iter_swap(TIterator1 a, TIterator2 b)
101132
{
102-
using ETL_OR_STD::swap; // Allow ADL
103-
swap(*a, *b);
133+
typedef etl::iterator_traits<TIterator1> traits1;
134+
typedef etl::iterator_traits<TIterator2> traits2;
135+
136+
typedef typename traits1::value_type v1;
137+
typedef typename traits2::value_type v2;
138+
139+
typedef typename traits1::reference r1;
140+
typedef typename traits2::reference r2;
141+
142+
const bool use_swap = etl::is_same<v1, v2>::value &&
143+
etl::is_reference<r1>::value &&
144+
etl::is_reference<r2>::value;
145+
146+
private_algorithm::swap_impl<use_swap>::do_swap(a, b);
104147
}
105148

106149
//***************************************************************************

Diff for: src/etl/alignment.h

+16-6
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ namespace etl
7676
//*****************************************************************************
7777
inline bool is_aligned(void* p, size_t required_alignment)
7878
{
79-
uintptr_t alignment = static_cast<uintptr_t>(required_alignment);
8079
uintptr_t address = reinterpret_cast<uintptr_t>(p);
81-
return (address % alignment) == 0U;
80+
return (address % required_alignment) == 0U;
8281
}
8382

8483
//*****************************************************************************
@@ -88,7 +87,7 @@ namespace etl
8887
bool is_aligned(void* p)
8988
{
9089
uintptr_t address = reinterpret_cast<uintptr_t>(p);
91-
return (address % static_cast<uintptr_t>(Alignment)) == 0U;
90+
return (address % Alignment) == 0U;
9291
}
9392

9493
//*****************************************************************************
@@ -204,13 +203,24 @@ namespace etl
204203
{
205204
public:
206205

207-
#if ETL_NOT_USING_64BIT_TYPES
208-
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
206+
#if ETL_USING_CPP11
207+
typedef struct { alignas(Alignment) char dummy; } type;
209208
#else
210-
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
209+
#if ETL_NOT_USING_64BIT_TYPES
210+
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
211+
#else
212+
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
213+
#endif
211214
#endif
215+
216+
ETL_STATIC_ASSERT(etl::alignment_of<type>::value == Alignment, "Unable to create the type with the specified alignment");
212217
};
213218

219+
#if ETL_USING_CPP11
220+
template <size_t Alignment>
221+
using type_with_alignment_t = typename type_with_alignment<Alignment>::type;
222+
#endif
223+
214224
//***************************************************************************
215225
/// Aligned storage
216226
/// Length should be determined in terms of sizeof()

Diff for: src/etl/array_view.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -421,23 +421,23 @@ namespace etl
421421
//*************************************************************************
422422
/// Returns <b>true</b> if the array size is zero.
423423
//*************************************************************************
424-
bool empty() const
424+
ETL_CONSTEXPR bool empty() const
425425
{
426426
return (mbegin == mend);
427427
}
428428

429429
//*************************************************************************
430430
/// Returns the size of the array.
431431
//*************************************************************************
432-
size_t size() const
432+
ETL_CONSTEXPR size_t size() const
433433
{
434-
return (mend - mbegin);
434+
return static_cast<size_t>(mend - mbegin);
435435
}
436436

437437
//*************************************************************************
438438
/// Returns the maximum possible size of the array.
439439
//*************************************************************************
440-
size_t max_size() const
440+
ETL_CONSTEXPR size_t max_size() const
441441
{
442442
return size();
443443
}

0 commit comments

Comments
 (0)