MemViz
v1.0.0
C++ Memory Layout Inspector
Loading...
Searching...
No Matches
BitCaster.hpp
Go to the documentation of this file.
1
#include <bit>
2
#include <iostream>
3
#include <type_traits>
4
5
namespace
memviz
{
41
template
<
typename
To,
typename
From>
42
void
castAndPrint
(From from) {
43
static_assert
(std::is_trivially_copyable_v<From>,
"From must be trivially copyable"
);
44
static_assert
(std::is_trivially_copyable_v<To>,
"To must be trivially copyable"
);
45
static_assert
(
sizeof
(To) ==
sizeof
(From));
46
47
std::cout<< std::bit_cast<To>(from) <<std::endl;
48
}
49
}
memviz
Definition
BitCaster.hpp:5
memviz::castAndPrint
void castAndPrint(From from)
Bitwise casts an object to another type and prints the result.
Definition
BitCaster.hpp:42
include
memviz
lib
BitCaster.hpp
Generated by
1.9.8