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>
78 template <
typename TOutputIterator,
typename T,
typename TCounter>
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>
166 return std::uninitialized_fill_n(o_begin, n, value);
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)
180 return std::uninitialized_fill_n(o_begin, n, value);
188 template <
typename TOutputIterator,
typename TSize,
typename T>
200 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
215 template <
typename TInputIterator,
typename TOutputIterator>
227 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
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>
313 return std::uninitialized_copy_n(i_begin, n, o_begin);
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)
327 return std::uninitialized_copy_n(i_begin, n, o_begin);
335 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
347 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
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)
366 return std::uninitialized_move(i_begin, i_end, 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));
380 return std::uninitialized_move(i_begin, i_end, o_begin);
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>
471 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
482#if ETL_USING_STL && ETL_USING_CPP17
488 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
491 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
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);
505 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
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>
614#if ETL_USING_STL && ETL_USING_CPP17
620 template <
typename TOutputIterator>
624 std::uninitialized_default_construct(o_begin, o_end);
633 template <
typename TOutputIterator,
typename TCounter>
637 count = int32_t(etl::distance(o_begin, o_end));
639 std::uninitialized_default_construct(o_begin, o_end);
647 template <
typename TOutputIterator>
659 template <
typename TOutputIterator>
664 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
679 template <
typename TOutputIterator,
typename TCounter>
692 template <
typename TOutputIterator,
typename TCounter>
702#if ETL_USING_STL && ETL_USING_CPP17
708 template <
typename TOutputIterator,
typename TSize>
711 return std::uninitialized_default_construct_n(o_begin, n);
720 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
725 return std::uninitialized_default_construct_n(o_begin, n);
733 template <
typename TOutputIterator,
typename TSize>
746 template <
typename TOutputIterator,
typename TSize>
763 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
780 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
794#if ETL_USING_STL && ETL_USING_CPP17
800 template <
typename TOutputIterator>
803 std::uninitialized_value_construct(o_begin, o_end);
812 template <
typename TOutputIterator,
typename TCounter>
815 count += int32_t(etl::distance(o_begin, o_end));
817 std::uninitialized_value_construct(o_begin, o_end);
825 template <
typename TOutputIterator>
829 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
839 template <
typename TOutputIterator>
843 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
858 template <
typename TOutputIterator,
typename TCounter>
867#if ETL_USING_STL && ETL_USING_CPP17
873 template <
typename TOutputIterator,
typename TSize>
876 return std::uninitialized_value_construct_n(o_begin, n);
885 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
890 return std::uninitialized_value_construct_n(o_begin, n);
898 template <
typename TOutputIterator,
typename TSize>
914 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
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)
1059 std::destroy(i_begin, 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));
1073 std::destroy(i_begin, i_end);
1081 template <
typename TIterator>
1092 template <
typename TIterator>
1109 template <
typename TIterator,
typename TCounter>
1122 template <
typename TIterator,
typename TCounter>
1136#if ETL_USING_STL && ETL_USING_CPP17
1142 template <
typename TIterator,
typename TSize>
1143 TIterator
destroy_n(TIterator i_begin, TSize n)
1145 return std::destroy_n(i_begin, n);
1154 template <
typename TIterator,
typename TSize,
typename TCounter>
1155 TIterator
destroy_n(TIterator i_begin, TSize n, TCounter& count)
1159 return std::destroy_n(i_begin, n);
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> >
1318 p =
other.release();
1319 deleter = etl::move(
other.deleter);
1328 p =
other.release();
1329 deleter =
other.deleter;
1351 template <
typename U,
typename E>
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
1408 using ETL_OR_STD::swap;
1414 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1416 return (p != ETL_NULLPTR);
1419#if ETL_USING_STL && ETL_USING_CPP11
1443 reset(
other.release());
1444 deleter = etl::move(
other.deleter);
1455 reset(
other.release());
1456 deleter =
other.deleter;
1497 template<
typename T,
typename TDeleter>
1524 p =
other.release();
1525 deleter = etl::move(
other.deleter);
1534 p =
other.release();
1535 deleter =
other.deleter;
1558 template <
typename U,
typename E>
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
1614 using ETL_OR_STD::swap;
1620 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1622 return (p != ETL_NULLPTR);
1625#if ETL_USING_STL && ETL_USING_CPP11
1649 reset(
other.release());
1650 deleter = etl::move(
other.deleter);
1661 reset(
other.release());
1662 deleter =
other.deleter;
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>
1743 create_default_at(T* )
1751 template <
typename T,
typename TCounter>
1753 create_default_at(T* , TCounter& count)
1762 template <
typename T>
1764 create_default_at(T* p)
1773 template <
typename T,
typename TCounter>
1775 create_default_at(T* p, TCounter& count)
1785 template <
typename T>
1786 void create_value_at(T* p)
1795 template <
typename T,
typename TCounter>
1796 void create_value_at(T* p, TCounter& count)
1806 template <
typename T>
1807 void create_copy_at(T* p,
const T& value)
1817 template <
typename T>
1818 void create_copy_at(T* p, T&& value)
1820 ::new (p) T(etl::move(value));
1828 template <
typename T,
typename TCounter>
1829 void create_copy_at(T* p,
const T& value, TCounter& count)
1839 template <
typename T>
1840 T& make_default_at(T* p)
1843 return *
reinterpret_cast<T*
>(p);
1850 template <
typename T,
typename TCounter>
1851 T& make_default_at(T* p, TCounter& count)
1855 return *
reinterpret_cast<T*
>(p);
1862 template <
typename T>
1863 T& make_copy_at(T* p,
const T& other)
1866 return *
reinterpret_cast<T*
>(p);
1874 template <
typename T>
1875 T& make_copy_at(T* p, T&& other)
1877 ::new (p) T(etl::move(other));
1878 return *
reinterpret_cast<T*
>(p);
1886 template <
typename T,
typename TCounter>
1887 T& make_copy_at(T* p,
const T& other, TCounter& count)
1891 return *
reinterpret_cast<T*
>(p);
1898 template <
typename T,
typename TParameter>
1899 T& make_value_at(T* p,
const TParameter& value)
1902 return *
reinterpret_cast<T*
>(p);
1910 template <
typename T,
typename TParameter>
1911 T& make_value_at(T* p, TParameter&& value)
1913 ::new (p) T(etl::move(value));
1914 return *
reinterpret_cast<T*
>(p);
1922 template <
typename T,
typename TParameter,
typename TCounter>
1923 T& make_value_at(T* p,
const TParameter& value, TCounter& count)
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);
1971 inline void memory_clear(
volatile char* p,
size_t n)
1985 template <
typename T>
1986 void memory_clear(
volatile T &
object)
1988 memory_clear(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T));
1998 template <
typename T>
1999 void memory_clear_range(
volatile T*
begin,
size_t n)
2001 memory_clear(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T));
2011 template <
typename T>
2012 void memory_clear_range(
volatile T*
begin,
volatile T*
end)
2014 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2016 memory_clear_range(
begin, n);
2026 inline void memory_set(
volatile char* p,
size_t n,
char value)
2041 template <
typename T>
2042 void memory_set(
volatile T &
object,
const char value)
2044 memory_set(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T), value);
2055 template <
typename T>
2056 void memory_set_range(
volatile T*
begin,
size_t n,
const char value)
2058 memory_set(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T), value);
2069 template <
typename T>
2070 void memory_set_range(
volatile T*
begin,
volatile T*
end,
const char value)
2072 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2074 memory_set_range(
begin, n, value);
2084 template <
typename T>
2085 struct wipe_on_destruct
2089 memory_clear(
static_cast<volatile T&
>(*
this));
2097 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2098 class uninitialized_buffer
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>
2163 class uninitialized_buffer_of
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;
2180 T& operator [](
int i)
2182 return reinterpret_cast<T*
>(this->raw)[i];
2186 const T& operator [](
int i)
const
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>
2357 mem_compare(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
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>
2444 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
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>
2463 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
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>
2477 TObject& construct_object_at(
void* p, TObject&& other)
2479#if ETL_IS_DEBUG_BUILD
2480 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2489 template <
typename TObject,
typename... TArgs>
2490 TObject& construct_object_at(
void* p, TArgs&&... args)
2492#if ETL_IS_DEBUG_BUILD
2493 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2502 template <
typename TObject>
2503 TObject& construct_object_at(
void* p)
2505#if ETL_IS_DEBUG_BUILD
2506 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2515 template <
typename TObject>
2516 TObject& construct_object_at(
void* p,
const TObject& other)
2518#if ETL_IS_DEBUG_BUILD
2519 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2528 template <
typename TObject,
typename TArg>
2529 TObject& construct_object_at(
void* p,
const TArg& arg)
2531#if ETL_IS_DEBUG_BUILD
2532 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2542 template <
typename TObject>
2543 TObject& get_object_at(
void* p)
2545#if ETL_IS_DEBUG_BUILD
2546 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2549 TObject& v = *
reinterpret_cast<TObject*
>(p);
2558 template <
typename TObject>
2559 void destroy_object_at(
void* p)
2561#if ETL_IS_DEBUG_BUILD
2562 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2565 TObject& v = get_object_at<TObject>(p);
#define ETL_ASSERT(b, e)
Definition error_handler.h:316
TOutputIterator uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T &value)
Definition memory.h:65
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
TOutputIterator uninitialized_value_construct_n(TOutputIterator o_begin, TSize n)
Definition memory.h:899
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
etl::enable_if< etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *)
Definition memory.h:1006
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
TOutputIterator uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition memory.h:459
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
add_rvalue_reference
Definition type_traits_generator.h:1327
conditional
Definition type_traits_generator.h:1160
is_reference
Definition type_traits_generator.h:1111
is_same
Definition type_traits_generator.h:1041
bitset_ext
Definition absolute.h:38
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_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:961
pair holds two objects of arbitrary type
Definition utility.h:164