C++ Logo

std-proposals

Advanced search

Re: [std-proposals] LWG making integers more portable

From: Baruch Burstein <bmburstein_at_[hidden]>
Date: Wed, 18 Feb 2026 12:43:04 +0200
On Mon, Feb 16, 2026 at 12:09 PM Tymi via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> When trying to get the smallest integral type of N bits, we either have to
> ensure N is one of 8, 16, 32 or 64, or trust the implementation to have a
> least/fast type for our width, which is often not the case.
>
> That's why I propose a way to standardise making least width integers and
> fast size integers within the library:
>
> A sample interface
> std::make_least<N> => a signed integer with at least N bits in width
> std::make_fast<N> => a signed integer with at least N bits in width that's
> also the fastest size for the given width
> std::make_uleast<N> => an unsigned integer with at least N bits in width
> std::make_ufast<N> => an unsigned integer with at least N bits in width
> that's also the fastest size for the given width
>
> I'm only concerned about signed/unsigned, but that's ultimately the
> interface design and can/should be changed.
> Cheers,
> Tymi.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals


I did this a long time ago. It may be what you want:
https://gist.github.com/BMBurstein/e5d746ae3d64e6e2c80e22b9ada54c24
The usage is like:

sized_ints<24>::uint_fast_t my_int_1;
sized_ints<32>::int_t my_int_2;

etc...

Received on 2026-02-18 10:43:43