mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
BitCast.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <bit>
6
#include <concepts>
7
#include <cstdlib>
8
9
namespace
mini_llvm::ops
{
10
11
template
<
typename
To>
12
struct
BitCast
{
13
template
<
typename
From>
14
To
operator()
(From)
const
noexcept
{
15
abort();
16
}
17
18
template
<
typename
From>
19
requires
(!std::same_as<From, bool> &&
sizeof
(To) ==
sizeof
(From))
20
To
operator
()(From x)
const
noexcept
{
21
return
std::bit_cast<To>(x);
22
}
23
};
24
25
template
<>
26
struct
BitCast
<bool> {
27
template
<
typename
From>
28
bool
operator()
(From)
const
noexcept
{
29
abort();
30
}
31
32
bool
operator()
(
bool
x)
const
noexcept
{
33
return
x;
34
}
35
};
36
37
}
// namespace mini_llvm::ops
mini_llvm::ops
Definition
Add.h:9
mini_llvm::ops::BitCast< bool >::operator()
bool operator()(bool x) const noexcept
Definition
BitCast.h:32
mini_llvm::ops::BitCast< bool >::operator()
bool operator()(From) const noexcept
Definition
BitCast.h:28
mini_llvm::ops::BitCast
Definition
BitCast.h:12
mini_llvm::ops::BitCast::operator()
To operator()(From) const noexcept
Definition
BitCast.h:14
include
mini-llvm
common
ops
BitCast.h
Generated by
1.17.0