Boost logo

Boost :

Subject: Re: [boost] [variant] Common base type of variant sub-types
From: Adam Badura (abadura_at_[hidden])
Date: 2010-01-09 13:57:23


>> Obviously it would not be wise to provide a function wrapper for each
>> and every visitor. However the extended "get" I proposed is unique in its
>> ways.
>
> But it wouldn't be 'get'.
> There is a reason why it works like this. It's designed to test and
> extract for a specific type in one of the variant possibilities, without
> doing any implicit conversion.
>
> Adding the enhancement you suggest would change the meaning of 'get' and
> potentially break other code.
> So I think it would be best as a separate function.

    Firstly I know it might break existing code (although I don't think it
is likely) and for the second time I dare to remind you that I did mention
that in my original post.
    Secondly it is somewhat subjective what get is. For me it is just asking
variant object for value of specified type and this can succeed with base
type. But again this is subjective so lets leave it. I already mentioned in
my original post that a new function could be used as well.

> Here is a possible implementation:

    I don't need it. In fact I already wrote one myself (although somewhat
longer and more complex as it seems). I want it to be added to Boost.

>> Secondly it provides for variant a feature available in union.
>
> That could only work with unions if the types are binary compatible, which
> isn't necessarily the case.

    Yes. This is not exactly the same. But similar enough and a powerful
feature (if it was not then unions would not have it).

    Adam Badura


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk