Boost logo

Boost :

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

>> typedef boost::variant<derived_1, derived_2> variant_type;
>> void f()
>> {
>> variant_type v;
>> v = derived_1();
>> assert(boost::get<base>(&v)); // This will fail.
> You can get the desired behaviour by applying a visitor.

    I know that. I even admitted that in the post (at the end).
    But IMHO it does not change anything. boost::get can be implemented as a
visitor (and in fact is implemented so) but still is provided as a function
for convenience.
    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. Firstly it extends function already present in Boost. Secondly it
provides for variant a feature available in union.

    Adam Badura

Boost list run by bdawes at, gregod at, cpdaniel at, john at