C++ Logo

std-proposals

Advanced search

[std-proposals] template int types

From: Robin Savonen Söderholm <robinsavonensoderholm_at_[hidden]>
Date: Tue, 10 Sep 2024 22:49:33 +0200
I would find something along the lines of the following:
```c++
template <size_t BITS>
using int_bits_t = /*specific int types that exactly BITS number of bits*/;
template <size_t BITS>
using int_least_t = /*the smallest integer type holding at least BITS
number of bits*/;
template <size_t BITS>
using int_fast_t = /*implementation defined but has at least BITS number of
bits, similar approach as the regular std::int_fastN_t;
// and same for uint...
```
. I see reason for this both when defining serializable interfaces and when
working with arithmetic where it could be useful to find an integer that is
at least twice as big as some input. I made my own version of these but it
was a bit cumbersome (especially dealing with `std::int_max_t` that may or
may not be the same as `long long`.

// Robin

Received on 2024-09-10 20:49:45