C++ Logo


Advanced search

Templated access to the standard integer types?

From: Eyal Rozenberg <eyalroz_at_[hidden]>
Date: Sun, 2 Jun 2019 10:51:27 +0300
C++ supports, through <cstdint>, exact-width integer types: int8_t,
int16_t, uint8_t, uint16_t, and so on for larger sizes.

In many cases you want to use template parameter(s) to choose from among
these types, i.e. have an int_t<8>, int_t<16>, uint_t<8> and so on.
Boost basically has this, with even more functionality:


Has there been a proposal to add at least an `std::int_t<N>` and
`std::uint_t<N>` type templates to the standard library? Or perhaps a
`std::signed_integer_t<N>`, `std::unsigned_integer_t<N>`, and a
`std::integer<Signedness, N>` ?

If so, can someone link to it, to the discussion of it, and explain
briefly why it was rejected? And if not - what do you think about this


PS - I realize one can propose a bunch of additional related
functionality, e.g. from boost::integer; but this seems to be the most
intuitive / closely-complementary to existing C-library functionality.

Received on 2019-06-02 02:53:16