Comms CCF
This is a simple communication layer based on COBS, CBOR and FNV-1A
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1
11
#pragma once
12
13
#include <stddef.h>
14
#include <stdint.h>
15
16
#include <bit>
17
18
template
<
size_t
N>
19
struct
Uint
{};
20
template
<>
struct
Uint
<8> {
using
Type = uint8_t; };;
21
template
<>
struct
Uint
<16> {
using
Type = uint16_t; };;
22
template
<>
struct
Uint
<32> {
using
Type = uint32_t; };;
23
template
<>
struct
Uint
<64> {
using
Type = uint64_t; };;
24
template
<
size_t
N>
using
UintT =
Uint<N>::Type
;
25
26
template
<
size_t
I>
27
struct
SmallestType
28
{
29
static
constexpr
unsigned
_bits = std::bit_width(I);
30
static
constexpr
unsigned
_bytes = (_bits + 7) / 8;
31
static
constexpr
unsigned
N = std::bit_ceil(_bytes);
32
using
Type =
Uint<N>
;
33
};
34
template
<
size_t
I>
using
SmallestTypeT = SmallestType<I>::Type;
SmallestType
Definition
types.hpp:28
Uint
Definition
types.hpp:19
comms-ccf
types.hpp
Generated by
1.14.0