Skip to content

Commit f12b966

Browse files
author
John Wellbelove
committed
Sync to 20.38.2
1 parent 9aa616a commit f12b966

File tree

117 files changed

+4494
-1985
lines changed

Some content is hidden

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

117 files changed

+4494
-1985
lines changed

Diff for: library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Embedded Template Library - Arduino",
3-
"version": "20.36.0",
3+
"version": "20.38.2",
44
"authors": {
55
"name": "John Wellbelove",
66
"email": "[email protected]"

Diff for: library.properties

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

Diff for: src/Embedded_Template_Library.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@
7777
#endif
7878
#endif
7979

80-
#endif
80+
#endif

Diff for: src/etl/algorithm.h

+43-9
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ namespace etl
229229
{
230230
return std::move(sb, se, db);
231231
}
232-
#else
233-
// non-pointer or not trivially copyable
232+
#elif ETL_USING_CPP11
233+
// For C++11
234234
template <typename TIterator1, typename TIterator2>
235235
ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
236236
{
@@ -243,19 +243,25 @@ namespace etl
243243

244244
return db;
245245
}
246+
#else
247+
// For C++03
248+
template <typename TIterator1, typename TIterator2>
249+
ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
250+
{
251+
return copy(sb, se, db);
252+
}
246253
#endif
247254

248255
//***************************************************************************
249256
// move_backward
250257
#if ETL_USING_STL && ETL_USING_CPP20
251258
template <typename TIterator1, typename TIterator2>
252-
ETL_CONSTEXPR20
253-
TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
259+
ETL_CONSTEXPR20 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
254260
{
255261
return std::move_backward(sb, se, de);
256262
}
257-
#else
258-
// non-pointer or not trivially copyable
263+
#elif ETL_USING_CPP11
264+
// For C++11
259265
template <typename TIterator1, typename TIterator2>
260266
ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
261267
{
@@ -266,6 +272,13 @@ namespace etl
266272

267273
return de;
268274
}
275+
#else
276+
// For C++03
277+
template <typename TIterator1, typename TIterator2>
278+
ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
279+
{
280+
return etl::copy_backward(sb, se, de);
281+
}
269282
#endif
270283

271284
//***************************************************************************
@@ -560,6 +573,7 @@ namespace etl
560573
//***************************************************************************
561574
// equal
562575
#if ETL_USING_STL && ETL_USING_CPP20
576+
// Three parameter
563577
template <typename TIterator1, typename TIterator2>
564578
[[nodiscard]]
565579
constexpr
@@ -568,15 +582,35 @@ namespace etl
568582
return std::equal(first1, last1, first2);
569583
}
570584

585+
// Three parameter + predicate
571586
template <typename TIterator1, typename TIterator2, typename TPredicate>
572587
[[nodiscard]]
573588
constexpr
574589
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
575590
{
576591
return std::equal(first1, last1, first2, predicate);
577592
}
593+
594+
// Four parameter
595+
template <typename TIterator1, typename TIterator2>
596+
[[nodiscard]]
597+
constexpr
598+
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
599+
{
600+
return std::equal(first1, last1, first2, last2);
601+
}
602+
603+
// Four parameter + Predicate
604+
template <typename TIterator1, typename TIterator2, typename TPredicate>
605+
[[nodiscard]]
606+
constexpr
607+
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
608+
{
609+
return std::equal(first1, last1, first2, last2, predicate);
610+
}
611+
578612
#else
579-
// Not pointer types or not trivially copyable.
613+
580614
template <typename TIterator1, typename TIterator2>
581615
ETL_NODISCARD
582616
ETL_CONSTEXPR14
@@ -639,8 +673,8 @@ namespace etl
639673
// Four parameter, Predicate
640674
template <typename TIterator1, typename TIterator2, typename TPredicate>
641675
ETL_NODISCARD
642-
ETL_CONSTEXPR14
643-
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
676+
ETL_CONSTEXPR14
677+
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
644678
{
645679
while ((first1 != last1) && (first2 != last2))
646680
{

Diff for: src/etl/alignment.h

+79-33
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,79 @@ namespace etl
102102

103103
namespace private_alignment
104104
{
105+
#if ETL_USING_CPP11
105106
//***************************************************************************
106107
// Matcher.
107108
//***************************************************************************
108-
template <bool IS_MATCH, const size_t ALIGNMENT, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
109+
template <bool Is_Match, size_t Alignment, typename... TRest>
110+
class type_with_alignment_matcher;
111+
112+
// Matching alignment.
113+
template <size_t Alignment, typename T1, typename... TRest>
114+
class type_with_alignment_matcher<true, Alignment, T1, TRest...>
115+
{
116+
public:
117+
118+
typedef T1 type;
119+
};
120+
121+
// Non-matching alignment
122+
template <size_t Alignment, typename T1, typename T2, typename... TRest>
123+
class type_with_alignment_matcher <false, Alignment, T1, T2, TRest...>
124+
{
125+
public:
126+
127+
typedef typename type_with_alignment_matcher < Alignment <= etl::alignment_of<T2>::value , Alignment, T2, TRest... > ::type type;
128+
};
129+
130+
// Non-matching alignment, none left.
131+
template <size_t Alignment, typename T1>
132+
class type_with_alignment_matcher <false, Alignment, T1>
133+
{
134+
public:
135+
136+
typedef char type;
137+
};
138+
139+
//***************************************************************************
140+
// Helper.
141+
//***************************************************************************
142+
template <size_t Alignment, typename T1, typename... T>
143+
class type_with_alignment_helper
144+
{
145+
public:
146+
147+
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T...>::type type;
148+
};
149+
#else
150+
//***************************************************************************
151+
// Matcher.
152+
//***************************************************************************
153+
template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
109154
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
110155
class type_with_alignment_matcher;
111156

112157
// Matching alignment.
113-
template <size_t ALIGNMENT, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
114-
class type_with_alignment_matcher <true, ALIGNMENT, T1, T2, T3, T4, T5, T6, T7, T8>
158+
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
159+
class type_with_alignment_matcher <true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
115160
{
116161
public:
117162

118163
typedef T1 type;
119164
};
120165

121166
// Non-matching alignment.
122-
template <size_t ALIGNMENT, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
123-
class type_with_alignment_matcher <false, ALIGNMENT, T1, T2, T3, T4, T5, T6, T7, T8>
167+
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
168+
class type_with_alignment_matcher <false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
124169
{
125170
public:
126171

127-
typedef typename type_with_alignment_matcher<ALIGNMENT <= etl::alignment_of<T2>::value, ALIGNMENT, T2, T3, T4, T5, T6, T7, T8, void>::type type;
172+
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
128173
};
129174

130175
// Non-matching alignment, none left.
131-
template <size_t ALIGNMENT>
132-
class type_with_alignment_matcher <false, ALIGNMENT, void, void, void, void, void, void, void, void>
176+
template <size_t Alignment>
177+
class type_with_alignment_matcher <false, Alignment, void, void, void, void, void, void, void, void>
133178
{
134179
public:
135180

@@ -139,38 +184,39 @@ namespace etl
139184
//***************************************************************************
140185
// Helper.
141186
//***************************************************************************
142-
template <size_t ALIGNMENT, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
143-
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
187+
template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
188+
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
144189
class type_with_alignment_helper
145190
{
146191
public:
147192

148-
typedef typename type_with_alignment_matcher<ALIGNMENT <= etl::alignment_of<T1>::value, ALIGNMENT, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
193+
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
149194
};
195+
#endif
150196
}
151197

152198
//***************************************************************************
153199
/// Gets a type that has the same as the specified alignment.
154200
///\ingroup alignment
155201
//***************************************************************************
156-
template <size_t ALIGNMENT>
202+
template <size_t Alignment>
157203
class type_with_alignment
158204
{
159205
public:
160206

161207
#if ETL_NOT_USING_64BIT_TYPES
162-
typedef typename private_alignment::type_with_alignment_helper<ALIGNMENT, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
208+
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
163209
#else
164-
typedef typename private_alignment::type_with_alignment_helper<ALIGNMENT, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
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;
165211
#endif
166212
};
167213

168214
//***************************************************************************
169215
/// Aligned storage
170-
/// LENGTH should be determined in terms of sizeof()
216+
/// Length should be determined in terms of sizeof()
171217
///\ingroup alignment
172218
//***************************************************************************
173-
template <size_t LENGTH, const size_t ALIGNMENT>
219+
template <size_t Length, const size_t Alignment>
174220
struct aligned_storage
175221
{
176222
struct type
@@ -184,7 +230,7 @@ namespace etl
184230
template <typename T>
185231
operator T& ()
186232
{
187-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
233+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
188234
T* t = *this;
189235
return *t;
190236
}
@@ -193,7 +239,7 @@ namespace etl
193239
template <typename T>
194240
operator const T& () const
195241
{
196-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
242+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
197243
const T* t = *this;
198244
return *t;
199245
}
@@ -202,23 +248,23 @@ namespace etl
202248
template <typename T>
203249
operator T* ()
204250
{
205-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
251+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
206252
return reinterpret_cast<T*>(data);
207253
}
208254

209255
/// Convert to const T pointer.
210256
template <typename T>
211257
operator const T* () const
212258
{
213-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
259+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
214260
return reinterpret_cast<const T*>(data);
215261
}
216262

217263
/// Get address as T reference.
218264
template <typename T>
219265
T& get_reference()
220266
{
221-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
267+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
222268
T* t = *this;
223269
return *t;
224270
}
@@ -227,7 +273,7 @@ namespace etl
227273
template <typename T>
228274
const T& get_reference() const
229275
{
230-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
276+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
231277
const T* t = *this;
232278
return *t;
233279
}
@@ -236,47 +282,47 @@ namespace etl
236282
template <typename T>
237283
T* get_address()
238284
{
239-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
285+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
240286
return reinterpret_cast<T*>(data);
241287
}
242288

243289
/// Get address as const T pointer.
244290
template <typename T>
245291
const T* get_address() const
246292
{
247-
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((ALIGNMENT % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
293+
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
248294
return reinterpret_cast<const T*>(data);
249295
}
250296

251297
#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
252-
alignas(ALIGNMENT) char data[LENGTH];
298+
alignas(Alignment) char data[Length];
253299
#else
254300
union
255301
{
256-
char data[LENGTH];
257-
typename etl::type_with_alignment<ALIGNMENT>::type etl_alignment_type; // A POD type that has the same alignment as ALIGNMENT.
302+
char data[Length];
303+
typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment as Alignment.
258304
};
259305
#endif
260306
};
261307
};
262308

263309
#if ETL_USING_CPP11
264-
template <size_t LENGTH, const size_t ALIGNMENT>
265-
using aligned_storage_t = typename aligned_storage<LENGTH, ALIGNMENT>::type;
310+
template <size_t Length, const size_t Alignment>
311+
using aligned_storage_t = typename aligned_storage<Length, Alignment>::type;
266312
#endif
267313

268314
//***************************************************************************
269315
/// Aligned storage as
270316
///\ingroup alignment
271317
//***************************************************************************
272-
template <size_t LENGTH, typename T>
273-
struct aligned_storage_as : public etl::aligned_storage<LENGTH, etl::alignment_of<T>::value>
318+
template <size_t Length, typename T>
319+
struct aligned_storage_as : public etl::aligned_storage<Length, etl::alignment_of<T>::value>
274320
{
275321
};
276322

277323
#if ETL_USING_CPP11
278-
template <size_t LENGTH, typename T>
279-
using aligned_storage_as_t = typename aligned_storage_as<LENGTH, T>::type;
324+
template <size_t Length, typename T>
325+
using aligned_storage_as_t = typename aligned_storage_as<Length, T>::type;
280326
#endif
281327
}
282328

0 commit comments

Comments
 (0)