31#ifndef ETL_MEMORY_INCLUDED
32#define ETL_MEMORY_INCLUDED
48#if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL
64 template <
typename TOutputIterator,
typename T>
65 TOutputIterator
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value)
78 template <
typename TOutputIterator,
typename T,
typename TCounter>
79 TOutputIterator
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
81 count += int32_t(etl::distance(o_begin, o_end));
93 template <
typename TOutputIterator,
typename T>
97 etl::fill(o_begin, o_end, value);
107 template <
typename TOutputIterator,
typename T>
111 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
113 while (o_begin != o_end)
115 ::new (
static_cast<void*
>(
etl::addressof(*o_begin))) value_type(value);
128 template <
typename TOutputIterator,
typename T,
typename TCounter>
130 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
132 count += int32_t(etl::distance(o_begin, o_end));
134 etl::fill(o_begin, o_end, value);
145 template <
typename TOutputIterator,
typename T,
typename TCounter>
147 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
149 count += int32_t(etl::distance(o_begin, o_end));
157#if ETL_USING_STL && ETL_USING_CPP11
163 template <
typename TOutputIterator,
typename TSize,
typename T>
175 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
176 TOutputIterator
uninitialized_fill_n(TOutputIterator o_begin, TSize n,
const T& value, TCounter& count)
188 template <
typename TOutputIterator,
typename TSize,
typename T>
200 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
215 template <
typename TInputIterator,
typename TOutputIterator>
216 TOutputIterator
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
227 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
228 TOutputIterator
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
230 count += int32_t(etl::distance(i_begin, i_end));
240 template <
typename TInputIterator,
typename TOutputIterator>
242 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
244 return etl::copy(i_begin, i_end, o_begin);
252 template <
typename TInputIterator,
typename TOutputIterator>
254 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
256 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
258 TOutputIterator o_end = o_begin;
260 while (i_begin != i_end)
262 ::new (
static_cast<void*
>(
etl::addressof(*o_end))) value_type(*i_begin);
276 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
278 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
280 TOutputIterator o_end = etl::copy(i_begin, i_end, o_begin);
281 count += int32_t(etl::distance(i_begin, i_end));
292 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
294 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
298 count += int32_t(etl::distance(i_begin, i_end));
304#if ETL_USING_STL && ETL_USING_CPP11
310 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
322 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
323 TOutputIterator
uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
335 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
347 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
348 TOutputIterator
uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
357#if ETL_USING_STL && ETL_USING_CPP17
363 template <
typename TInputIterator,
typename TOutputIterator>
364 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
375 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
376 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
378 count += int32_t(etl::distance(i_begin, i_end));
388 template <
typename TInputIterator,
typename TOutputIterator>
390 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
392 return etl::move(i_begin, i_end, o_begin);
400 template <
typename TInputIterator,
typename TOutputIterator>
402 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
404 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
406 TOutputIterator o_end = o_begin;
408 while (i_begin != i_end)
410 ::new (
static_cast<void*
>(
etl::addressof(*o_end))) value_type(etl::move(*i_begin));
424 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
426 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
428 TOutputIterator o_end = etl::move(i_begin, i_end, o_begin);
429 count += int32_t(etl::distance(i_begin, i_end));
440 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
442 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
446 count += int32_t(etl::distance(i_begin, i_end));
458 template <
typename TInputIterator,
typename TOutputIterator>
459 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
471 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
472 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
474 count += int32_t(etl::distance(i_begin, i_end));
482#if ETL_USING_STL && ETL_USING_CPP17
488 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
500 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
501 TOutputIterator
uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
503 count += TCounter(n);
513 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
517 return etl::move(i_begin, i_begin + n, o_begin);
525 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
529 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
531 TOutputIterator o_end = o_begin;
535 ::new (
static_cast<void*
>(
etl::addressof(*o_end))) value_type(etl::move(*i_begin));
549 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
553 TOutputIterator o_end = etl::move(i_begin, i_begin + n, o_begin);
554 count += TCounter(n);
565 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
571 count += TCounter(n);
583 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
600 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
601 TOutputIterator
uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
603 count += TCounter(n);
614#if ETL_USING_STL && ETL_USING_CPP17
620 template <
typename TOutputIterator>
633 template <
typename TOutputIterator,
typename TCounter>
637 count = int32_t(etl::distance(o_begin, o_end));
647 template <
typename TOutputIterator>
659 template <
typename TOutputIterator>
664 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
666 while (o_begin != o_end)
679 template <
typename TOutputIterator,
typename TCounter>
683 count = int32_t(etl::distance(o_begin, o_end));
692 template <
typename TOutputIterator,
typename TCounter>
696 count += int32_t(etl::distance(o_begin, o_end));
702#if ETL_USING_STL && ETL_USING_CPP17
708 template <
typename TOutputIterator,
typename TSize>
720 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
733 template <
typename TOutputIterator,
typename TSize>
737 TOutputIterator o_end = o_begin + n;
746 template <
typename TOutputIterator,
typename TSize>
750 TOutputIterator o_end = o_begin + n;
763 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
767 TOutputIterator o_end = o_begin + n;
780 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
784 TOutputIterator o_end = o_begin + n;
794#if ETL_USING_STL && ETL_USING_CPP17
800 template <
typename TOutputIterator>
812 template <
typename TOutputIterator,
typename TCounter>
815 count += int32_t(etl::distance(o_begin, o_end));
825 template <
typename TOutputIterator>
829 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
831 etl::fill(o_begin, o_end, value_type());
839 template <
typename TOutputIterator>
843 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
845 while (o_begin != o_end)
847 ::new (
static_cast<void*
>(
etl::addressof(*o_begin))) value_type();
858 template <
typename TOutputIterator,
typename TCounter>
861 count += int32_t(etl::distance(o_begin, o_end));
867#if ETL_USING_STL && ETL_USING_CPP17
873 template <
typename TOutputIterator,
typename TSize>
885 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
898 template <
typename TOutputIterator,
typename TSize>
901 TOutputIterator o_end = o_begin + n;
914 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
917 TOutputIterator o_end = o_begin + n;
927#if ETL_USING_STL && ETL_USING_CPP20
933 template <
typename T,
typename... TArgs>
944 template <
typename T,
typename... TArgs>
947 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T(etl::forward<TArgs>(args)...);
955 template <
typename T>
958 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T();
965 template <
typename T,
typename TArg>
968 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T(arg);
972#if ETL_USING_STL && ETL_USING_CPP20
978 template <
typename T>
991 template <
typename T,
typename TCounter>
1004 template <
typename T>
1015 template <
typename T>
1028 template <
typename T,
typename TCounter>
1041 template <
typename T,
typename TCounter>
1050#if ETL_USING_STL && ETL_USING_CPP17
1056 template <
typename TIterator>
1057 void destroy(TIterator i_begin, TIterator i_end)
1068 template <
typename TIterator,
typename TCounter>
1069 void destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1071 count -= int32_t(etl::distance(i_begin, i_end));
1081 template <
typename TIterator>
1092 template <
typename TIterator>
1096 while (i_begin != i_end)
1109 template <
typename TIterator,
typename TCounter>
1111 destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1113 count -= int32_t(etl::distance(i_begin, i_end));
1122 template <
typename TIterator,
typename TCounter>
1124 destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1126 count -= int32_t(etl::distance(i_begin, i_end));
1128 while (i_begin != i_end)
1136#if ETL_USING_STL && ETL_USING_CPP17
1142 template <
typename TIterator,
typename TSize>
1143 TIterator
destroy_n(TIterator i_begin, TSize n)
1154 template <
typename TIterator,
typename TSize,
typename TCounter>
1155 TIterator
destroy_n(TIterator i_begin, TSize n, TCounter& count)
1167 template <
typename TIterator,
typename TSize>
1179 template <
typename TIterator,
typename TSize>
1199 template <
typename TIterator,
typename TSize,
typename TCounter>
1213 template <
typename TIterator,
typename TSize,
typename TCounter>
1236 template <
typename T>
1245 template <
typename U>
1251 void operator()(T * p)
const ETL_NOEXCEPT
1263 template <
typename T>
1272 template <
typename U>
1279 void operator()(U* p)
const
1291 template <
typename T,
typename TDeleter = etl::default_delete<T> >
1296 typedef T element_type;
1298 typedef T& reference;
1307 ETL_CONSTEXPR
explicit unique_ptr(pointer p_) ETL_NOEXCEPT
1318 p = other.release();
1319 deleter = etl::move(other.deleter);
1328 p = other.release();
1329 deleter = other.deleter;
1337 typename etl::add_lvalue_reference<const TDeleter>::type>::type deleter_) ETL_NOEXCEPT
1345 unique_ptr(pointer p_,
typename etl::remove_reference<TDeleter>::type&& deleter_) ETL_NOEXCEPT
1347 , deleter(etl::move(deleter_))
1351 template <
typename U,
typename E>
1354 , deleter(etl::forward<E>(u.get_deleter()))
1362 if (p != ETL_NULLPTR)
1369 ETL_CONSTEXPR pointer get()
const ETL_NOEXCEPT
1375 TDeleter& get_deleter() ETL_NOEXCEPT
1381 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1387 pointer release() ETL_NOEXCEPT
1396 void reset(pointer p_ = pointer()) ETL_NOEXCEPT
1414 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1416 return (p != ETL_NULLPTR);
1419#if ETL_USING_STL && ETL_USING_CPP11
1421 unique_ptr& operator =(std::nullptr_t) ETL_NOEXCEPT
1443 reset(other.release());
1444 deleter = etl::move(other.deleter);
1455 reset(other.release());
1456 deleter = other.deleter;
1464 ETL_CONSTEXPR reference operator *()
const
1470 ETL_CONSTEXPR pointer operator ->()
const ETL_NOEXCEPT
1476 ETL_CONSTEXPR reference operator [](
size_t i)
const
1497 template<
typename T,
typename TDeleter>
1502 typedef T element_type;
1504 typedef T& reference;
1513 ETL_CONSTEXPR
explicit unique_ptr(pointer p_) ETL_NOEXCEPT
1524 p = other.release();
1525 deleter = etl::move(other.deleter);
1534 p = other.release();
1535 deleter = other.deleter;
1544 typename etl::add_lvalue_reference<const TDeleter>::type>::type deleter_) ETL_NOEXCEPT
1552 unique_ptr(pointer p_,
typename etl::remove_reference<TDeleter>::type&& deleter_) ETL_NOEXCEPT
1554 , deleter(etl::move(deleter_))
1558 template <
typename U,
typename E>
1561 , deleter(etl::forward<E>(u.get_deleter()))
1569 if (p != ETL_NULLPTR)
1576 ETL_CONSTEXPR pointer get()
const ETL_NOEXCEPT
1582 TDeleter& get_deleter() ETL_NOEXCEPT
1588 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1594 pointer release() ETL_NOEXCEPT
1602 void reset(pointer p_) ETL_NOEXCEPT
1620 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1622 return (p != ETL_NULLPTR);
1625#if ETL_USING_STL && ETL_USING_CPP11
1627 unique_ptr& operator =(std::nullptr_t) ETL_NOEXCEPT
1649 reset(other.release());
1650 deleter = etl::move(other.deleter);
1661 reset(other.release());
1662 deleter = other.deleter;
1670 ETL_CONSTEXPR reference operator *()
const
1676 ETL_CONSTEXPR pointer operator ->()
const ETL_NOEXCEPT
1682 ETL_CONSTEXPR reference operator [](
size_t i)
const
1701template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1704 return lhs.get() == rhs.get();
1708template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1711 return reinterpret_cast<char*
>(lhs.get()) <
reinterpret_cast<char*
>(rhs.get());
1715template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1718 return !(rhs < lhs);
1722template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1729template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1732 return !(lhs < rhs);
1741 template <
typename T>
1751 template <
typename T,
typename TCounter>
1762 template <
typename T>
1773 template <
typename T,
typename TCounter>
1785 template <
typename T>
1795 template <
typename T,
typename TCounter>
1806 template <
typename T>
1817 template <
typename T>
1820 ::new (p) T(etl::move(value));
1828 template <
typename T,
typename TCounter>
1839 template <
typename T>
1843 return *
reinterpret_cast<T*
>(p);
1850 template <
typename T,
typename TCounter>
1855 return *
reinterpret_cast<T*
>(p);
1862 template <
typename T>
1866 return *
reinterpret_cast<T*
>(p);
1874 template <
typename T>
1877 ::new (p) T(etl::move(other));
1878 return *
reinterpret_cast<T*
>(p);
1886 template <
typename T,
typename TCounter>
1891 return *
reinterpret_cast<T*
>(p);
1898 template <
typename T,
typename TParameter>
1902 return *
reinterpret_cast<T*
>(p);
1910 template <
typename T,
typename TParameter>
1913 ::new (p) T(etl::move(value));
1914 return *
reinterpret_cast<T*
>(p);
1922 template <
typename T,
typename TParameter,
typename TCounter>
1927 return *
reinterpret_cast<T*
>(p);
1935 template <
typename T>
1938 void create_copy_at(
void* p)
1940 new (p) T(
static_cast<const T&
>(*
this));
1943 template <
typename TCounter>
1944 void create_copy_at(
void* p, TCounter& count)
1946 new (p) T(
static_cast<const T&
>(*
this));
1950 T& make_copy_at(
void* p)
1952 new (p) T(
static_cast<const T&
>(*
this));
1953 return *
reinterpret_cast<T*
>(p);
1956 template <
typename TCounter>
1957 T& make_copy_at(
void* p, TCounter& count)
1959 new (p) T(
static_cast<const T&
>(*
this));
1961 return *
reinterpret_cast<T*
>(p);
1985 template <
typename T>
1988 memory_clear(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T));
1998 template <
typename T>
2011 template <
typename T>
2014 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2041 template <
typename T>
2044 memory_set(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T), value);
2055 template <
typename T>
2058 memory_set(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T), value);
2069 template <
typename T>
2072 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2084 template <
typename T>
2097 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2102 static ETL_CONSTANT
size_t Object_Size = VObject_Size;
2103 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2104 static ETL_CONSTANT
size_t Alignment = VAlignment;
2107 template <
typename T>
2111 return *
reinterpret_cast<T*
>(raw);
2115 template <
typename T>
2116 operator const T& ()
const
2119 return *
reinterpret_cast<const T*
>(raw);
2123 template <
typename T>
2127 return reinterpret_cast<T*
>(raw);
2131 template <
typename T>
2132 operator const T* ()
const
2135 return reinterpret_cast<const T*
>(raw);
2138#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2139 alignas(VAlignment)
char raw[Object_Size * N_Objects];
2143 char raw[VObject_Size * VN_Objects];
2144 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2149 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2150 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Object_Size;
2152 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2153 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::N_Objects;
2155 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2156 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Alignment;
2162 template <
typename T,
size_t VN_Objects>
2167 typedef T value_type;
2168 typedef T& reference;
2169 typedef const T& const_reference;
2171 typedef const T* const_pointer;
2172 typedef T* iterator;
2173 typedef const T* const_iterator;
2175 static ETL_CONSTANT
size_t Object_Size =
sizeof(T);
2176 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2182 return reinterpret_cast<T*
>(this->raw)[i];
2188 return reinterpret_cast<const T*
>(this->raw)[i];
2194 return *
reinterpret_cast<T*
>(raw);
2198 operator const T& ()
const
2200 return *
reinterpret_cast<const T*
>(raw);
2207 return reinterpret_cast<T*
>(raw);
2211 operator const T* ()
const
2213 return reinterpret_cast<const T*
>(raw);
2218 return reinterpret_cast<T*
>(raw);
2221 const T* begin()
const
2223 return reinterpret_cast<const T*
>(raw);
2228 return reinterpret_cast<T*
>(raw + (
sizeof(T) * N_Objects));
2231 const T* end()
const
2233 return reinterpret_cast<const T*
>(raw + (
sizeof(T) * N_Objects));
2236#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2237 alignas(Alignment)
char raw[
sizeof(T) * N_Objects];
2241 char raw[
sizeof(T) * N_Objects];
2242 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2247 template <
typename T,
size_t VN_Objects>
2248 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Object_Size;
2250 template <
typename T,
size_t VN_Objects>
2251 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::N_Objects;
2253 template <
typename T,
size_t VN_Objects>
2254 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Alignment;
2257 template <
typename T,
size_t N_Objects>
2258 using uninitialized_buffer_of_t =
typename uninitialized_buffer_of<T, N_Objects>::buffer;
2269 template <
typename TPo
inter>
2271 mem_copy(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2273 return reinterpret_cast<TPointer
>(memcpy(
reinterpret_cast<void*
>(db),
2274 reinterpret_cast<void*
>(sb),
2275 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb)));
2285 template <
typename TPo
inter>
2287 mem_copy(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
2289 return reinterpret_cast<TPointer
>(memcpy(
reinterpret_cast<void*
>(db),
2290 reinterpret_cast<void*
>(sb),
2291 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2301 template <
typename TPo
inter>
2303 mem_move(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2305 return reinterpret_cast<TPointer
>(memmove(
reinterpret_cast<void*
>(db),
2306 reinterpret_cast<void*
>(sb),
2307 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb)));
2317 template <
typename TPo
inter>
2319 mem_move(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
2321 return reinterpret_cast<TPointer
>(memmove(
reinterpret_cast<void*
>(db),
2322 reinterpret_cast<void*
>(sb),
2323 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2335 template <
typename TPo
inter>
2338 mem_compare(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2340 return memcmp(
reinterpret_cast<void*
>(db),
2341 reinterpret_cast<void*
>(sb),
2342 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2354 template <
typename TPo
inter>
2359 return memcmp(
reinterpret_cast<void*
>(db),
2360 reinterpret_cast<void*
>(sb),
2361 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2371 template <
typename TPo
inter,
typename T>
2373 mem_set(TPointer db,
const TPointer de, T value) ETL_NOEXCEPT
2375 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2376 static_cast<char>(value),
2377 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(de - db)));
2387 template <
typename TPo
inter,
typename T>
2389 mem_set(
const TPointer db,
size_t n, T value) ETL_NOEXCEPT
2391 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2392 static_cast<char>(value),
2393 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2403 template <
typename TPo
inter,
typename T>
2406 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2408 void* result = memchr(
reinterpret_cast<void*
>(sb),
2409 static_cast<char>(value),
2410 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2412 return (result == 0U) ?
reinterpret_cast<char*
>(se) :
reinterpret_cast<char*
>(result);
2422 template <
typename TPo
inter,
typename T>
2425 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2427 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2428 static_cast<char>(value),
2429 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2431 return (result == 0U) ?
reinterpret_cast<const char*
>(se) :
reinterpret_cast<const char*
>(result);
2441 template <
typename TPo
inter,
typename T>
2446 void* result = memchr(
reinterpret_cast<void*
>(sb),
2447 static_cast<char>(value),
2448 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2450 return (result == 0U) ?
reinterpret_cast<char*
>(sb + n) :
reinterpret_cast<char*
>(result);
2460 template <
typename TPo
inter,
typename T>
2465 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2466 static_cast<char>(value),
2467 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2469 return (result == 0U) ?
reinterpret_cast<const char*
>(sb + n) :
reinterpret_cast<const char*
>(result);
2476 template <
typename TObject>
2479#if ETL_IS_DEBUG_BUILD
2480 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2483 return *
etl::construct_at(
reinterpret_cast<typename etl::remove_reference<TObject>::type*
>(p), etl::forward<TObject>(other));
2489 template <
typename TObject,
typename... TArgs>
2492#if ETL_IS_DEBUG_BUILD
2493 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2496 return *
etl::construct_at(
reinterpret_cast<TObject*
>(p), etl::forward<TArgs>(args)...);
2502 template <
typename TObject>
2505#if ETL_IS_DEBUG_BUILD
2515 template <
typename TObject>
2518#if ETL_IS_DEBUG_BUILD
2528 template <
typename TObject,
typename TArg>
2531#if ETL_IS_DEBUG_BUILD
2542 template <
typename TObject>
2545#if ETL_IS_DEBUG_BUILD
2549 TObject& v = *
reinterpret_cast<TObject*
>(p);
2558 template <
typename TObject>
2561#if ETL_IS_DEBUG_BUILD
2565 TObject& v = get_object_at<TObject>(p);
Memory misalignment exception.
Definition: alignment.h:65
T & operator[](int i)
Index operator.
Definition: memory.h:2180
Definition: memory.h:2099
Definition: memory.h:2164
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
Definition: memory.h:1293
TOutputIterator uninitialized_value_construct_n(TOutputIterator o_begin, TSize n, TCounter &count)
Definition: memory.h:915
TOutputIterator uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T &value)
Definition: memory.h:65
TOutputIterator uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T &value, TCounter &count)
Definition: memory.h:79
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T &value, TCounter &count)
Definition: memory.h:201
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:827
void memory_set_range(volatile T *begin, size_t n, const char value)
Definition: memory.h:2056
TOutputIterator uninitialized_value_construct_n(TOutputIterator o_begin, TSize n)
Definition: memory.h:899
etl::enable_if< etl::is_trivially_constructible< T >::value, void >::type create_default_at(T *)
Definition: memory.h:1743
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:735
T * construct_at(T *p)
Definition: memory.h:956
void create_copy_at(T *p, const T &value)
Definition: memory.h:1807
TOutputIterator uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter &count)
Definition: memory.h:228
void create_value_at(T *p)
Definition: memory.h:1786
T & make_value_at(T *p, const TParameter &value)
Definition: memory.h:1899
etl::enable_if< etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *)
Definition: memory.h:1006
void memory_clear_range(volatile T *begin, size_t n)
Definition: memory.h:1999
void memory_set(volatile char *p, size_t n, char value)
Definition: memory.h:2026
TOutputIterator uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition: memory.h:584
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition: memory.h:336
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:1169
T & make_default_at(T *p)
Definition: memory.h:1840
TOutputIterator uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition: memory.h:459
TOutputIterator uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter &count)
Definition: memory.h:472
T & make_copy_at(T *p, const T &other)
Definition: memory.h:1863
T * construct_at(T *p, const TArg &arg)
Definition: memory.h:966
void memory_clear(volatile char *p, size_t n)
Definition: memory.h:1971
TOutputIterator uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition: memory.h:216
etl::enable_if< etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, void >::type uninitialized_default_construct(TOutputIterator, TOutputIterator)
Definition: memory.h:649
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T &value)
Definition: memory.h:189
ETL_CONSTEXPR17 T * addressof(T &t)
Definition: addressof.h:51
void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter &count)
Definition: memory.h:859
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter &count)
Definition: memory.h:348
Definition: memory.h:1937
Definition: memory.h:1238
Definition: memory.h:2086
add_rvalue_reference
Definition: type_traits_generator.h:1327
conditional
Definition: type_traits_generator.h:1160
enable_if
Definition: type_traits_generator.h:1191
is_const
Definition: type_traits_generator.h:908
is_reference
Definition: type_traits_generator.h:1111
is_same
Definition: type_traits_generator.h:1041
bitset_ext
Definition: absolute.h:38
void destroy_object_at(void *p)
Definition: memory.h:2559
ETL_NODISCARD etl::enable_if< etl::is_trivially_copyable< typenameetl::iterator_traits< TPointer >::value_type >::value, int >::type mem_compare(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT
Definition: memory.h:2338
TObject & construct_object_at(void *p)
Default construct the container at 'p'.
Definition: memory.h:2503
etl::enable_if< etl::is_trivially_copyable< typenameetl::iterator_traits< TPointer >::value_type >::value, TPointer >::type mem_set(TPointer db, const TPointer de, T value) ETL_NOEXCEPT
Definition: memory.h:2373
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition: array.h:621
etl::enable_if< etl::is_trivially_copyable< typenameetl::iterator_traits< TPointer >::value_type >::value, TPointer >::type mem_move(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT
Definition: memory.h:2303
ETL_CONSTEXPR TContainer::iterator begin(TContainer &container)
Definition: iterator.h:931
void destroy(const T *const p)
Destroys the object.
Definition: variant_pool_generator.h:256
ETL_NODISCARD etl::enable_if< etl::is_pointer< TPointer >::value &&!etl::is_const< typenameetl::remove_pointer< TPointer >::type >::value, char * >::type mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
Definition: memory.h:2406
etl::enable_if< etl::is_trivially_copyable< typenameetl::iterator_traits< TPointer >::value_type >::value, TPointer >::type mem_copy(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT
Definition: memory.h:2271
TObject & get_object_at(void *p)
Get the container at 'p'.
Definition: memory.h:2543
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition: iterator.h:961
etl::enable_if<!etl::is_trivially_destructible< typenameetl::iterator_traits< TIterator >::value_type >::value, void >::type destroy(TIterator i_begin, TIterator i_end, TCounter &count)
Definition: memory.h:1124
etl::enable_if<!etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, void >::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter &count)
Definition: memory.h:694
etl::enable_if<!etl::is_trivially_destructible< typenameetl::iterator_traits< TIterator >::value_type >::value, TIterator >::type destroy_n(TIterator i_begin, TSize n, TCounter &count)
Definition: memory.h:1215
etl::enable_if<!etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *p, TCounter &count)
Definition: memory.h:1043
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, TCounter &count)
Definition: memory.h:782