Embedded Template Library
1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
bit_cast.h
1
#pragma once
2
3
#include "
platform.h
"
4
5
template
<
typename
TDestination,
typename
TSource>
6
typename
etl::enable_if<(
sizeof
(TDestination) ==
sizeof
(TSource)) && etl::is_trivially_copyable<TSource>::value
7
&& etl::is_trivially_copyable<TDestination>::value,
8
TDestination>
::type
9
bit_cast(
const
TSource& source) ETL_NOEXCEPT
10
{
11
TDestination destination;
12
13
memcpy(&destination, &source,
sizeof
(TDestination));
14
15
return
destination;
16
}
17
18
template
<
typename
TDestination,
typename
TSource>
19
ETL_CONSTEXPR
typename
etl::enable_if<(
sizeof
(TDestination) ==
sizeof
(TSource)) && etl::is_trivially_copyable<TSource>::value
20
&& etl::is_trivially_copyable<TDestination>::value,
21
TDestination>
::type
22
bit_cast(
const
TSource& source) ETL_NOEXCEPT
23
{
24
TDestination destination;
25
26
__builtin_memcpy(&destination, &source,
sizeof
(TDestination));
27
28
return
destination;
29
}
type
platform.h
include
etl
experimental
bit_cast.h
Generated on
for Embedded Template Library by
1.17.0