cpp-common: add GCharUP
[babeltrace.git] / src / cpp-common / std-int.hpp
CommitLineData
2f1bfb2a
PP
1/*
2 * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef BABELTRACE_CPP_COMMON_STD_INT_HPP
8#define BABELTRACE_CPP_COMMON_STD_INT_HPP
9
10#include <cstdint>
11
12namespace bt2_common {
13namespace internal {
14
15template <std::size_t LenBitsV, bool IsSignedV>
16struct StdIntTBase;
17
18template <>
19struct StdIntTBase<8, true>
20{
21 using Type = std::int8_t;
22};
23
24template <>
25struct StdIntTBase<8, false>
26{
27 using Type = std::uint8_t;
28};
29
30template <>
31struct StdIntTBase<16, true>
32{
33 using Type = std::int16_t;
34};
35
36template <>
37struct StdIntTBase<16, false>
38{
39 using Type = std::uint16_t;
40};
41
42template <>
43struct StdIntTBase<32, true>
44{
45 using Type = std::int32_t;
46};
47
48template <>
49struct StdIntTBase<32, false>
50{
51 using Type = std::uint32_t;
52};
53
54template <>
55struct StdIntTBase<64, true>
56{
57 using Type = std::int64_t;
58};
59
60template <>
61struct StdIntTBase<64, false>
62{
63 using Type = std::uint64_t;
64};
65
66} /* namespace internal */
67
68/*
69 * Standard fixed-length integer type `Type` of length `LenBitsV` bits
70 * and signedness `IsSignedV`.
71 *
72 * `LenBitsV` must be one of 8, 16, 32, or 64.
73 *
74 * For example, `StdIntT<32, true>` is `std::int32_t`.
75 */
76template <std::size_t LenBitsV, bool IsSignedV>
77using StdIntT = typename internal::StdIntTBase<LenBitsV, IsSignedV>::Type;
78
79} /* namespace bt2_common */
80
81#endif /* BABELTRACE_CPP_COMMON_STD_INT_HPP */
This page took 0.025113 seconds and 4 git commands to generate.