MCPcopy Create free account
hub / github.com/apache/singa / byteSwap

Function byteSwap

include/singa/io/integer.h:34–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33template <typename T>
34static inline T byteSwap(const T& v) {
35 int size = sizeof(v);
36 T ret;
37 uint8_t *dest = reinterpret_cast<uint8_t *>(&ret);
38 uint8_t *src = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(&v));
39 for (int i = 0; i < size; ++i) {
40 dest[i] = src[size - i - 1];
41 }
42 return ret;
43}
44
45template <typename T>
46static inline T hton(const T& v)

Callers 1

htonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected