31#ifndef ETL_MEMORY_INCLUDED
32#define ETL_MEMORY_INCLUDED
48#if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL
72 template <
typename Iterator>
73 ETL_CONSTEXPR
typename Iterator::pointer
to_address(
const Iterator& itr) ETL_NOEXCEPT
85 template <
typename TOutputIterator,
typename T>
86 TOutputIterator
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value)
88 std::uninitialized_fill(o_begin, o_end, value);
99 template <
typename TOutputIterator,
typename T,
typename TCounter>
100 TOutputIterator
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
102 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
104 std::uninitialized_fill(o_begin, o_end, value);
114 template <
typename TOutputIterator,
typename T>
115 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>
::type
118 etl::fill(o_begin, o_end, value);
128 template <
typename TOutputIterator,
typename T>
129 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
130 TOutputIterator>::type
133 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
135 while (o_begin != o_end)
150 template <
typename TOutputIterator,
typename T,
typename TCounter>
151 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
152 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
154 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
156 etl::fill(o_begin, o_end, value);
167 template <
typename TOutputIterator,
typename T,
typename TCounter>
168 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
169 TOutputIterator>::type
170 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
172 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
180#if ETL_USING_STL && ETL_USING_CPP11
186 template <
typename TOutputIterator,
typename TSize,
typename T>
189 return std::uninitialized_fill_n(o_begin, n, value);
198 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
199 TOutputIterator
uninitialized_fill_n(TOutputIterator o_begin, TSize n,
const T& value, TCounter& count)
203 return std::uninitialized_fill_n(o_begin, n, value);
211 template <
typename TOutputIterator,
typename TSize,
typename T>
223 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
238 template <
typename TInputIterator,
typename TOutputIterator>
239 TOutputIterator
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
241 return std::uninitialized_copy(i_begin, i_end, o_begin);
250 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
251 TOutputIterator
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
253 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
255 return std::uninitialized_copy(i_begin, i_end, o_begin);
263 template <
typename TInputIterator,
typename TOutputIterator>
264 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>
::type
265 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
267 return etl::copy(i_begin, i_end, o_begin);
275 template <
typename TInputIterator,
typename TOutputIterator>
276 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
277 TOutputIterator>::type
278 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
280 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
282 TOutputIterator o_end = o_begin;
284 while (i_begin != i_end)
300 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
301 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
302 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
304 TOutputIterator o_end = etl::copy(i_begin, i_end, o_begin);
305 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
316 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
317 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
318 TOutputIterator>::type
319 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
323 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
337 struct uninitialized_copy_fn
339 template <
class I,
class S1,
class O,
class S2,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
340 ranges::uninitialized_copy_result<I, O> operator()(I ifirst, S1 ilast, O ofirst, S2 olast)
const
342 using value_type =
typename etl::iterator_traits<O>::value_type;
344 O ofirst_original = ofirst;
346 #if ETL_USING_EXCEPTIONS
350 for (; ifirst != ilast && ofirst != olast; ++ifirst, ++ofirst)
352 ::new (
static_cast<void*
>(
etl::to_address(ofirst))) value_type(*ifirst);
355 return {etl::move(ifirst), etl::move(ofirst)};
356 #if ETL_USING_EXCEPTIONS
360 for (; ofirst_original != ofirst; ++ofirst_original)
369 template <
class IR,
class OR,
typename = etl::enable_if_t<etl::is_range_v<IR>>>
370 ranges::uninitialized_copy_result<ranges::borrowed_iterator_t<IR>, ranges::borrowed_iterator_t<OR>> operator()(IR&& in_range,
371 OR&& out_range)
const
373 return (*
this)(ranges::begin(in_range), ranges::end(in_range), ranges::begin(out_range), ranges::end(out_range));
384 struct uninitialized_copy_n_fn
386 template <
class I,
class O,
class S,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
387 ranges::uninitialized_copy_n_result<I, O> operator()(I ifirst, etl::iter_difference_t<I> n, O ofirst, S olast)
const
389 using value_type =
typename etl::iterator_traits<O>::value_type;
391 O ofirst_original = ofirst;
393 #if ETL_USING_EXCEPTIONS
397 for (; n > 0 && ofirst != olast; ++ifirst, ++ofirst, --n)
399 ::new (
static_cast<void*
>(
etl::to_address(ofirst))) value_type(*ifirst);
402 return {etl::move(ifirst), etl::move(ofirst)};
403 #if ETL_USING_EXCEPTIONS
407 for (; ofirst_original != ofirst; ++ofirst_original)
424 struct uninitialized_fill_fn
426 template <
class I,
class S,
class T,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
427 I operator()(I first, S last,
const T& value)
const
429 using value_type =
typename etl::iterator_traits<I>::value_type;
433 #if ETL_USING_EXCEPTIONS
437 for (; current != last; ++current)
439 ::new (
static_cast<void*
>(
etl::to_address(current))) value_type(value);
443 #if ETL_USING_EXCEPTIONS
447 for (; first != current; ++first)
456 template <
class R,
class T,
typename = etl::enable_if_t<etl::is_range_v<R>>>
457 ranges::borrowed_iterator_t<R> operator()(R&& r,
const T& value)
const
459 return (*
this)(ranges::begin(r), ranges::end(r), value);
470 struct uninitialized_fill_n_fn
472 template <
class I,
class T>
473 I operator()(I first, etl::iter_difference_t<I> n,
const T& value)
const
475 using value_type =
typename etl::iterator_traits<I>::value_type;
479 #if ETL_USING_EXCEPTIONS
483 for (; n > 0; ++current, --n)
485 ::new (
static_cast<void*
>(
etl::to_address(current))) value_type(value);
489 #if ETL_USING_EXCEPTIONS
493 for (; first != current; ++first)
507#if ETL_USING_STL && ETL_USING_CPP11
513 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
516 return std::uninitialized_copy_n(i_begin, n, o_begin);
525 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
526 TOutputIterator
uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
530 return std::uninitialized_copy_n(i_begin, n, o_begin);
538 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
550 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
551 TOutputIterator
uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
560 #if ETL_USING_STL && ETL_USING_CPP17
566 template <
typename TInputIterator,
typename TOutputIterator>
567 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
571 return std::uninitialized_move(i_begin, i_end, o_begin);
581 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
582 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
584 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
587 return std::uninitialized_move(i_begin, i_end, o_begin);
596 template <
typename TInputIterator,
typename TOutputIterator>
597 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
598 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
600 return etl::move(i_begin, i_end, o_begin);
608 template <
typename TInputIterator,
typename TOutputIterator>
609 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
610 TOutputIterator>::type
611 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
613 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
615 TOutputIterator o_end = o_begin;
617 while (i_begin != i_end)
633 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
634 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
635 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
637 TOutputIterator o_end = etl::move(i_begin, i_end, o_begin);
638 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
649 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
650 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
651 TOutputIterator>::type
652 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
656 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
668 template <
typename TInputIterator,
typename TOutputIterator>
669 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
672 return ETL_OR_STD::uninitialized_copy(i_begin, i_end, o_begin);
681 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
682 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
684 count +=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
687 return ETL_OR_STD::uninitialized_copy(i_begin, i_end, o_begin);
692 #if ETL_USING_STL && ETL_USING_CPP17
698 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
701 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
710 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
711 TOutputIterator
uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
713 count += TCounter(n);
715 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
723 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
724 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
727 return etl::move(i_begin, i_begin + n, o_begin);
735 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
736 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
737 TOutputIterator>::type
740 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
742 TOutputIterator o_end = o_begin;
760 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
761 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
764 TOutputIterator o_end = etl::move(i_begin, i_begin + n, o_begin);
765 count += TCounter(n);
776 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
777 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
778 TOutputIterator>::type
783 count += TCounter(n);
795 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
800 return std::uninitialized_copy_n(i_begin, n, o_begin);
812 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
813 TOutputIterator
uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
815 count += TCounter(n);
819 return std::uninitialized_copy_n(i_begin, n, o_begin);
834 struct uninitialized_move_fn
836 template <
class I,
class S1,
class O,
class S2,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
837 ranges::uninitialized_move_result<I, O> operator()(I ifirst, S1 ilast, O ofirst, S2 olast)
const
839 using value_type =
typename etl::iterator_traits<O>::value_type;
841 O ofirst_original = ofirst;
843 #if ETL_USING_EXCEPTIONS
847 for (; ifirst != ilast && ofirst != olast; ++ifirst, ++ofirst)
849 ::new (
static_cast<void*
>(
etl::to_address(ofirst))) value_type(etl::move(*ifirst));
852 return {etl::move(ifirst), etl::move(ofirst)};
853 #if ETL_USING_EXCEPTIONS
857 for (; ofirst_original != ofirst; ++ofirst_original)
866 template <
class IR,
class OR,
typename = etl::enable_if_t<etl::is_range_v<IR>>>
867 ranges::uninitialized_move_result<ranges::borrowed_iterator_t<IR>, ranges::borrowed_iterator_t<OR>> operator()(IR&& in_range,
868 OR&& out_range)
const
870 return (*
this)(ranges::begin(in_range), ranges::end(in_range), ranges::begin(out_range), ranges::end(out_range));
881 struct uninitialized_move_n_fn
883 template <
class I,
class O,
class S,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
884 ranges::uninitialized_move_n_result<I, O> operator()(I ifirst, etl::iter_difference_t<I> n, O ofirst, S olast)
const
886 using value_type =
typename etl::iterator_traits<O>::value_type;
888 O ofirst_original = ofirst;
890 #if ETL_USING_EXCEPTIONS
894 for (; n > 0 && ofirst != olast; ++ifirst, ++ofirst, --n)
896 ::new (
static_cast<void*
>(
etl::to_address(ofirst))) value_type(etl::move(*ifirst));
899 return {etl::move(ifirst), etl::move(ofirst)};
900 #if ETL_USING_EXCEPTIONS
904 for (; ofirst_original != ofirst; ++ofirst_original)
918#if ETL_USING_STL && ETL_USING_CPP17
924 template <
typename TOutputIterator>
925 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>::type
928 std::uninitialized_default_construct(o_begin, o_end);
937 template <
typename TOutputIterator,
typename TCounter>
938 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>::type
941 count =
static_cast<TCounter
>(etl::distance(o_begin, o_end));
943 std::uninitialized_default_construct(o_begin, o_end);
951 template <
typename TOutputIterator>
952 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>::type
963 template <
typename TOutputIterator>
964 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>
::type
967 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
969 while (o_begin != o_end)
982 template <
typename TOutputIterator,
typename TCounter>
983 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>
::type
986 count =
static_cast<TCounter
>(etl::distance(o_begin, o_end));
995 template <
typename TOutputIterator,
typename TCounter>
996 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>
::type
999 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
1005#if ETL_USING_STL && ETL_USING_CPP17
1011 template <
typename TOutputIterator,
typename TSize>
1014 return std::uninitialized_default_construct_n(o_begin, n);
1023 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
1028 return std::uninitialized_default_construct_n(o_begin, n);
1036 template <
typename TOutputIterator,
typename TSize>
1037 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
1040 TOutputIterator o_end = o_begin + n;
1049 template <
typename TOutputIterator,
typename TSize>
1050 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
1054 TOutputIterator o_end = o_begin + n;
1067 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
1068 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>
::type
1071 TOutputIterator o_end = o_begin + n;
1084 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
1085 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
1089 TOutputIterator o_end = o_begin + n;
1107 struct uninitialized_default_construct_fn
1109 template <
class I,
class S,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
1110 I operator()(I first, S last)
const
1112 using value_type =
typename etl::iterator_traits<I>::value_type;
1116 #if ETL_USING_EXCEPTIONS
1120 for (; current != last; ++current)
1126 #if ETL_USING_EXCEPTIONS
1130 for (; first != current; ++first)
1139 template <
class R,
typename = etl::enable_if_t<etl::is_range_v<R>>>
1140 ranges::borrowed_iterator_t<R> operator()(R&& r)
const
1142 return (*
this)(ranges::begin(r), ranges::end(r));
1153 struct uninitialized_default_construct_n_fn
1156 I operator()(I first, etl::iter_difference_t<I> n)
const
1158 using value_type =
typename etl::iterator_traits<I>::value_type;
1162 #if ETL_USING_EXCEPTIONS
1166 for (; n > 0; ++current, --n)
1172 #if ETL_USING_EXCEPTIONS
1176 for (; first != current; ++first)
1190#if ETL_USING_STL && ETL_USING_CPP17
1196 template <
typename TOutputIterator>
1199 std::uninitialized_value_construct(o_begin, o_end);
1208 template <
typename TOutputIterator,
typename TCounter>
1211 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
1213 std::uninitialized_value_construct(o_begin, o_end);
1221 template <
typename TOutputIterator>
1222 typename etl::enable_if< etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>::type
1225 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
1235 template <
typename TOutputIterator>
1236 typename etl::enable_if< !etl::is_trivially_constructible< typename etl::iterator_traits<TOutputIterator>::value_type>::value,
void>
::type
1239 typedef typename etl::iterator_traits<TOutputIterator>::value_type
value_type;
1241 while (o_begin != o_end)
1254 template <
typename TOutputIterator,
typename TCounter>
1257 count +=
static_cast<TCounter
>(etl::distance(o_begin, o_end));
1263#if ETL_USING_STL && ETL_USING_CPP17
1269 template <
typename TOutputIterator,
typename TSize>
1272 return std::uninitialized_value_construct_n(o_begin, n);
1281 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
1286 return std::uninitialized_value_construct_n(o_begin, n);
1294 template <
typename TOutputIterator,
typename TSize>
1297 TOutputIterator o_end = o_begin + n;
1310 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
1313 TOutputIterator o_end = o_begin + n;
1331 struct uninitialized_value_construct_fn
1333 template <
class I,
class S,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
1334 I operator()(I first, S last)
const
1336 using value_type =
typename etl::iterator_traits<I>::value_type;
1340 #if ETL_USING_EXCEPTIONS
1344 for (; current != last; ++current)
1350 #if ETL_USING_EXCEPTIONS
1354 for (; first != current; ++first)
1363 template <
class R,
typename = etl::enable_if_t<etl::is_range_v<R>>>
1364 ranges::borrowed_iterator_t<R> operator()(R&& r)
const
1366 return (*
this)(ranges::begin(r), ranges::end(r));
1377 struct uninitialized_value_construct_n_fn
1380 I operator()(I first, etl::iter_difference_t<I> n)
const
1382 using value_type =
typename etl::iterator_traits<I>::value_type;
1386 #if ETL_USING_EXCEPTIONS
1390 for (; n > 0; ++current, --n)
1396 #if ETL_USING_EXCEPTIONS
1400 for (; first != current; ++first)
1414#if ETL_USING_STL && ETL_USING_CPP20
1420 template <
typename T,
typename... TArgs>
1423 return std::construct_at(p, etl::forward<TArgs>(args)...);
1425#elif ETL_USING_CPP11
1431 template <
typename T,
typename... TArgs>
1434 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T(etl::forward<TArgs>(args)...);
1442 template <
typename T>
1445 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T();
1452 template <
typename T,
typename TArg>
1455 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T(arg);
1467 struct construct_at_fn
1469 template <
class T,
class... Args>
1470 constexpr T* operator()(T* p, Args&&... args)
const
1480#if ETL_USING_STL && ETL_USING_CPP20
1486 template <
typename T>
1498 template <
typename T,
typename TCounter>
1499 ETL_CONSTEXPR20
void destroy_at(T* p, TCounter& count)
1510 template <
typename T>
1520 template <
typename T>
1521 typename etl::enable_if<!etl::is_trivially_destructible<T>::value,
void>
::type destroy_at(T* p)
1532 template <
typename T,
typename TCounter>
1533 typename etl::enable_if<etl::is_trivially_destructible<T>::value,
void>
::type destroy_at(T* , TCounter& count)
1544 template <
typename T,
typename TCounter>
1545 typename etl::enable_if<!etl::is_trivially_destructible<T>::value,
void>
::type destroy_at(T* p, TCounter& count)
1552#if ETL_USING_STL && ETL_USING_CPP17
1558 template <
typename TIterator>
1559 void destroy(TIterator i_begin, TIterator i_end)
1561 std::destroy(i_begin, i_end);
1570 template <
typename TIterator,
typename TCounter>
1571 void destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1573 count -=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
1575 std::destroy(i_begin, i_end);
1583 template <
typename TIterator>
1584 typename etl::enable_if< etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value,
void>::type
1594 template <
typename TIterator>
1595 typename etl::enable_if< !etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value,
void>
::type
1598 while (i_begin != i_end)
1611 template <
typename TIterator,
typename TCounter>
1612 typename etl::enable_if< etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value,
void>
::type
1613 destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1615 count -=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
1624 template <
typename TIterator,
typename TCounter>
1625 typename etl::enable_if< !etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value,
void>
::type
1626 destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1628 count -=
static_cast<TCounter
>(etl::distance(i_begin, i_end));
1630 while (i_begin != i_end)
1638#if ETL_USING_STL && ETL_USING_CPP17
1644 template <
typename TIterator,
typename TSize>
1645 TIterator
destroy_n(TIterator i_begin, TSize n)
1647 return std::destroy_n(i_begin, n);
1656 template <
typename TIterator,
typename TSize,
typename TCounter>
1657 TIterator
destroy_n(TIterator i_begin, TSize n, TCounter& count)
1661 return std::destroy_n(i_begin, n);
1669 template <
typename TIterator,
typename TSize>
1670 typename etl::enable_if< etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value, TIterator>::type
1681 template <
typename TIterator,
typename TSize>
1682 typename etl::enable_if< !etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value, TIterator>
::type
1701 template <
typename TIterator,
typename TSize,
typename TCounter>
1702 typename etl::enable_if< etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value, TIterator>
::type
1715 template <
typename TIterator,
typename TSize,
typename TCounter>
1716 typename etl::enable_if< !etl::is_trivially_destructible< typename etl::iterator_traits<TIterator>::value_type>::value, TIterator>
::type
1740 struct destroy_at_fn
1743 constexpr void operator()(T* p)
const
1758 template <
class I,
class S,
typename = etl::enable_if_t<!etl::is_range_v<I>>>
1759 I operator()(I first, S last)
const
1761 for (; first != last; ++first)
1769 template <
class R,
typename = etl::enable_if_t<etl::is_range_v<R>>>
1770 ranges::borrowed_iterator_t<R> operator()(R&& r)
const
1772 return (*
this)(ranges::begin(r), ranges::end(r));
1776 inline constexpr destroy_fn destroy{};
1786 I operator()(I first, etl::iter_difference_t<I> n)
const
1788 for (; n > 0; ++first, --n)
1797 inline constexpr destroy_n_fn
destroy_n{};
1807 template <
typename T>
1808 struct default_delete
1811 ETL_CONSTEXPR default_delete() ETL_NOEXCEPT
1816 template <
typename U>
1817 default_delete(
const default_delete<U>&) ETL_NOEXCEPT
1822 void operator()(T* p)
const ETL_NOEXCEPT
1834 template <
typename T>
1835 struct default_delete<T[]>
1838 ETL_CONSTEXPR default_delete() ETL_NOEXCEPT
1843 template <
typename U>
1844 default_delete(
const default_delete<U>&) ETL_NOEXCEPT
1850 void operator()(U* p)
const
1862 template <
typename T,
typename TDeleter = etl::default_delete<T> >
1867 typedef T element_type;
1869 typedef T& reference;
1872 ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT
1878 ETL_CONSTEXPR
explicit unique_ptr(pointer p_) ETL_NOEXCEPT
1885 unique_ptr(unique_ptr&& other) ETL_NOEXCEPT
1889 p = other.release();
1890 deleter = etl::move(other.deleter);
1895 unique_ptr(unique_ptr& other) ETL_NOEXCEPT
1899 p = other.release();
1900 deleter = other.deleter;
1906 unique_ptr(pointer p_,
typename etl::conditional< etl::is_reference<TDeleter>::value, TDeleter,
1907 typename etl::add_lvalue_reference<const TDeleter>::type>
::type deleter_) ETL_NOEXCEPT
1915 unique_ptr(pointer p_,
typename etl::remove_reference<TDeleter>::type&& deleter_) ETL_NOEXCEPT
1917 , deleter(etl::move(deleter_))
1921 template <
typename U,
typename E>
1922 unique_ptr(unique_ptr<U, E>&& u) ETL_NOEXCEPT
1924 , deleter(etl::forward<E>(u.get_deleter()))
1932 if (p != ETL_NULLPTR)
1939 ETL_CONSTEXPR pointer get()
const ETL_NOEXCEPT
1945 TDeleter& get_deleter() ETL_NOEXCEPT
1951 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1957 pointer release() ETL_NOEXCEPT
1966 void reset(pointer p_ = pointer()) ETL_NOEXCEPT
1968 if (p_ == ETL_NULLPTR || p_ != p)
1973 if (value != ETL_NULLPTR)
1981 void swap(unique_ptr& value) ETL_NOEXCEPT
1983 using ETL_OR_STD::swap;
1989 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1991 return (p != ETL_NULLPTR);
2007 unique_ptr& operator=(unique_ptr&& other) ETL_NOEXCEPT
2011 reset(other.release());
2012 deleter = etl::move(other.deleter);
2019 unique_ptr& operator=(unique_ptr& other) ETL_NOEXCEPT
2023 reset(other.release());
2024 deleter = other.deleter;
2032 ETL_CONSTEXPR reference operator*()
const
2038 ETL_CONSTEXPR pointer operator->()
const ETL_NOEXCEPT
2044 ETL_CONSTEXPR reference operator[](
size_t i)
const
2052 unique_ptr(
const unique_ptr&) ETL_DELETE;
2053 unique_ptr& operator=(
const unique_ptr&) ETL_DELETE;
2065 template <
typename T,
typename TDeleter>
2066 class unique_ptr<T[], TDeleter>
2070 typedef T element_type;
2072 typedef T& reference;
2075 ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT
2081 ETL_CONSTEXPR
explicit unique_ptr(pointer p_) ETL_NOEXCEPT
2088 unique_ptr(unique_ptr&& other) ETL_NOEXCEPT
2092 p = other.release();
2093 deleter = etl::move(other.deleter);
2098 unique_ptr(unique_ptr& other) ETL_NOEXCEPT
2102 p = other.release();
2103 deleter = other.deleter;
2109 unique_ptr(pointer p_,
typename etl::conditional< etl::is_reference<TDeleter>::value, TDeleter,
2110 typename etl::add_lvalue_reference<const TDeleter>::type>
::type deleter_) ETL_NOEXCEPT
2118 unique_ptr(pointer p_,
typename etl::remove_reference<TDeleter>::type&& deleter_) ETL_NOEXCEPT
2120 , deleter(etl::move(deleter_))
2124 template <
typename U,
typename E>
2125 unique_ptr(unique_ptr<U, E>&& u) ETL_NOEXCEPT
2127 , deleter(etl::forward<E>(u.get_deleter()))
2135 if (p != ETL_NULLPTR)
2142 ETL_CONSTEXPR pointer get()
const ETL_NOEXCEPT
2148 TDeleter& get_deleter() ETL_NOEXCEPT
2154 const TDeleter& get_deleter()
const ETL_NOEXCEPT
2160 pointer release() ETL_NOEXCEPT
2168 void reset(pointer p_) ETL_NOEXCEPT
2175 if (value != ETL_NULLPTR)
2188 void swap(unique_ptr& v) ETL_NOEXCEPT
2190 using ETL_OR_STD::swap;
2196 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
2198 return (p != ETL_NULLPTR);
2211 unique_ptr& operator=(unique_ptr&& other) ETL_NOEXCEPT
2215 reset(other.release());
2216 deleter = etl::move(other.deleter);
2223 unique_ptr& operator=(unique_ptr& other) ETL_NOEXCEPT
2227 reset(other.release());
2228 deleter = other.deleter;
2236 ETL_CONSTEXPR reference operator*()
const
2242 ETL_CONSTEXPR pointer operator->()
const ETL_NOEXCEPT
2248 ETL_CONSTEXPR reference operator[](
size_t i)
const
2256 unique_ptr(
const unique_ptr&) ETL_DELETE;
2257 unique_ptr& operator=(
const unique_ptr&) ETL_DELETE;
2267template <
typename T1,
typename TD1,
typename T2,
typename TD2>
2270 return lhs.get() == rhs.get();
2274template <
typename T1,
typename TD1,
typename T2,
typename TD2>
2277 return reinterpret_cast<char*
>(lhs.get()) <
reinterpret_cast<char*
>(rhs.get());
2281template <
typename T1,
typename TD1,
typename T2,
typename TD2>
2284 return !(rhs < lhs);
2288template <
typename T1,
typename TD1,
typename T2,
typename TD2>
2295template <
typename T1,
typename TD1,
typename T2,
typename TD2>
2298 return !(lhs < rhs);
2307 template <
typename T>
2316 template <
typename T,
typename TCounter>
2326 template <
typename T>
2336 template <
typename T,
typename TCounter>
2347 template <
typename T>
2357 template <
typename T,
typename TCounter>
2368 template <
typename T>
2379 template <
typename T>
2382 ::new (p) T(etl::move(value));
2390 template <
typename T,
typename TCounter>
2401 template <
typename T>
2405 return *
reinterpret_cast<T*
>(p);
2412 template <
typename T,
typename TCounter>
2417 return *
reinterpret_cast<T*
>(p);
2424 template <
typename T>
2428 return *
reinterpret_cast<T*
>(p);
2436 template <
typename T>
2439 ::new (p) T(etl::move(other));
2440 return *
reinterpret_cast<T*
>(p);
2448 template <
typename T,
typename TCounter>
2453 return *
reinterpret_cast<T*
>(p);
2460 template <
typename T,
typename TParameter>
2464 return *
reinterpret_cast<T*
>(p);
2472 template <
typename T,
typename TParameter>
2475 ::new (p) T(etl::move(value));
2476 return *
reinterpret_cast<T*
>(p);
2484 template <
typename T,
typename TParameter,
typename TCounter>
2489 return *
reinterpret_cast<T*
>(p);
2497 template <
typename T>
2500 void create_copy_at(
void* p)
2502 new (p) T(
static_cast<const T&
>(*
this));
2505 template <
typename TCounter>
2506 void create_copy_at(
void* p, TCounter& count)
2508 new (p) T(
static_cast<const T&
>(*
this));
2512 T& make_copy_at(
void* p)
2514 new (p) T(
static_cast<const T&
>(*
this));
2515 return *
reinterpret_cast<T*
>(p);
2518 template <
typename TCounter>
2519 T& make_copy_at(
void* p, TCounter& count)
2521 new (p) T(
static_cast<const T&
>(*
this));
2523 return *
reinterpret_cast<T*
>(p);
2547 template <
typename T>
2550 memory_clear(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T));
2560 template <
typename T>
2573 template <
typename T>
2576 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2603 template <
typename T>
2606 memory_set(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T), value);
2617 template <
typename T>
2620 memory_set(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T), value);
2631 template <
typename T>
2634 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2646 template <
typename T>
2660 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2665 static ETL_CONSTANT
size_t Object_Size = VObject_Size;
2666 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2667 static ETL_CONSTANT
size_t Alignment = VAlignment;
2670 template <
typename T>
2673 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)),
"Incompatible alignment");
2674 return *
reinterpret_cast<T*
>(raw);
2678 template <
typename T>
2679 operator const T&()
const
2681 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)),
"Incompatible alignment");
2682 return *
reinterpret_cast<const T*
>(raw);
2686 template <
typename T>
2689 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)),
"Incompatible alignment");
2690 return reinterpret_cast<T*
>(raw);
2694 template <
typename T>
2695 operator const T*()
const
2697 ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)),
"Incompatible alignment");
2698 return reinterpret_cast<const T*
>(raw);
2701#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2702 alignas(VAlignment)
char raw[Object_Size * N_Objects];
2706 char raw[VObject_Size * VN_Objects];
2707 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2713 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2714 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Object_Size;
2716 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2717 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::N_Objects;
2719 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2720 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Alignment;
2726 template <
typename T,
size_t VN_Objects>
2731 typedef T value_type;
2732 typedef T& reference;
2733 typedef const T& const_reference;
2735 typedef const T* const_pointer;
2736 typedef T* iterator;
2737 typedef const T* const_iterator;
2739 static ETL_CONSTANT
size_t Object_Size =
sizeof(T);
2740 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2741 static ETL_CONSTANT
size_t Alignment = etl::alignment_of<T>::value;
2746 return reinterpret_cast<T*
>(this->raw)[i];
2752 return reinterpret_cast<const T*
>(this->raw)[i];
2758 return *
reinterpret_cast<T*
>(raw);
2762 operator const T&()
const
2764 return *
reinterpret_cast<const T*
>(raw);
2771 return reinterpret_cast<T*
>(raw);
2775 operator const T*()
const
2777 return reinterpret_cast<const T*
>(raw);
2782 return reinterpret_cast<T*
>(raw);
2785 const T* begin()
const
2787 return reinterpret_cast<const T*
>(raw);
2792 return reinterpret_cast<T*
>(raw + (
sizeof(T) * N_Objects));
2795 const T* end()
const
2797 return reinterpret_cast<const T*
>(raw + (
sizeof(T) * N_Objects));
2800#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2801 alignas(Alignment)
char raw[
sizeof(T) * N_Objects];
2805 char raw[
sizeof(T) * N_Objects];
2806 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2812 template <
typename T,
size_t VN_Objects>
2813 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Object_Size;
2815 template <
typename T,
size_t VN_Objects>
2816 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::N_Objects;
2818 template <
typename T,
size_t VN_Objects>
2819 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Alignment;
2822 template <
typename T,
size_t N_Objects>
2834 template <
typename T>
2835 T*
mem_copy(
const T* sb,
const T* se, T* db) ETL_NOEXCEPT
2837 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_copy a non trivially copyable type");
2839#if ETL_USING_BUILTIN_MEMCPY
2840 __builtin_memcpy(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2842 ::memcpy(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2855 template <
typename T>
2858 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_copy a non trivially copyable type");
2860#if ETL_USING_BUILTIN_MEMCPY
2861 __builtin_memcpy(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2863 ::memcpy(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2876 template <
typename T>
2877 T*
mem_move(
const T* sb,
const T* se, T* db) ETL_NOEXCEPT
2879 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_move a non trivially copyable type");
2881#if ETL_USING_BUILTIN_MEMMOVE
2882 __builtin_memmove(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2884 ::memmove(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2897 template <
typename T>
2900 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_move a non trivially copyable type");
2902#if ETL_USING_BUILTIN_MEMMOVE
2905 __builtin_memmove(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2908 ::memmove(
reinterpret_cast<void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2926 template <
typename T>
2930 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_compare a non trivially copyable type");
2932#if ETL_USING_BUILTIN_MEMCMP
2933 return __builtin_memcmp(
reinterpret_cast<const void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2935 return ::memcmp(
reinterpret_cast<const void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) *
static_cast<size_t>(se - sb));
2951 template <
typename T>
2955 ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value,
"Cannot mem_compare a non trivially copyable type");
2957#if ETL_USING_BUILTIN_MEMCMP
2958 return __builtin_memcmp(
reinterpret_cast<const void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2960 return ::memcmp(
reinterpret_cast<const void*
>(db),
reinterpret_cast<const void*
>(sb),
sizeof(T) * n);
2971 template <
typename TPo
inter,
typename T>
2972 typename etl::enable_if<etl::is_pointer<TPointer>::value && !etl::is_const<TPointer>::value && etl::is_integral<T>::value &&
sizeof(T) == 1,
2974 mem_set(TPointer db,
const TPointer de, T value) ETL_NOEXCEPT
2976 ETL_STATIC_ASSERT(etl::is_trivially_copyable<
typename etl::iterator_traits<TPointer>::value_type>::value,
2977 "Cannot mem_set a non trivially copyable type");
2979#if ETL_USING_BUILTIN_MEMSET
2980 __builtin_memset(
reinterpret_cast<void*
>(db),
static_cast<char>(value),
2981 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(de - db));
2983 ::memset(
reinterpret_cast<void*
>(db),
static_cast<char>(value),
2984 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(de - db));
2997 template <
typename TPo
inter,
typename T>
2998 typename etl::enable_if<etl::is_pointer<TPointer>::value && !etl::is_const<TPointer>::value && etl::is_integral<T>::value &&
sizeof(T) == 1,
3000 mem_set(TPointer db,
size_t n, T value) ETL_NOEXCEPT
3002 ETL_STATIC_ASSERT(etl::is_trivially_copyable<
typename etl::iterator_traits<TPointer>::value_type>::value,
3003 "Cannot mem_set a non trivially copyable type");
3005#if ETL_USING_BUILTIN_MEMSET
3006 __builtin_memset(
reinterpret_cast<void*
>(db),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3008 ::memset(
reinterpret_cast<void*
>(db),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3021 template <
typename TPo
inter,
typename T>
3024 && etl::is_integral<T>::value &&
sizeof(T) == 1,
3027#if ETL_USING_BUILTIN_MEMCHR
3028 void* result = __builtin_memchr(
reinterpret_cast<void*
>(sb),
static_cast<char>(value),
3029 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
3031 return (result == 0U) ?
reinterpret_cast<char*
>(se) :
reinterpret_cast<char*
>(result);
3033 void* result = ::memchr(
reinterpret_cast<void*
>(sb),
static_cast<char>(value),
3034 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
3036 return (result == 0U) ?
reinterpret_cast<char*
>(se) :
reinterpret_cast<char*
>(result);
3047 template <
typename TPo
inter,
typename T>
3050 && etl::is_integral<T>::value &&
sizeof(T) == 1,
3053#if ETL_USING_BUILTIN_MEMCHR
3054 const void* result = __builtin_memchr(
reinterpret_cast<const void*
>(sb),
static_cast<char>(value),
3055 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
3057 return (result == 0U) ?
reinterpret_cast<const char*
>(se) :
reinterpret_cast<const char*
>(result);
3059 const void* result = ::memchr(
reinterpret_cast<const void*
>(sb),
static_cast<char>(value),
3060 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
3062 return (result == 0U) ?
reinterpret_cast<const char*
>(se) :
reinterpret_cast<const char*
>(result);
3073 template <
typename TPo
inter,
typename T>
3076 && etl::is_integral<T>::value &&
sizeof(T) == 1,
3079#if ETL_USING_BUILTIN_MEMCHR
3081 __builtin_memchr(
reinterpret_cast<void*
>(sb),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3083 return (result == 0U) ?
reinterpret_cast<char*
>(sb + n) :
reinterpret_cast<char*
>(result);
3085 void* result = ::memchr(
reinterpret_cast<void*
>(sb),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3087 return (result == 0U) ?
reinterpret_cast<char*
>(sb + n) :
reinterpret_cast<char*
>(result);
3098 template <
typename TPo
inter,
typename T>
3101 && etl::is_integral<T>::value &&
sizeof(T) == 1,
3104#if ETL_USING_BUILTIN_MEMCHR
3105 const void* result =
3106 __builtin_memchr(
reinterpret_cast<const void*
>(sb),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3108 return (result == 0U) ?
reinterpret_cast<const char*
>(sb + n) :
reinterpret_cast<const char*
>(result);
3110 const void* result =
3111 ::memchr(
reinterpret_cast<const void*
>(sb),
static_cast<char>(value),
sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
3113 return (result == 0U) ?
reinterpret_cast<const char*
>(sb + n) :
reinterpret_cast<const char*
>(result);
3121 template <
typename TObject>
3124 #if ETL_IS_DEBUG_BUILD
3128 return *
etl::construct_at(
reinterpret_cast<typename etl::remove_reference<TObject>::type*
>(p), etl::forward<TObject>(other));
3134 template <
typename TObject,
typename... TArgs>
3137 #if ETL_IS_DEBUG_BUILD
3141 return *
etl::construct_at(
reinterpret_cast<TObject*
>(p), etl::forward<TArgs>(args)...);
3147 template <
typename TObject>
3150 #if ETL_IS_DEBUG_BUILD
3160 template <
typename TObject>
3163 #if ETL_IS_DEBUG_BUILD
3173 template <
typename TObject,
typename TArg>
3176 #if ETL_IS_DEBUG_BUILD
3187 template <
typename TObject>
3190#if ETL_IS_DEBUG_BUILD
3194 return *
reinterpret_cast<TObject*
>(p);
3200 template <
typename TObject>
3203#if ETL_IS_DEBUG_BUILD
3207 return *
reinterpret_cast<const TObject*
>(p);
3214 template <
typename TObject>
3217#if ETL_IS_DEBUG_BUILD
Memory misalignment exception.
Definition alignment.h:66
T & operator[](int i)
Index operator.
Definition memory.h:2744
const T & operator[](int i) const
Index operator.
Definition memory.h:2750
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
TOutputIterator uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T &value)
Definition memory.h:86
etl::enable_if< etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, void >::type uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end)
Definition memory.h:1223
void memory_set_range(volatile T *begin, size_t n, const char value)
Definition memory.h:2618
TOutputIterator uninitialized_value_construct_n(TOutputIterator o_begin, TSize n)
Definition memory.h:1295
etl::enable_if< etl::is_trivially_constructible< T >::value, void >::type create_default_at(T *)
Definition memory.h:2308
etl::enable_if< etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, TOutputIterator >::type uninitialized_default_construct_n(TOutputIterator o_begin, TSize n)
Definition memory.h:1038
T * construct_at(T *p)
Definition memory.h:1443
void create_copy_at(T *p, const T &value)
Definition memory.h:2369
void create_value_at(T *p)
Definition memory.h:2348
T & make_value_at(T *p, const TParameter &value)
Definition memory.h:2461
etl::enable_if< etl::is_trivially_destructible< typenameetl::iterator_traits< TIterator >::value_type >::value, void >::type destroy(TIterator, TIterator)
Definition memory.h:1585
etl::enable_if< etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *)
Definition memory.h:1511
void memory_clear_range(volatile T *begin, size_t n)
Definition memory.h:2561
void memory_set(volatile char *p, size_t n, char value)
Definition memory.h:2588
TOutputIterator uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition memory.h:796
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition memory.h:539
etl::enable_if< etl::is_trivially_destructible< typenameetl::iterator_traits< TIterator >::value_type >::value, TIterator >::type destroy_n(TIterator i_begin, TSize n)
Definition memory.h:1671
T & make_default_at(T *p)
Definition memory.h:2402
TOutputIterator uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition memory.h:669
T & make_copy_at(T *p, const T &other)
Definition memory.h:2425
void memory_clear(volatile char *p, size_t n)
Definition memory.h:2533
TOutputIterator uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition memory.h:239
etl::enable_if< etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, void >::type uninitialized_default_construct(TOutputIterator, TOutputIterator)
Definition memory.h:953
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T &value)
Definition memory.h:212
bitset_ext
Definition absolute.h:40
T * mem_move(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2877
ETL_NODISCARD int mem_compare(const T *sb, const T *se, const T *db) ETL_NOEXCEPT
Definition memory.h:2928
void destroy_object_at(void *p)
Definition memory.h:3215
etl::enable_if< etl::is_pointer< TPointer >::value &&!etl::is_const< TPointer >::value &&etl::is_integral< T >::value &&sizeof(T)==1, TPointer >::type mem_set(TPointer db, const TPointer de, T value) ETL_NOEXCEPT
Definition memory.h:2974
TObject & construct_object_at(void *p)
Default construct the container at 'p'.
Definition memory.h:3148
bool is_aligned(const void *p, size_t required_alignment)
Check that 'p' has 'required_alignment'.
Definition alignment.h:91
ETL_NODISCARD etl::enable_if< etl::is_pointer< TPointer >::value &&!etl::is_const< typenameetl::remove_pointer< TPointer >::type >::value &&etl::is_integral< T >::value &&sizeof(T)==1, char * >::type mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
Definition memory.h:3025
ETL_CONSTEXPR T * to_address(T *p) ETL_NOEXCEPT
Definition memory.h:62
ETL_CONSTEXPR TContainer::iterator begin(TContainer &container)
Definition iterator.h:967
T * mem_copy(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2835
TObject & get_object_at(void *p)
Get the container at 'p'.
Definition memory.h:3188
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:997
is_const
Definition type_traits.h:213