cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / cpp-common / bt2c / std-int.hpp
1 /*
2 * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP
8 #define BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP
9
10 #include <cstdint>
11
12 namespace bt2c {
13 namespace internal {
14
15 template <std::size_t LenBitsV, bool IsSignedV>
16 struct StdIntTBase;
17
18 template <>
19 struct StdIntTBase<8, true>
20 {
21 using Type = std::int8_t;
22 };
23
24 template <>
25 struct StdIntTBase<8, false>
26 {
27 using Type = std::uint8_t;
28 };
29
30 template <>
31 struct StdIntTBase<16, true>
32 {
33 using Type = std::int16_t;
34 };
35
36 template <>
37 struct StdIntTBase<16, false>
38 {
39 using Type = std::uint16_t;
40 };
41
42 template <>
43 struct StdIntTBase<32, true>
44 {
45 using Type = std::int32_t;
46 };
47
48 template <>
49 struct StdIntTBase<32, false>
50 {
51 using Type = std::uint32_t;
52 };
53
54 template <>
55 struct StdIntTBase<64, true>
56 {
57 using Type = std::int64_t;
58 };
59
60 template <>
61 struct 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 */
76 template <std::size_t LenBitsV, bool IsSignedV>
77 using StdIntT = typename internal::StdIntTBase<LenBitsV, IsSignedV>::Type;
78
79 } /* namespace bt2c */
80
81 #endif /* BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP */
This page took 0.030849 seconds and 4 git commands to generate.