MCPcopy Create free account
hub / github.com/comaps/comaps / ReverseByteOrder

Function ReverseByteOrder

libs/coding/endianness.hpp:27–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <typename T>
27T ReverseByteOrder(T t)
28{
29 static_assert(std::is_integral<T>::value, "Only integral types are supported.");
30
31 T res;
32 char const * a = reinterpret_cast<char const *>(&t);
33 char * b = reinterpret_cast<char *>(&res);
34 for (size_t i = 0; i < sizeof(T); ++i)
35 b[i] = a[sizeof(T) - 1 - i];
36 return res;
37}
38
39template <typename T>
40T SwapIfBigEndianMacroBased(T t)

Callers 10

GetHeightRCMethod · 0.85
UNIT_TESTFunction · 0.85
operator()Method · 0.85
ReverseMapVisitorClass · 0.85
operator()Method · 0.85
UNIT_TESTFunction · 0.85
DecodeHeaderMethod · 0.85
InitHeaderMethod · 0.85

Calls

no outgoing calls

Tested by 2

UNIT_TESTFunction · 0.68
UNIT_TESTFunction · 0.68