mem_func.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef MEM_FUNC_HPP
00013 #define MEM_FUNC_HPP
00014
00015 #include "math_func.hpp"
00016
00024 template <typename T>
00025 static FORCEINLINE void MemCpyT(T *destination, const T *source, size_t num = 1)
00026 {
00027 memcpy(destination, source, num * sizeof(T));
00028 }
00029
00037 template <typename T>
00038 static FORCEINLINE void MemMoveT(T *destination, const T *source, size_t num = 1)
00039 {
00040 memmove(destination, source, num * sizeof(T));
00041 }
00042
00050 template <typename T>
00051 static FORCEINLINE void MemSetT(T *ptr, byte value, size_t num = 1)
00052 {
00053 memset(ptr, value, num * sizeof(T));
00054 }
00055
00064 template <typename T>
00065 static FORCEINLINE int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
00066 {
00067 return memcmp(ptr1, ptr2, num * sizeof(T));
00068 }
00069
00078 template <typename T>
00079 static FORCEINLINE void MemReverseT(T *ptr1, T *ptr2)
00080 {
00081 assert(ptr1 != NULL && ptr2 != NULL);
00082 assert(ptr1 < ptr2);
00083
00084 do {
00085 Swap(*ptr1, *ptr2);
00086 } while (++ptr1 < --ptr2);
00087 }
00088
00095 template <typename T>
00096 static FORCEINLINE void MemReverseT(T *ptr, size_t num)
00097 {
00098 assert(ptr != NULL);
00099
00100 MemReverseT(ptr, ptr + (num - 1));
00101 }
00102
00103 #endif