Boost logo

Boost :

Subject: Re: [boost] [variant] Common base type of variant sub-types
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-01-09 01:15:41


Adam Badura wrote:

> 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.


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