[PATCH 0/4] Add variant type
Andrew Burgess
aburgess@redhat.com
Fri Feb 4 12:44:31 GMT 2022
* Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2022-02-02 20:32:45 -0500]:
> On 2022-02-02 19:02, Andrew Burgess wrote:
> > * Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2022-02-01 09:07:13 -0500]:
> >
> >> I sometimes encounter situations where I think using std::variant would
> >> be useful. The benefits would be to be able to use non-POD types in the
> >> alternatives, have them automatically constructed when making an
> >> alternative active, and automatically destructing them when switching to
> >> another alternative of destroying the variant. Also, the validation of
> >> access to the alternatives, to prevent accessing an alternative that is
> >> not the current one.
> >>
> >> However, std::variant is only available in C++17. I suggest that we
> >> import a variant implementation to allow us to use it right now, a bit
> >> like we did for optional and string_view. We could maybe import the
> >> implementation from libstdc++, like we did for these last two types, but
> >> that sounds really tedious (we would also want to import any tests).
> >> Instead, we can take advantage of a popular implementation distributed
> >> as a single header file. I chose this one:
> >>
> >> https://github.com/martinmoene/variant-lite
> >>
> >> because it is close to the std implementation, and the license (Boost
> >> Software License) is clear and compatible with the GPL v3.
> >
> > Is this compatible with the copyright assignment requirement of
> > contributing to GDB?
> >
> > I'm assuming copyright of that file is not assigned to FSF.
>
> Exactly, we're merely redistributing it (as its license allows). Its
> header does not say "Copyright FSF" like the other files.
>
> > My concern would be, what if code was copied from that file into the
> > rest of GDB? Does that cause us problems?
>
> Well, we should avoid that :). I see it exactly like zlib, which is also bundled.
OK. Thank you for the explanation.
I took a look through this whole series, and it all looks good to me.
Thanks,
Andrew
More information about the Gdb-patches
mailing list