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
1398 if (
p_ == ETL_NULLPTR ||
p_ != p)
1403 if (value != ETL_NULLPTR)
1413 using ETL_OR_STD::swap;
1419 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1421 return (p != ETL_NULLPTR);
1441 reset(
other.release());
1442 deleter = etl::move(
other.deleter);
1453 reset(
other.release());
1454 deleter =
other.deleter;
1495 template<
typename T,
typename TDeleter>
1522 p =
other.release();
1523 deleter = etl::move(
other.deleter);
1532 p =
other.release();
1533 deleter =
other.deleter;
1556 template <
typename U,
typename E>
1567 if (p != ETL_NULLPTR)
1574 ETL_CONSTEXPR
pointer get()
const ETL_NOEXCEPT
1580 TDeleter& get_deleter() ETL_NOEXCEPT
1586 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1592 pointer release() ETL_NOEXCEPT
1607 if (value != ETL_NULLPTR)
1622 using ETL_OR_STD::swap;
1628 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1630 return (p != ETL_NULLPTR);
1647 reset(
other.release());
1648 deleter = etl::move(
other.deleter);
1659 reset(
other.release());
1660 deleter =
other.deleter;
1699template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1702 return lhs.get() == rhs.get();
1706template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1709 return reinterpret_cast<char*
>(lhs.get()) <
reinterpret_cast<char*
>(rhs.get());
1713template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1716 return !(rhs < lhs);
1720template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1727template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1730 return !(lhs < rhs);
1739 template <
typename T>
1741 create_default_at(T* )
1749 template <
typename T,
typename TCounter>
1751 create_default_at(T* , TCounter& count)
1760 template <
typename T>
1762 create_default_at(T* p)
1771 template <
typename T,
typename TCounter>
1773 create_default_at(T* p, TCounter& count)
1783 template <
typename T>
1784 void create_value_at(T* p)
1793 template <
typename T,
typename TCounter>
1794 void create_value_at(T* p, TCounter& count)
1804 template <
typename T>
1805 void create_copy_at(T* p,
const T& value)
1815 template <
typename T>
1816 void create_copy_at(T* p, T&& value)
1818 ::new (p) T(etl::move(value));
1826 template <
typename T,
typename TCounter>
1827 void create_copy_at(T* p,
const T& value, TCounter& count)
1837 template <
typename T>
1838 T& make_default_at(T* p)
1841 return *
reinterpret_cast<T*
>(p);
1848 template <
typename T,
typename TCounter>
1849 T& make_default_at(T* p, TCounter& count)
1853 return *
reinterpret_cast<T*
>(p);
1860 template <
typename T>
1861 T& make_copy_at(T* p,
const T& other)
1864 return *
reinterpret_cast<T*
>(p);
1872 template <
typename T>
1873 T& make_copy_at(T* p, T&& other)
1875 ::new (p) T(etl::move(other));
1876 return *
reinterpret_cast<T*
>(p);
1884 template <
typename T,
typename TCounter>
1885 T& make_copy_at(T* p,
const T& other, TCounter& count)
1889 return *
reinterpret_cast<T*
>(p);
1896 template <
typename T,
typename TParameter>
1897 T& make_value_at(T* p,
const TParameter& value)
1900 return *
reinterpret_cast<T*
>(p);
1908 template <
typename T,
typename TParameter>
1909 T& make_value_at(T* p, TParameter&& value)
1911 ::new (p) T(etl::move(value));
1912 return *
reinterpret_cast<T*
>(p);
1920 template <
typename T,
typename TParameter,
typename TCounter>
1921 T& make_value_at(T* p,
const TParameter& value, TCounter& count)
1925 return *
reinterpret_cast<T*
>(p);
1933 template <
typename T>
1936 void create_copy_at(
void* p)
1938 new (p) T(
static_cast<const T&
>(*
this));
1941 template <
typename TCounter>
1942 void create_copy_at(
void* p, TCounter& count)
1944 new (p) T(
static_cast<const T&
>(*
this));
1948 T& make_copy_at(
void* p)
1950 new (p) T(
static_cast<const T&
>(*
this));
1951 return *
reinterpret_cast<T*
>(p);
1954 template <
typename TCounter>
1955 T& make_copy_at(
void* p, TCounter& count)
1957 new (p) T(
static_cast<const T&
>(*
this));
1959 return *
reinterpret_cast<T*
>(p);
1969 inline void memory_clear(
volatile char* p,
size_t n)
1983 template <
typename T>
1984 void memory_clear(
volatile T &
object)
1986 memory_clear(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T));
1996 template <
typename T>
1997 void memory_clear_range(
volatile T*
begin,
size_t n)
1999 memory_clear(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T));
2009 template <
typename T>
2010 void memory_clear_range(
volatile T*
begin,
volatile T*
end)
2012 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2014 memory_clear_range(
begin, n);
2024 inline void memory_set(
volatile char* p,
size_t n,
char value)
2039 template <
typename T>
2040 void memory_set(
volatile T &
object,
const char value)
2042 memory_set(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T), value);
2053 template <
typename T>
2054 void memory_set_range(
volatile T*
begin,
size_t n,
const char value)
2056 memory_set(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T), value);
2067 template <
typename T>
2068 void memory_set_range(
volatile T*
begin,
volatile T*
end,
const char value)
2070 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2072 memory_set_range(
begin, n, value);
2082 template <
typename T>
2083 struct wipe_on_destruct
2087 memory_clear(
static_cast<volatile T&
>(*
this));
2095 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2096 class uninitialized_buffer
2100 static ETL_CONSTANT
size_t Object_Size = VObject_Size;
2101 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2102 static ETL_CONSTANT
size_t Alignment = VAlignment;
2105 template <
typename T>
2109 return *
reinterpret_cast<T*
>(raw);
2113 template <
typename T>
2114 operator const T& ()
const
2117 return *
reinterpret_cast<const T*
>(raw);
2121 template <
typename T>
2125 return reinterpret_cast<T*
>(raw);
2129 template <
typename T>
2130 operator const T* ()
const
2133 return reinterpret_cast<const T*
>(raw);
2136#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2137 alignas(VAlignment)
char raw[Object_Size * N_Objects];
2141 char raw[VObject_Size * VN_Objects];
2142 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2147 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2148 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Object_Size;
2150 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2151 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::N_Objects;
2153 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2154 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Alignment;
2160 template <
typename T,
size_t VN_Objects>
2161 class uninitialized_buffer_of
2165 typedef T value_type;
2166 typedef T& reference;
2167 typedef const T& const_reference;
2169 typedef const T* const_pointer;
2170 typedef T* iterator;
2171 typedef const T* const_iterator;
2173 static ETL_CONSTANT
size_t Object_Size =
sizeof(T);
2174 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2178 T& operator [](
int i)
2180 return reinterpret_cast<T*
>(this->raw)[i];
2184 const T& operator [](
int i)
const
2186 return reinterpret_cast<const T*
>(this->raw)[i];
2192 return *
reinterpret_cast<T*
>(raw);
2196 operator const T& ()
const
2198 return *
reinterpret_cast<const T*
>(raw);
2205 return reinterpret_cast<T*
>(raw);
2209 operator const T* ()
const
2211 return reinterpret_cast<const T*
>(raw);
2216 return reinterpret_cast<T*
>(raw);
2219 const T*
begin()
const
2221 return reinterpret_cast<const T*
>(raw);
2226 return reinterpret_cast<T*
>(raw + (
sizeof(T) * N_Objects));
2229 const T*
end()
const
2231 return reinterpret_cast<const T*
>(raw + (
sizeof(T) * N_Objects));
2234#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2235 alignas(Alignment)
char raw[
sizeof(T) * N_Objects];
2239 char raw[
sizeof(T) * N_Objects];
2240 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2245 template <
typename T,
size_t VN_Objects>
2246 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Object_Size;
2248 template <
typename T,
size_t VN_Objects>
2249 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::N_Objects;
2251 template <
typename T,
size_t VN_Objects>
2252 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Alignment;
2255 template <
typename T,
size_t N_Objects>
2256 using uninitialized_buffer_of_t =
typename uninitialized_buffer_of<T, N_Objects>::buffer;
2267 template <
typename TPo
inter>
2269 mem_copy(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2271 return reinterpret_cast<TPointer
>(memcpy(
reinterpret_cast<void*
>(db),
2272 reinterpret_cast<void*
>(sb),
2273 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb)));
2283 template <
typename TPo
inter>
2285 mem_copy(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
2287 return reinterpret_cast<TPointer
>(memcpy(
reinterpret_cast<void*
>(db),
2288 reinterpret_cast<void*
>(sb),
2289 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2299 template <
typename TPo
inter>
2301 mem_move(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2303 return reinterpret_cast<TPointer
>(memmove(
reinterpret_cast<void*
>(db),
2304 reinterpret_cast<void*
>(sb),
2305 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb)));
2315 template <
typename TPo
inter>
2317 mem_move(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
2319 return reinterpret_cast<TPointer
>(memmove(
reinterpret_cast<void*
>(db),
2320 reinterpret_cast<void*
>(sb),
2321 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2333 template <
typename TPo
inter>
2336 mem_compare(
const TPointer sb,
const TPointer se, TPointer db) ETL_NOEXCEPT
2338 return memcmp(
reinterpret_cast<void*
>(db),
2339 reinterpret_cast<void*
>(sb),
2340 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2352 template <
typename TPo
inter>
2355 mem_compare(
const TPointer sb,
size_t n, TPointer db) ETL_NOEXCEPT
2357 return memcmp(
reinterpret_cast<void*
>(db),
2358 reinterpret_cast<void*
>(sb),
2359 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2369 template <
typename TPo
inter,
typename T>
2371 mem_set(TPointer db,
const TPointer de, T value) ETL_NOEXCEPT
2373 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2374 static_cast<char>(value),
2375 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(de - db)));
2385 template <
typename TPo
inter,
typename T>
2387 mem_set(
const TPointer db,
size_t n, T value) ETL_NOEXCEPT
2389 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2390 static_cast<char>(value),
2391 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2401 template <
typename TPo
inter,
typename T>
2404 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2406 void* result = memchr(
reinterpret_cast<void*
>(sb),
2407 static_cast<char>(value),
2408 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2410 return (result == 0U) ?
reinterpret_cast<char*
>(se) : reinterpret_cast<char*>(result);
2420 template <
typename TPo
inter,
typename T>
2423 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2425 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2426 static_cast<char>(value),
2427 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2429 return (result == 0U) ?
reinterpret_cast<const char*
>(se) : reinterpret_cast<const char*>(result);
2439 template <
typename TPo
inter,
typename T>
2442 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
2444 void* result = memchr(
reinterpret_cast<void*
>(sb),
2445 static_cast<char>(value),
2446 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2448 return (result == 0U) ?
reinterpret_cast<char*
>(sb + n) : reinterpret_cast<char*>(result);
2458 template <
typename TPo
inter,
typename T>
2461 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
2463 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2464 static_cast<char>(value),
2465 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2467 return (result == 0U) ?
reinterpret_cast<const char*
>(sb + n) : reinterpret_cast<const char*>(result);
2474 template <
typename TObject>
2475 TObject& construct_object_at(
void* p, TObject&& other)
2477#if ETL_IS_DEBUG_BUILD
2478 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2487 template <
typename TObject,
typename... TArgs>
2488 TObject& construct_object_at(
void* p, TArgs&&... args)
2490#if ETL_IS_DEBUG_BUILD
2491 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2500 template <
typename TObject>
2501 TObject& construct_object_at(
void* p)
2503#if ETL_IS_DEBUG_BUILD
2504 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2513 template <
typename TObject>
2514 TObject& construct_object_at(
void* p,
const TObject& other)
2516#if ETL_IS_DEBUG_BUILD
2517 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2526 template <
typename TObject,
typename TArg>
2527 TObject& construct_object_at(
void* p,
const TArg& arg)
2529#if ETL_IS_DEBUG_BUILD
2530 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2540 template <
typename TObject>
2541 TObject& get_object_at(
void* p)
2543#if ETL_IS_DEBUG_BUILD
2544 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2547 TObject& v = *
reinterpret_cast<TObject*
>(p);
2556 template <
typename TObject>
2557 void destroy_object_at(
void* p)
2559#if ETL_IS_DEBUG_BUILD
2560 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2563 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
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
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
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:962
void destroy(const T *const p)
Destroys the object.
Definition variant_pool_generator.h:370
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:992
add_lvalue_reference
Definition type_traits_generator.h:1270
pair holds two objects of arbitrary type
Definition utility.h:164