内存以字节为单位进行逆序, 可用于大小端的转换

#include <math.h>
#include <string>

template <typename T>
void ReverseOrder(T *_pStr, size_t _iSize)
{
    unsigned char *pcPoint = (unsigned char*)_pStr;
    int iCount = floor(_iSize / 2);
    for (int i = 0; i < iCount; i++)
    {
        std::swap(*(pcPoint + i), *(pcPoint + _iSize - 1 - i));
    }
}
相关文章
相关标签/搜索