Use of an external variant implementation

Simon Marchi simon.marchi@polymtl.ca
Tue Jun 29 14:36:23 GMT 2021


On 2021-06-23 3:10 p.m., Simon Marchi via Gdb-patches wrote:
> Hi,
> 
> It was suggested a few times that we backport listdcxx's implementation
> of std::variant (available in C++ >= 17), so that we can use it in GDB,
> a bit like we have done for std::string_view and std::optional.  This
> would allow replacing unions with something that can hold non-POD types.
> 
> Could we instead use an existing implementation such as this one?
> 
>   https://github.com/mapbox/variant
> 
> I think it would be wasteful to spend some time writing an
> implementation, when there's already one that seems very well tested and
> documented.
> 
> The only downside I see is that the API doesn't seem to match
> std::variant's API exactly.  For example, the standard version uses
> std::visit, while that version uses an apply_visitor function.  But I am
> pretty sure we would be able to make a little shim so that we are able
> to use the standard version when __cplusplus is >= 2017, and that
> version otherwise.
> 
> The license seems to be BSD, is there a problem with redistributing it
> with GDB?
> 
> The idea would be to copy just the few relevant headers in our repo,
> like we do for readline or other external software.  We could also use
> a submodule, I don't really mind.
> 
> Simon

Ping about this.  I will eventually start writing a proper patch for
this.  But if there is a fundamental problem about this approach, I'd
like to know right away so that I don't waste time on it.

Simon


More information about the Gdb-patches mailing list