Boost logo

Boost Users :

Subject: Re: [Boost-users] Inconsistent with variant with bool
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-05-22 12:03:21


On 05/22/10 10:54, Robin wrote:
[snip]
>
> typedef boost::variant <bool, int> VariantType;
>
> VariantType variant;
> int i = boost::get <int> (variant)); // this throws fail get
>
> Is it intended behavior?
>
> Robin
The default value of the variant is the 1st bound type, which in case of:

   variant<bool,int>

is bool. Hence, when you try to retrieve an int with get<int>(variant),
it throws, as expected.

-Larry


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net