Babel
Epitech's C++ VoIP project
Common
Utilities
SwapEndian.hpp
Go to the documentation of this file.
1
//
2
// Created by cbihan on 06/10/2021.
3
//
4
5
#pragma once
6
7
#include <climits>
8
#include <cstdint>
9
10
namespace
Babel
11
{
12
template
<
typename
T>
13
T
swapEndian
(T value)
14
{
15
auto
*lo =
reinterpret_cast<
unsigned
char
*
>
(&value);
16
auto
*hi =
reinterpret_cast<
unsigned
char
*
>
(&value) +
sizeof
(T) - 1;
17
unsigned
char
swap;
18
while
(lo < hi) {
19
swap = *lo;
20
*lo++ = *hi;
21
*hi-- = swap;
22
}
23
24
return
value;
25
}
26
}
Babel
Definition:
IAudioManager.hpp:13
Babel::swapEndian
T swapEndian(T value)
Definition:
SwapEndian.hpp:13
Generated by
1.8.17