C++ Logo

std-proposals

Advanced search

Re: Templated access to the standard integer types?

From: Eyal Rozenberg <eyalroz_at_[hidden]>
Date: Sun, 2 Jun 2019 18:07:10 +0300
Thank you, John, for the link to Lawrence Crowl's proposal:

On 02/06/2019 12:21, John McFarlane via Std-Proposals wrote:
> wg21.link/p0102

but has it come up in committee sessions? LWG specifically?

>
> to the discussion of it,
>
>

> This comes up from time to time, e.g. earlier this year
> ... snip ...
> I'd like to see the integer family (e.g. `unsigned`, `signed` etc.) as a
> parameter and for this to be a customisation point.

You mean something like this? :

   namespace detail {

   template <typename I, std::size_t NumBits>
   struct resized_integer;

   template <>
   struct resized_integer<int, 8> { using type = int8_t; };
   template <>
   struct resized_integer<int, 16> { using type = int16_t; };
   template <>
   struct resized_integer<unsigned, 8> { using type = uint8_t; };
   template <>
   struct resized_integer<unsigned, 16> { using type = uint16_t; };

   } // namespace detail

   template <typename I, std::size_t NumBits>
   using resized_integer_t =
       typename detail::resized_integer<I, NumBits>::type;

   template <std::size_t NumBits>
   using signed_t = resized_integer_t<int, NumBits>;

   template <std::size_t NumBits>
   using unsigned_t = resized_integer_t<unsigned, NumBits>;


That could be nice. But, again - has the committee discussed it?

Eyal

Received on 2019-06-02 10:09:07