Skip to content

Commit 88d0881

Browse files
committed
Sync to 20.35.5
1 parent a41f53f commit 88d0881

File tree

151 files changed

+10732
-2514
lines changed

Some content is hidden

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

151 files changed

+10732
-2514
lines changed

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.32.1",
3+
"version": "20.35.5",
44
"authors": {
55
"name": "John Wellbelove",
66
"email": "[email protected]"

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.32.1
2+
version=20.35.5
33
author= John Wellbelove <[email protected]>
44
maintainer=John Wellbelove <[email protected]>
55
license=MIT

src/etl/absolute.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ namespace etl
6868
ETL_CONSTEXPR typename etl::enable_if<etl::is_signed<T>::value, TReturn>::type
6969
absolute_unsigned(T value)
7070
{
71-
return (value == etl::integral_limits<T>::min) ? etl::integral_limits<TReturn>::max / 2U
72-
: (value < T(0)) ? TReturn(-value) : TReturn(value);
71+
return (value == etl::integral_limits<T>::min) ? (etl::integral_limits<TReturn>::max / 2U) + 1U
72+
: (value < T(0)) ? TReturn(-value) : TReturn(value);
7373
}
7474

7575
//***************************************************************************

src/etl/algorithm.h

+24-22
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ SOFTWARE.
3838
/// Additional new variants of certain algorithms.
3939
///\ingroup utilities
4040

41-
#include <stdint.h>
42-
#include <string.h>
43-
4441
#include "platform.h"
4542
#include "type_traits.h"
4643
#include "iterator.h"
4744
#include "functional.h"
4845
#include "utility.h"
4946

47+
#include <stdint.h>
48+
#include <string.h>
49+
5050
#include "private/minmax_push.h"
5151

5252
#if ETL_USING_STL
@@ -183,13 +183,6 @@ namespace etl
183183
{
184184
return std::copy_n(sb, count, db);
185185
}
186-
#elif ETL_USING_STL && ETL_USING_CPP11 && !ETL_FORCE_CONSTEXPR_ALGORITHMS
187-
// Use the STL implementation
188-
template <typename TIterator1, typename TSize, typename TIterator2>
189-
TIterator2 copy_n(TIterator1 sb, TSize count, TIterator2 db)
190-
{
191-
return std::copy_n(sb, count, db);
192-
}
193186
#else
194187
// Non-pointer or not trivially copyable or not using builtin memcpy.
195188
template <typename TIterator1, typename TSize, typename TIterator2>
@@ -236,12 +229,6 @@ namespace etl
236229
{
237230
return std::move(sb, se, db);
238231
}
239-
#elif ETL_USING_STL && ETL_USING_CPP11 && !ETL_FORCE_CONSTEXPR_ALGORITHMS
240-
template <typename TIterator1, typename TIterator2>
241-
TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
242-
{
243-
return std::move(sb, se, db);
244-
}
245232
#else
246233
// non-pointer or not trivially copyable
247234
template <typename TIterator1, typename TIterator2>
@@ -267,12 +254,6 @@ namespace etl
267254
{
268255
return std::move_backward(sb, se, de);
269256
}
270-
#elif ETL_USING_STL && ETL_USING_CPP11 && !ETL_FORCE_CONSTEXPR_ALGORITHMS
271-
template <typename TIterator1, typename TIterator2>
272-
TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
273-
{
274-
return std::move_backward(sb, se, de);
275-
}
276257
#else
277258
// non-pointer or not trivially copyable
278259
template <typename TIterator1, typename TIterator2>
@@ -424,6 +405,27 @@ namespace etl
424405
etl::upper_bound(first, last, value, compare()));
425406
}
426407

408+
//***************************************************************************
409+
// binary_search
410+
//***************************************************************************
411+
template <typename TIterator, typename T, typename Compare>
412+
ETL_NODISCARD
413+
bool binary_search(TIterator first, TIterator last, const T& value, Compare compare)
414+
{
415+
first = etl::lower_bound(first, last, value, compare);
416+
417+
return (!(first == last) && !(compare(value, *first)));
418+
}
419+
420+
template <typename TIterator, typename T>
421+
ETL_NODISCARD
422+
bool binary_search(TIterator first, TIterator last, const T& value)
423+
{
424+
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
425+
426+
return binary_search(first, last, value, compare());
427+
}
428+
427429
//***************************************************************************
428430
// find_if
429431
//***************************************************************************

src/etl/alignment.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ SOFTWARE.
3131
#ifndef ETL_ALIGNMENT_INCLUDED
3232
#define ETL_ALIGNMENT_INCLUDED
3333

34-
#include <stdint.h>
35-
3634
#include "platform.h"
3735
#include "type_traits.h"
3836
#include "static_assert.h"
3937

38+
#include <stdint.h>
39+
4040
///\defgroup alignment alignment
4141
/// Creates a variable of the specified type at the specified alignment.
4242
/// \ingroup utilities

src/etl/array.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ SOFTWARE.
3131
#ifndef ETL_ARRAY_INCLUDED
3232
#define ETL_ARRAY_INCLUDED
3333

34-
#include <stddef.h>
35-
3634
#include "platform.h"
37-
3835
#include "algorithm.h"
3936
#include "iterator.h"
4037
#include "functional.h"
@@ -46,6 +43,8 @@ SOFTWARE.
4643
#include "nth_type.h"
4744
#include "initializer_list.h"
4845

46+
#include <stddef.h>
47+
4948
///\defgroup array array
5049
/// A replacement for std::array if you haven't got C++0x11.
5150
///\ingroup containers

src/etl/array_view.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ SOFTWARE.
4040
#include "nullptr.h"
4141
#include "hash.h"
4242
#include "algorithm.h"
43-
#include "memory.h"
4443
#include "type_traits.h"
4544

46-
#if ETL_USING_CPP11 && ETL_USING_STL
45+
#if ETL_USING_STL && ETL_USING_CPP11
4746
#include <array>
4847
#endif
4948

@@ -155,7 +154,7 @@ namespace etl
155154
/// Construct from etl::array.
156155
//*************************************************************************
157156
template <typename U, size_t N>
158-
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
157+
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
159158
: mbegin(a.data())
160159
, mend(a.data() + a.size())
161160
{
@@ -165,14 +164,14 @@ namespace etl
165164
/// Construct from etl::array.
166165
//*************************************************************************
167166
template <typename U, size_t N>
168-
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
167+
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
169168
: mbegin(a.data())
170169
, mend(a.data() + a.size())
171170
{
172171
}
173172
#endif
174173

175-
#if ETL_USING_CPP11 && ETL_USING_STL
174+
#if ETL_USING_STL && ETL_USING_CPP11
176175
//*************************************************************************
177176
/// Construct from std::array.
178177
//*************************************************************************
@@ -215,7 +214,7 @@ namespace etl
215214
template <typename TContainer>
216215
ETL_CONSTEXPR array_view(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
217216
!etl::is_array<TContainer>::value &&
218-
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
217+
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
219218
: mbegin(a.data())
220219
, mend(a.data() + a.size())
221220
{
@@ -228,7 +227,7 @@ namespace etl
228227
template <typename TContainer>
229228
ETL_CONSTEXPR array_view(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
230229
!etl::is_array<TContainer>::value &&
231-
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
230+
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
232231
: mbegin(a.data())
233232
, mend(a.data() + a.size())
234233
{

src/etl/atomic/atomic_gcc_sync.h

+14
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ SOFTWARE.
3939
#include <stdint.h>
4040
#include <string.h>
4141

42+
// Select the amtomic builtins based on the ARM5 version of the GCC compiler.
43+
#if defined(ETL_COMPILER_ARM5)
44+
#define ETL_USE_SYNC_BUILTINS
45+
#endif
46+
47+
// Select the amtomic builtins based on the ARM6 version of the GCC compiler.
48+
#if defined(ETL_COMPILER_ARM6)
49+
#if ETL_COMPILER_FULL_VERSION >= 40700
50+
#define ETL_USE_ATOMIC_BUILTINS
51+
#else
52+
#define ETL_USE_SYNC_BUILTINS
53+
#endif
54+
#endif
55+
4256
// Select the amtomic builtins based on the version of the GCC compiler.
4357
#if defined(ETL_COMPILER_GCC)
4458
#if ETL_COMPILER_FULL_VERSION >= 40700

src/etl/basic_string.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ SOFTWARE.
3131
#ifndef ETL_BASIC_STRING_INCLUDED
3232
#define ETL_BASIC_STRING_INCLUDED
3333

34-
#include <stddef.h>
35-
#include <stdint.h>
36-
#include <string.h>
37-
3834
#include "platform.h"
39-
4035
#include "algorithm.h"
4136
#include "iterator.h"
4237
#include "functional.h"
@@ -53,6 +48,10 @@ SOFTWARE.
5348
#include "binary.h"
5449
#include "flags.h"
5550

51+
#include <stddef.h>
52+
#include <stdint.h>
53+
#include <string.h>
54+
5655
#include "private/minmax_push.h"
5756

5857
//*****************************************************************************

src/etl/binary.h

+37-2
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ namespace etl
441441
ETL_CONSTEXPR14 bool has_zero_byte(TValue value)
442442
{
443443
typedef typename etl::make_unsigned<TValue>::type unsigned_t;
444-
const unsigned_t mask = etl::binary_fill<unsigned_t, uint8_t>(0x7FU);
444+
ETL_CONSTEXPR14 const unsigned_t mask = etl::binary_fill<unsigned_t, uint8_t>(0x7FU);
445445
const unsigned_t temp = unsigned_t(~((((unsigned_t(value) & mask) + mask) | unsigned_t(value)) | mask));
446446

447447
return (temp != 0U);
@@ -455,7 +455,7 @@ namespace etl
455455
ETL_CONSTEXPR14 bool has_zero_byte()
456456
{
457457
typedef typename etl::make_unsigned<TValue>::type unsigned_t;
458-
const unsigned_t mask = etl::binary_fill<unsigned_t, uint8_t>(0x7FU);
458+
ETL_CONSTEXPR14 const unsigned_t mask = etl::binary_fill<unsigned_t, uint8_t>(0x7FU);
459459
const unsigned_t temp = unsigned_t(~((((unsigned_t(N) & mask) + mask) | unsigned_t(N)) | mask));
460460

461461
return (temp != 0U);
@@ -2181,6 +2181,41 @@ namespace etl
21812181
return ((static_cast<typename etl::make_unsigned<T>::type>(value) & 1U) == 0U);
21822182
}
21832183

2184+
//***********************************
2185+
template <typename T, size_t NBits>
2186+
class lsb_mask
2187+
{
2188+
public:
2189+
2190+
static ETL_CONSTANT T value = static_cast<T>(etl::max_value_for_nbits<NBits>::value);
2191+
};
2192+
2193+
//***********************************
2194+
template <typename T>
2195+
ETL_CONSTEXPR14 T make_lsb_mask(size_t nbits)
2196+
{
2197+
typedef typename etl::make_unsigned<T>::type type;
2198+
2199+
return (nbits == etl::integral_limits<type>::bits) ? static_cast<T>(etl::integral_limits<type>::max)
2200+
: static_cast<T>((static_cast<type>(1U) << nbits) - 1U);
2201+
};
2202+
2203+
//***********************************
2204+
template <typename T, size_t NBits>
2205+
class msb_mask
2206+
{
2207+
public:
2208+
2209+
static ETL_CONSTANT T value = static_cast<T>(etl::reverse_bits_const<T, lsb_mask<T, NBits>::value>::value);
2210+
};
2211+
2212+
//***********************************
2213+
template <typename T>
2214+
ETL_CONSTEXPR T make_msb_mask(size_t nbits)
2215+
{
2216+
return static_cast<T>(etl::reverse_bits(make_lsb_mask<T>(nbits)));
2217+
};
2218+
21842219
//***************************************************************************
21852220
/// 8 bit binary byte constants.
21862221
///\ingroup binary

src/etl/bip_buffer_spsc_atomic.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ SOFTWARE.
3838
#ifndef ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED
3939
#define ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED
4040

41-
#include <stddef.h>
42-
#include <stdint.h>
43-
4441
#include "platform.h"
4542
#include "alignment.h"
4643
#include "parameter_type.h"
@@ -53,6 +50,9 @@ SOFTWARE.
5350
#include "span.h"
5451
#include "file_error_numbers.h"
5552

53+
#include <stddef.h>
54+
#include <stdint.h>
55+
5656
#if ETL_HAS_ATOMIC
5757

5858
namespace etl

src/etl/bit.h

+21-7
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,30 @@ SOFTWARE.
3131
#ifndef ETL_BIT_INCLUDED
3232
#define ETL_BIT_INCLUDED
3333

34-
#include <string.h>
35-
3634
#include "platform.h"
3735
#include "type_traits.h"
3836
#include "binary.h"
3937
#include "integral_limits.h"
4038
#include "endianness.h"
4139
#include "type_traits.h"
4240

41+
#include <string.h>
42+
4343
#if ETL_USING_CPP20 && ETL_USING_STL
4444
#include <bit>
4545
#endif
4646

4747
namespace etl
4848
{
4949
//***************************************************************************
50-
/// bit_cast
50+
/// bit_cast - Type to different type.
5151
//***************************************************************************
5252
template <typename TDestination, typename TSource>
53-
ETL_CONSTEXPR14
54-
typename etl::enable_if<(sizeof(TDestination) == sizeof(TSource)) &&
55-
etl::is_trivially_copyable<TSource>::value &&
56-
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
53+
ETL_NODISCARD
54+
typename etl::enable_if<!(etl::is_integral<TDestination>::value&& etl::is_integral<TSource>::value) &&
55+
(sizeof(TDestination) == sizeof(TSource)) &&
56+
etl::is_trivially_copyable<TSource>::value &&
57+
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
5758
bit_cast(const TSource& source) ETL_NOEXCEPT
5859
{
5960
TDestination destination;
@@ -63,6 +64,19 @@ namespace etl
6364
return destination;
6465
}
6566

67+
//***************************************************************************
68+
/// bit_cast - Integral to integral
69+
//***************************************************************************
70+
template <typename TDestination, typename TSource>
71+
ETL_NODISCARD
72+
ETL_CONSTEXPR14
73+
typename etl::enable_if<(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) &&
74+
(sizeof(TDestination) == sizeof(TSource)), TDestination>::type
75+
bit_cast(const TSource& source) ETL_NOEXCEPT
76+
{
77+
return static_cast<TDestination>(source);
78+
}
79+
6680
//***************************************************************************
6781
/// byteswap
6882
//***************************************************************************

0 commit comments

Comments
 (0)