C++ Logo

std-proposals

Advanced search

Re: Templated access to the standard integer types?

From: John McFarlane <john_at_[hidden]>
Date: Wed, 5 Jun 2019 10:43:01 +0200
On Sun, 2 Jun 2019 at 17:07, Eyal Rozenberg <eyalroz_at_[hidden]> wrote:

> 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?
>

I doubt it. Proposals don't make it to LWG until they are quite far
advanced.

>
> >
> > 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?
>

Something like that, yes. I don't recall any committee discussion on it.

>
> Eyal
>

Received on 2019-06-05 03:44:59