libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
traits.h
1#pragma once
2#include "libmicroemu/types.h"
3
4#include <cstddef>
5#include <cstdint>
6#include <type_traits>
7
8namespace libmicroemu::internal {
9
10template <typename T> struct make_signed_type;
11
12template <> struct make_signed_type<u64> {
13 using type = i64;
14};
15template <> struct make_signed_type<u32> {
16 using type = i32;
17};
18
19template <> struct make_signed_type<u16> {
20 using type = i16;
21};
22
23template <> struct make_signed_type<u8> {
24 using type = i8;
25};
26
27template <typename T> using make_signed_type_t = typename make_signed_type<T>::type;
28
29// ----------------------------------
30
31template <typename T> struct no_of_bits;
32
33template <> struct no_of_bits<u64> {
34 static constexpr u32 N = 64U;
35};
36
37template <> struct no_of_bits<u32> {
38 static constexpr u32 N = 32U;
39};
40
41template <> struct no_of_bits<u16> {
42 static constexpr u16 N = 16U;
43};
44
45template <> struct no_of_bits<u8> {
46 static constexpr u8 N = 8U;
47};
48
49template <typename T> struct next_bigger_type;
50
51template <> struct next_bigger_type<u32> {
52 using type = u64;
53};
54
55template <> struct next_bigger_type<u16> {
56 using type = u32;
57};
58
59template <> struct next_bigger_type<u8> {
60 using type = u16;
61};
62
63// Alias for easy use
64template <typename T> using next_bigger_type_t = typename next_bigger_type<T>::type;
65
66} // namespace libmicroemu::internal
The libmicroemu::internal namespace contains all classes and functions of libmicroemu which are priva...
Definition bkpt_flags.h:6
Definition traits.h:31