1 #ifndef RDESTL_UTILITY_H 2 #define RDESTL_UTILITY_H 4 #include <stk_util/util/rdestl_common.h> 12 void copy_n(
const T* first,
size_t n, T* result, int_to_type<false>)
14 const T* last = first + n;
23 case 3: *result++ = *first++;
24 case 2: *result++ = *first++;
25 case 1: *result++ = *first++;
30 void copy_n(
const T* first,
size_t n, T* result, int_to_type<true>)
32 RDE_ASSERT(result >= first + n || result < first);
33 Sys::MemCpy(result, first, n *
sizeof(T));
37 void copy(
const T* first,
const T* last, T* result, int_to_type<false>)
43 void copy(
const T* first,
const T* last, T* result, int_to_type<true>)
45 const size_t n =
reinterpret_cast<const char*
>(last) - reinterpret_cast<const char*>(first);
46 Sys::MemCpy(result, first, n);
49 template<
typename T> RDE_FORCEINLINE
50 void move_n(
const T* from,
size_t n, T* result, int_to_type<false>)
52 for (
int i =
int(n) - 1; i >= 0; --i)
55 template<
typename T> RDE_FORCEINLINE
56 void move_n(
const T* first,
size_t n, T* result, int_to_type<true>)
58 Sys::MemMove(result, first, n *
sizeof(T));
61 template<
typename T> RDE_FORCEINLINE
62 void move(
const T* first,
const T* last, T* result, int_to_type<false>)
64 while (--last >= first)
67 template<
typename T> RDE_FORCEINLINE
68 void move(
const T* first,
const T* last, T* result, int_to_type<true>)
72 const size_t n =
reinterpret_cast<const char*
>(last) - reinterpret_cast<const char*>(first);
74 Sys::MemMove(result, first, n);
79 void copy_construct_n(
const T* first,
size_t n, T* result, int_to_type<false>)
81 for (
size_t i = 0; i < n; ++i)
82 new (result + i) T(first[i]);
85 void copy_construct_n(
const T* first,
size_t n, T* result, int_to_type<true>)
87 RDE_ASSERT(result >= first + n || result < first);
88 Sys::MemCpy(result, first, n *
sizeof(T));
92 void destruct_n(T* first,
size_t n, int_to_type<false>)
96 for (
size_t i = 0; i < n; ++i)
99 template<
typename T> RDE_FORCEINLINE
100 void destruct_n(T*,
size_t, int_to_type<true>)
106 void destruct(T* mem, int_to_type<false>)
111 template<
typename T> RDE_FORCEINLINE
112 void destruct(T*, int_to_type<true>)
118 void construct(T* mem, int_to_type<false>)
122 template<
typename T> RDE_FORCEINLINE
123 void construct(T*, int_to_type<true>)
128 template<
typename T> RDE_FORCEINLINE
129 void copy_construct(T* mem,
const T& orig, int_to_type<false>)
133 template<
typename T> RDE_FORCEINLINE
134 void copy_construct(T* mem,
const T& orig, int_to_type<true>)
140 void construct_n(T* to,
size_t count, int_to_type<false>)
143 for (
size_t i = 0; i <
count; ++i)
146 template<
typename T>
inline 147 void construct_n(T*,
int, int_to_type<true>)
153 template<
class TIter,
class TPred>
154 void test_ordering(TIter first, TIter last,
const TPred& pred)
162 RDE_ASSERT(pred(*first, *next));
167 sizeof(first);
sizeof(last);
sizeof(pred);
171 template<
typename T1,
typename T2,
class TPred>
inline 172 bool debug_pred(
const TPred& pred,
const T1& a,
const T2& b)
177 RDE_ASSERT(!pred(b, a));
193 #endif // #ifndef RDESTL_UTILITY_H OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
eastl::iterator_traits< InputIterator >::difference_type count(InputIterator first, InputIterator last, const T &value)