
22 May
2010
22 May
'10
4:01 p.m.
AMDG Robin wrote:
I'm facing a inconsistent behavior with Variant when bool is defined. The below code will return i as 0
typedef boost::variant <int> VariantType;
VariantType variant; int i = boost::get <int> (variant)); // default to 0
If I set a bool in the variant
typedef boost::variant
VariantType; VariantType variant; int i = boost::get <int> (variant)); // this throws fail get
Is it intended behavior?
Yes. A default constructed variant contains the first variant type, so your variant contains a bool, not an int. In Christ, Steven Watanabe