This is the mail archive of the
mailing list for the libstdc++ project.
Re: [v3 PATCH] PR libstdc++/87619
- From: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 17 Oct 2018 12:20:18 +0300
- Subject: Re: [v3 PATCH] PR libstdc++/87619
- References: <CAFk2RUYRRCtoFro2zZzt7YXg4Z02=-+kCzPqTaRywYVDwcu0rQ@mail.gmail.com> <20181017090740.GW23172@redhat.com>
On Wed, 17 Oct 2018 at 12:07, Jonathan Wakely <firstname.lastname@example.org> wrote:
> It might be worth also calling f<256>() and doing:
> template <std::size_t... Is>
> void f_impl(std::index_sequence<Is...> is)
> using V = std::variant<S<Is>...>;
> // For a variant of 255 alternatives the valid indices are [0,254]
> // and index 255 means valueless-by-exception, so fits in one byte.
> if constexpr (std::variant_size_v<V> <= 255)
> static_assert(sizeof(V) == 2)
> static_assert(sizeof(V) > 2)
> Just to check we don't introduce an off-by-one error in the *other*
> direction in future. What do you think?
Agreed. I'll patch that in.
> To be really portable we would use numeric_limits<unsigned char>::max()
> but we don't need to worry about non-8-bit char in our implementation.
I can change that as well so that we don't need to re-think it every time.