|
|
|
@ -65,37 +65,4 @@ static inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
|
|
|
|
|
return memcmp(ptr1, ptr2, num * sizeof(T));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Type safe memory reverse operation.
|
|
|
|
|
* Reverse a block of memory in steps given by the
|
|
|
|
|
* type of the pointers.
|
|
|
|
|
*
|
|
|
|
|
* @param ptr1 Start-pointer to the block of memory.
|
|
|
|
|
* @param ptr2 End-pointer to the block of memory.
|
|
|
|
|
*/
|
|
|
|
|
template <typename T>
|
|
|
|
|
static inline void MemReverseT(T *ptr1, T *ptr2)
|
|
|
|
|
{
|
|
|
|
|
assert(ptr1 != nullptr && ptr2 != nullptr);
|
|
|
|
|
assert(ptr1 < ptr2);
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
Swap(*ptr1, *ptr2);
|
|
|
|
|
} while (++ptr1 < --ptr2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Type safe memory reverse operation (overloaded)
|
|
|
|
|
*
|
|
|
|
|
* @param ptr Pointer to the block of memory.
|
|
|
|
|
* @param num The number of items we want to reverse.
|
|
|
|
|
*/
|
|
|
|
|
template <typename T>
|
|
|
|
|
static inline void MemReverseT(T *ptr, size_t num)
|
|
|
|
|
{
|
|
|
|
|
assert(ptr != nullptr);
|
|
|
|
|
|
|
|
|
|
MemReverseT(ptr, ptr + (num - 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* MEM_FUNC_HPP */
|
|
|
|
|