MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / ReverseBytes

Function ReverseBytes

12.08-byteSwap1/main.cpp:19–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17# endif
18
19constexpr auto ReverseBytes(std::integral auto value)
20{
21 return
22 [&]<size_t... I>(std::index_sequence<I...>) -> decltype(value) {
23 return ((((value >> I * 8) & 0xff)
24 << ((8 * sizeof(value)) - ((1 + I) * 8))) |
25 ...);
26 }(std::make_index_sequence<sizeof(value)>{});
27}
28
29template<std::integral T>
30constexpr T ByteSwap(T value)

Callers 1

ByteSwapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected