2 * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP
8 #define BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP
15 * Whether or not an integer is signed.
25 template <std::size_t LenBitsV, Signedness SignednessV>
29 struct StdIntTBase<8, Signedness::Signed>
31 using Type = std::int8_t;
35 struct StdIntTBase<8, Signedness::Unsigned>
37 using Type = std::uint8_t;
41 struct StdIntTBase<16, Signedness::Signed>
43 using Type = std::int16_t;
47 struct StdIntTBase<16, Signedness::Unsigned>
49 using Type = std::uint16_t;
53 struct StdIntTBase<32, Signedness::Signed>
55 using Type = std::int32_t;
59 struct StdIntTBase<32, Signedness::Unsigned>
61 using Type = std::uint32_t;
65 struct StdIntTBase<64, Signedness::Signed>
67 using Type = std::int64_t;
71 struct StdIntTBase<64, Signedness::Unsigned>
73 using Type = std::uint64_t;
76 } /* namespace internal */
79 * Standard fixed-length integer type `Type` of length `LenBitsV` bits
80 * and signedness `SignednessV`.
82 * `LenBitsV` must be one of 8, 16, 32, or 64.
84 * For example, `StdIntT<32, Signedness::Signed>` is `std::int32_t`.
86 template <std::size_t LenBitsV, Signedness SignednessV>
87 using StdIntT = typename internal::StdIntTBase<LenBitsV, SignednessV>::Type;
89 } /* namespace bt2c */
91 #endif /* BABELTRACE_CPP_COMMON_BT2C_STD_INT_HPP */