31#ifndef ETL_MEMORY_INCLUDED
32#define ETL_MEMORY_INCLUDED
48#if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL
72 template <
typename Iterator>
85 template <
typename TOutputIterator,
typename T>
99 template <
typename TOutputIterator,
typename T,
typename TCounter>
114 template <
typename TOutputIterator,
typename T>
118 etl::fill(o_begin, o_end, value);
128 template <
typename TOutputIterator,
typename T>
132 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
134 while (o_begin != o_end)
136 ::new (
static_cast<void*
>(
etl::to_address(o_begin))) value_type(value);
149 template <
typename TOutputIterator,
typename T,
typename TCounter>
151 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
153 count += int32_t(etl::distance(o_begin, o_end));
155 etl::fill(o_begin, o_end, value);
166 template <
typename TOutputIterator,
typename T,
typename TCounter>
168 uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end,
const T& value, TCounter& count)
170 count += int32_t(etl::distance(o_begin, o_end));
178#if ETL_USING_STL && ETL_USING_CPP11
184 template <
typename TOutputIterator,
typename TSize,
typename T>
187 return std::uninitialized_fill_n(o_begin, n, value);
196 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
197 TOutputIterator
uninitialized_fill_n(TOutputIterator o_begin, TSize n,
const T& value, TCounter& count)
201 return std::uninitialized_fill_n(o_begin, n, value);
209 template <
typename TOutputIterator,
typename TSize,
typename T>
221 template <
typename TOutputIterator,
typename TSize,
typename T,
typename TCounter>
236 template <
typename TInputIterator,
typename TOutputIterator>
248 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
261 template <
typename TInputIterator,
typename TOutputIterator>
263 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
265 return etl::copy(i_begin, i_end, o_begin);
273 template <
typename TInputIterator,
typename TOutputIterator>
275 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
277 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
279 TOutputIterator o_end = o_begin;
281 while (i_begin != i_end)
283 ::new (
static_cast<void*
>(
etl::to_address(o_end))) value_type(*i_begin);
297 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
299 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
301 TOutputIterator o_end = etl::copy(i_begin, i_end, o_begin);
302 count += int32_t(etl::distance(i_begin, i_end));
313 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
315 uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
319 count += int32_t(etl::distance(i_begin, i_end));
325#if ETL_USING_STL && ETL_USING_CPP11
331 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
334 return std::uninitialized_copy_n(i_begin, n, o_begin);
343 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
344 TOutputIterator
uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
348 return std::uninitialized_copy_n(i_begin, n, o_begin);
356 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
368 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
378#if ETL_USING_STL && ETL_USING_CPP17
384 template <
typename TInputIterator,
typename TOutputIterator>
385 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
387 return std::uninitialized_move(i_begin, i_end, o_begin);
396 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
397 TOutputIterator
uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
399 count += int32_t(etl::distance(i_begin, i_end));
401 return std::uninitialized_move(i_begin, i_end, o_begin);
409 template <
typename TInputIterator,
typename TOutputIterator>
411 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
413 return etl::move(i_begin, i_end, o_begin);
421 template <
typename TInputIterator,
typename TOutputIterator>
423 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
425 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
427 TOutputIterator o_end = o_begin;
429 while (i_begin != i_end)
431 ::new (
static_cast<void*
>(
etl::to_address(o_end))) value_type(etl::move(*i_begin));
445 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
447 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
449 TOutputIterator o_end = etl::move(i_begin, i_end, o_begin);
450 count += int32_t(etl::distance(i_begin, i_end));
461 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
463 uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
467 count += int32_t(etl::distance(i_begin, i_end));
479 template <
typename TInputIterator,
typename TOutputIterator>
492 template <
typename TInputIterator,
typename TOutputIterator,
typename TCounter>
503#if ETL_USING_STL && ETL_USING_CPP17
509 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
512 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
521 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
522 TOutputIterator
uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin, TCounter& count)
524 count += TCounter(n);
526 return std::uninitialized_move(i_begin, i_begin + n, o_begin);
534 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
538 return etl::move(i_begin, i_begin + n, o_begin);
546 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
550 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
552 TOutputIterator o_end = o_begin;
556 ::new (
static_cast<void*
>(
etl::to_address(o_end))) value_type(etl::move(*i_begin));
570 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
574 TOutputIterator o_end = etl::move(i_begin, i_begin + n, o_begin);
575 count += TCounter(n);
586 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
592 count += TCounter(n);
604 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator>
621 template <
typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TCounter>
635#if ETL_USING_STL && ETL_USING_CPP17
641 template <
typename TOutputIterator>
645 std::uninitialized_default_construct(o_begin, o_end);
654 template <
typename TOutputIterator,
typename TCounter>
658 count = int32_t(etl::distance(o_begin, o_end));
660 std::uninitialized_default_construct(o_begin, o_end);
668 template <
typename TOutputIterator>
680 template <
typename TOutputIterator>
685 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
700 template <
typename TOutputIterator,
typename TCounter>
713 template <
typename TOutputIterator,
typename TCounter>
723#if ETL_USING_STL && ETL_USING_CPP17
729 template <
typename TOutputIterator,
typename TSize>
732 return std::uninitialized_default_construct_n(o_begin, n);
741 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
746 return std::uninitialized_default_construct_n(o_begin, n);
754 template <
typename TOutputIterator,
typename TSize>
767 template <
typename TOutputIterator,
typename TSize>
784 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
801 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
815#if ETL_USING_STL && ETL_USING_CPP17
821 template <
typename TOutputIterator>
824 std::uninitialized_value_construct(o_begin, o_end);
833 template <
typename TOutputIterator,
typename TCounter>
836 count += int32_t(etl::distance(o_begin, o_end));
838 std::uninitialized_value_construct(o_begin, o_end);
846 template <
typename TOutputIterator>
850 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
860 template <
typename TOutputIterator>
864 typedef typename etl::iterator_traits<TOutputIterator>::value_type value_type;
879 template <
typename TOutputIterator,
typename TCounter>
888#if ETL_USING_STL && ETL_USING_CPP17
894 template <
typename TOutputIterator,
typename TSize>
897 return std::uninitialized_value_construct_n(o_begin, n);
906 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
911 return std::uninitialized_value_construct_n(o_begin, n);
919 template <
typename TOutputIterator,
typename TSize>
935 template <
typename TOutputIterator,
typename TSize,
typename TCounter>
948#if ETL_USING_STL && ETL_USING_CPP20
954 template <
typename T,
typename... TArgs>
965 template <
typename T,
typename... TArgs>
968 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p))) T(
etl::forward<TArgs>(args)...);
976 template <
typename T>
979 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p)))
T();
986 template <
typename T,
typename TArg>
989 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(p)))
T(
arg);
993#if ETL_USING_STL && ETL_USING_CPP20
999 template <
typename T>
1012 template <
typename T,
typename TCounter>
1025 template <
typename T>
1036 template <
typename T>
1049 template <
typename T,
typename TCounter>
1062 template <
typename T,
typename TCounter>
1071#if ETL_USING_STL && ETL_USING_CPP17
1077 template <
typename TIterator>
1078 void destroy(TIterator i_begin, TIterator i_end)
1080 std::destroy(i_begin, i_end);
1089 template <
typename TIterator,
typename TCounter>
1090 void destroy(TIterator i_begin, TIterator i_end, TCounter& count)
1092 count -= int32_t(etl::distance(i_begin, i_end));
1094 std::destroy(i_begin, i_end);
1102 template <
typename TIterator>
1113 template <
typename TIterator>
1130 template <
typename TIterator,
typename TCounter>
1143 template <
typename TIterator,
typename TCounter>
1157#if ETL_USING_STL && ETL_USING_CPP17
1163 template <
typename TIterator,
typename TSize>
1164 TIterator
destroy_n(TIterator i_begin, TSize n)
1166 return std::destroy_n(i_begin, n);
1175 template <
typename TIterator,
typename TSize,
typename TCounter>
1176 TIterator
destroy_n(TIterator i_begin, TSize n, TCounter& count)
1180 return std::destroy_n(i_begin, n);
1188 template <
typename TIterator,
typename TSize>
1200 template <
typename TIterator,
typename TSize>
1220 template <
typename TIterator,
typename TSize,
typename TCounter>
1234 template <
typename TIterator,
typename TSize,
typename TCounter>
1257 template <
typename T>
1266 template <
typename U>
1272 void operator()(
T * p)
const ETL_NOEXCEPT
1284 template <
typename T>
1293 template <
typename U>
1300 void operator()(
U* p)
const
1312 template <
typename T,
typename TDeleter = etl::default_delete<T> >
1339 p =
other.release();
1340 deleter = etl::move(
other.deleter);
1349 p =
other.release();
1350 deleter =
other.deleter;
1372 template <
typename U,
typename E>
1383 if (p != ETL_NULLPTR)
1390 ETL_CONSTEXPR
pointer get()
const ETL_NOEXCEPT
1396 TDeleter& get_deleter() ETL_NOEXCEPT
1402 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1408 pointer release() ETL_NOEXCEPT
1419 if (
p_ == ETL_NULLPTR ||
p_ != p)
1424 if (value != ETL_NULLPTR)
1434 using ETL_OR_STD::swap;
1440 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1442 return (p != ETL_NULLPTR);
1462 reset(
other.release());
1463 deleter = etl::move(
other.deleter);
1474 reset(
other.release());
1475 deleter =
other.deleter;
1516 template<
typename T,
typename TDeleter>
1543 p =
other.release();
1544 deleter = etl::move(
other.deleter);
1553 p =
other.release();
1554 deleter =
other.deleter;
1577 template <
typename U,
typename E>
1588 if (p != ETL_NULLPTR)
1595 ETL_CONSTEXPR
pointer get()
const ETL_NOEXCEPT
1601 TDeleter& get_deleter() ETL_NOEXCEPT
1607 const TDeleter& get_deleter()
const ETL_NOEXCEPT
1613 pointer release() ETL_NOEXCEPT
1628 if (value != ETL_NULLPTR)
1643 using ETL_OR_STD::swap;
1649 ETL_CONSTEXPR
operator bool()
const ETL_NOEXCEPT
1651 return (p != ETL_NULLPTR);
1668 reset(
other.release());
1669 deleter = etl::move(
other.deleter);
1680 reset(
other.release());
1681 deleter =
other.deleter;
1720template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1723 return lhs.get() == rhs.get();
1727template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1730 return reinterpret_cast<char*
>(lhs.get()) <
reinterpret_cast<char*
>(rhs.get());
1734template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1737 return !(rhs < lhs);
1741template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1748template<
typename T1,
typename TD1,
typename T2,
typename TD2>
1751 return !(lhs < rhs);
1760 template <
typename T>
1762 create_default_at(T* )
1770 template <
typename T,
typename TCounter>
1772 create_default_at(T* , TCounter& count)
1781 template <
typename T>
1783 create_default_at(T* p)
1792 template <
typename T,
typename TCounter>
1794 create_default_at(T* p, TCounter& count)
1804 template <
typename T>
1805 void create_value_at(T* p)
1814 template <
typename T,
typename TCounter>
1815 void create_value_at(T* p, TCounter& count)
1825 template <
typename T>
1826 void create_copy_at(T* p,
const T& value)
1836 template <
typename T>
1837 void create_copy_at(T* p, T&& value)
1839 ::new (p) T(etl::move(value));
1847 template <
typename T,
typename TCounter>
1848 void create_copy_at(T* p,
const T& value, TCounter& count)
1858 template <
typename T>
1859 T& make_default_at(T* p)
1862 return *
reinterpret_cast<T*
>(p);
1869 template <
typename T,
typename TCounter>
1870 T& make_default_at(T* p, TCounter& count)
1874 return *
reinterpret_cast<T*
>(p);
1881 template <
typename T>
1882 T& make_copy_at(T* p,
const T& other)
1885 return *
reinterpret_cast<T*
>(p);
1893 template <
typename T>
1894 T& make_copy_at(T* p, T&& other)
1896 ::new (p) T(etl::move(other));
1897 return *
reinterpret_cast<T*
>(p);
1905 template <
typename T,
typename TCounter>
1906 T& make_copy_at(T* p,
const T& other, TCounter& count)
1910 return *
reinterpret_cast<T*
>(p);
1917 template <
typename T,
typename TParameter>
1918 T& make_value_at(T* p,
const TParameter& value)
1921 return *
reinterpret_cast<T*
>(p);
1929 template <
typename T,
typename TParameter>
1930 T& make_value_at(T* p, TParameter&& value)
1932 ::new (p) T(etl::move(value));
1933 return *
reinterpret_cast<T*
>(p);
1941 template <
typename T,
typename TParameter,
typename TCounter>
1942 T& make_value_at(T* p,
const TParameter& value, TCounter& count)
1946 return *
reinterpret_cast<T*
>(p);
1954 template <
typename T>
1957 void create_copy_at(
void* p)
1959 new (p) T(
static_cast<const T&
>(*
this));
1962 template <
typename TCounter>
1963 void create_copy_at(
void* p, TCounter& count)
1965 new (p) T(
static_cast<const T&
>(*
this));
1969 T& make_copy_at(
void* p)
1971 new (p) T(
static_cast<const T&
>(*
this));
1972 return *
reinterpret_cast<T*
>(p);
1975 template <
typename TCounter>
1976 T& make_copy_at(
void* p, TCounter& count)
1978 new (p) T(
static_cast<const T&
>(*
this));
1980 return *
reinterpret_cast<T*
>(p);
1990 inline void memory_clear(
volatile char* p,
size_t n)
2004 template <
typename T>
2005 void memory_clear(
volatile T &
object)
2007 memory_clear(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T));
2017 template <
typename T>
2018 void memory_clear_range(
volatile T*
begin,
size_t n)
2020 memory_clear(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T));
2030 template <
typename T>
2031 void memory_clear_range(
volatile T*
begin,
volatile T*
end)
2033 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2035 memory_clear_range(
begin, n);
2045 inline void memory_set(
volatile char* p,
size_t n,
char value)
2060 template <
typename T>
2061 void memory_set(
volatile T &
object,
const char value)
2063 memory_set(
reinterpret_cast<volatile char*
>(&
object),
sizeof(T), value);
2074 template <
typename T>
2075 void memory_set_range(
volatile T*
begin,
size_t n,
const char value)
2077 memory_set(
reinterpret_cast<volatile char*
>(
begin), n *
sizeof(T), value);
2088 template <
typename T>
2089 void memory_set_range(
volatile T*
begin,
volatile T*
end,
const char value)
2091 const size_t n =
static_cast<size_t>(etl::distance(
begin,
end));
2093 memory_set_range(
begin, n, value);
2103 template <
typename T>
2104 struct wipe_on_destruct
2108 memory_clear(
static_cast<volatile T&
>(*
this));
2116 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2117 class uninitialized_buffer
2121 static ETL_CONSTANT
size_t Object_Size = VObject_Size;
2122 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2123 static ETL_CONSTANT
size_t Alignment = VAlignment;
2126 template <
typename T>
2130 return *
reinterpret_cast<T*
>(raw);
2134 template <
typename T>
2135 operator const T& ()
const
2138 return *
reinterpret_cast<const T*
>(raw);
2142 template <
typename T>
2146 return reinterpret_cast<T*
>(raw);
2150 template <
typename T>
2151 operator const T* ()
const
2154 return reinterpret_cast<const T*
>(raw);
2157#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2158 alignas(VAlignment)
char raw[Object_Size * N_Objects];
2162 char raw[VObject_Size * VN_Objects];
2163 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2168 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2169 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Object_Size;
2171 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2172 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::N_Objects;
2174 template <
size_t VObject_Size,
size_t VN_Objects,
size_t VAlignment>
2175 ETL_CONSTANT
size_t uninitialized_buffer<VObject_Size, VN_Objects, VAlignment>::Alignment;
2181 template <
typename T,
size_t VN_Objects>
2182 class uninitialized_buffer_of
2186 typedef T value_type;
2187 typedef T& reference;
2188 typedef const T& const_reference;
2190 typedef const T* const_pointer;
2191 typedef T* iterator;
2192 typedef const T* const_iterator;
2194 static ETL_CONSTANT
size_t Object_Size =
sizeof(T);
2195 static ETL_CONSTANT
size_t N_Objects = VN_Objects;
2199 T& operator [](
int i)
2201 return reinterpret_cast<T*
>(this->raw)[i];
2205 const T& operator [](
int i)
const
2207 return reinterpret_cast<const T*
>(this->raw)[i];
2213 return *
reinterpret_cast<T*
>(raw);
2217 operator const T& ()
const
2219 return *
reinterpret_cast<const T*
>(raw);
2226 return reinterpret_cast<T*
>(raw);
2230 operator const T* ()
const
2232 return reinterpret_cast<const T*
>(raw);
2237 return reinterpret_cast<T*
>(raw);
2240 const T*
begin()
const
2242 return reinterpret_cast<const T*
>(raw);
2247 return reinterpret_cast<T*
>(raw + (
sizeof(T) * N_Objects));
2250 const T*
end()
const
2252 return reinterpret_cast<const T*
>(raw + (
sizeof(T) * N_Objects));
2255#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5) && !defined(ETL_UNINITIALIZED_BUFFER_FORCE_CPP03_IMPLEMENTATION)
2256 alignas(Alignment)
char raw[
sizeof(T) * N_Objects];
2260 char raw[
sizeof(T) * N_Objects];
2261 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
2266 template <
typename T,
size_t VN_Objects>
2267 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Object_Size;
2269 template <
typename T,
size_t VN_Objects>
2270 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::N_Objects;
2272 template <
typename T,
size_t VN_Objects>
2273 ETL_CONSTANT
size_t uninitialized_buffer_of<T, VN_Objects>::Alignment;
2276 template <
typename T,
size_t N_Objects>
2277 using uninitialized_buffer_of_t =
typename uninitialized_buffer_of<T, N_Objects>::buffer;
2288 template <
typename T>
2290 mem_copy(
const T* sb,
const T* se, T* db) ETL_NOEXCEPT
2292 return reinterpret_cast<T*
>(memcpy(
reinterpret_cast<void*
>(db),
2293 reinterpret_cast<const void*
>(sb),
2294 sizeof(
typename etl::iterator_traits<T*>::value_type) *
static_cast<size_t>(se - sb)));
2304 template <
typename T>
2306 mem_copy(
const T* sb,
size_t n, T* db) ETL_NOEXCEPT
2308 return reinterpret_cast<T*
>(memcpy(
reinterpret_cast<void*
>(db),
2309 reinterpret_cast<const void*
>(sb),
2310 sizeof(
typename etl::iterator_traits<T*>::value_type) * n));
2320 template <
typename T>
2322 mem_move(
const T* sb,
const T* se, T* db) ETL_NOEXCEPT
2324 return reinterpret_cast<T*
>(memmove(
reinterpret_cast<void*
>(db),
2325 reinterpret_cast<const void*
>(sb),
2326 sizeof(
typename etl::iterator_traits<T*>::value_type) *
static_cast<size_t>(se - sb)));
2336 template <
typename T>
2338 mem_move(
const T* sb,
size_t n, T* db) ETL_NOEXCEPT
2340 return reinterpret_cast<T*
>(memmove(
reinterpret_cast<void*
>(db),
2341 reinterpret_cast<const void*
>(sb),
2342 sizeof(
typename etl::iterator_traits<T*>::value_type) * n));
2354 template <
typename T>
2357 mem_compare(
const T* sb,
const T* se,
const T* db) ETL_NOEXCEPT
2359 return memcmp(
reinterpret_cast<const void*
>(db),
2360 reinterpret_cast<const void*
>(sb),
2361 sizeof(
typename etl::iterator_traits<T*>::value_type) *
static_cast<size_t>(se - sb));
2373 template <
typename T>
2376 mem_compare(
const T* sb,
size_t n,
const T* db) ETL_NOEXCEPT
2378 return memcmp(
reinterpret_cast<const void*
>(db),
2379 reinterpret_cast<const void*
>(sb),
2380 sizeof(
typename etl::iterator_traits<T*>::value_type) * n);
2390 template <
typename TPo
inter,
typename T>
2392 mem_set(TPointer db,
const TPointer de, T value) ETL_NOEXCEPT
2394 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2395 static_cast<char>(value),
2396 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(de - db)));
2406 template <
typename TPo
inter,
typename T>
2408 mem_set(TPointer db,
size_t n, T value) ETL_NOEXCEPT
2410 return reinterpret_cast<TPointer
>(memset(
reinterpret_cast<void*
>(db),
2411 static_cast<char>(value),
2412 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n));
2422 template <
typename TPo
inter,
typename T>
2425 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2427 void* result = memchr(
reinterpret_cast<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<char*
>(se) : reinterpret_cast<char*>(result);
2441 template <
typename TPo
inter,
typename T>
2444 mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
2446 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2447 static_cast<char>(value),
2448 sizeof(
typename etl::iterator_traits<TPointer>::value_type) *
static_cast<size_t>(se - sb));
2450 return (result == 0U) ?
reinterpret_cast<const char*
>(se) : reinterpret_cast<const char*>(result);
2460 template <
typename TPo
inter,
typename T>
2463 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
2465 void* result = memchr(
reinterpret_cast<void*
>(sb),
2466 static_cast<char>(value),
2467 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2469 return (result == 0U) ?
reinterpret_cast<char*
>(sb + n) : reinterpret_cast<char*>(result);
2479 template <
typename TPo
inter,
typename T>
2482 mem_char(TPointer sb,
size_t n, T value) ETL_NOEXCEPT
2484 const void* result = memchr(
reinterpret_cast<const void*
>(sb),
2485 static_cast<char>(value),
2486 sizeof(
typename etl::iterator_traits<TPointer>::value_type) * n);
2488 return (result == 0U) ?
reinterpret_cast<const char*
>(sb + n) : reinterpret_cast<const char*>(result);
2495 template <
typename TObject>
2496 TObject& construct_object_at(
void* p, TObject&& other)
2498#if ETL_IS_DEBUG_BUILD
2499 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2508 template <
typename TObject,
typename... TArgs>
2509 TObject& construct_object_at(
void* p, TArgs&&... args)
2511#if ETL_IS_DEBUG_BUILD
2512 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2521 template <
typename TObject>
2522 TObject& construct_object_at(
void* p)
2524#if ETL_IS_DEBUG_BUILD
2525 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2534 template <
typename TObject>
2535 TObject& construct_object_at(
void* p,
const TObject& other)
2537#if ETL_IS_DEBUG_BUILD
2538 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2547 template <
typename TObject,
typename TArg>
2548 TObject& construct_object_at(
void* p,
const TArg& arg)
2550#if ETL_IS_DEBUG_BUILD
2551 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2561 template <
typename TObject>
2562 TObject& get_object_at(
void* p)
2564#if ETL_IS_DEBUG_BUILD
2565 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2568 TObject& v = *
reinterpret_cast<TObject*
>(p);
2577 template <
typename TObject>
2578 void destroy_object_at(
void* p)
2580#if ETL_IS_DEBUG_BUILD
2581 ETL_ASSERT(is_aligned<TObject>(p), ETL_ERROR(alignment_error));
2584 TObject& v = get_object_at<TObject>(p);
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
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:848
TOutputIterator uninitialized_value_construct_n(TOutputIterator o_begin, TSize n)
Definition memory.h:920
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:756
T * construct_at(T *p)
Definition memory.h:977
etl::enable_if< etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *)
Definition memory.h:1027
TOutputIterator uninitialized_move_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition memory.h:605
TOutputIterator uninitialized_copy_n(TInputIterator i_begin, TSize n, TOutputIterator o_begin)
Definition memory.h:357
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:1190
TOutputIterator uninitialized_move(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition memory.h:480
TOutputIterator uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
Definition memory.h:237
etl::enable_if< etl::is_trivially_constructible< typenameetl::iterator_traits< TOutputIterator >::value_type >::value, void >::type uninitialized_default_construct(TOutputIterator, TOutputIterator)
Definition memory.h:670
TOutputIterator uninitialized_fill_n(TOutputIterator o_begin, TSize n, const T &value)
Definition memory.h:210
add_rvalue_reference
Definition type_traits_generator.h:1322
conditional
Definition type_traits_generator.h:1155
is_reference
Definition type_traits_generator.h:1106
is_same
Definition type_traits_generator.h:1036
bitset_ext
Definition absolute.h:38
ETL_CONSTEXPR T * to_address(T *p)
Definition memory.h:62
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:1265
pair holds two objects of arbitrary type
Definition utility.h:164