Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-30 19:18:11


Persson Jonas <jonas.persson_at_[hidden]> writes:

> Hello,
> I just started experimenting with variant and ran into the following unexpected behaviour:
>
> int main() {
> typedef boost::variant<> Var0;
> typedef boost::variant<int> Var1;
> typedef boost::variant<int,float> Var2;
> typedef boost::variant<int,float,bool> Var3;
> int s0 = boost::mpl::size<Var0::types>::type::value;
> int s1 = boost::mpl::size<Var1::types>::type::value;
> int s2 = boost::mpl::size<Var2::types>::type::value;
> int s3 = boost::mpl::size<Var3::types>::type::value;
> std::cout << s0 << ',' << s1 << ',' << s2 << ',' << s3 << std::endl;
> }
>
>>From this I expected the output:
> 0,1,2,3
>
> but I got:
> 1,1,2,3

Well that's about as good as anyone could want, since there are no
zero-sized types.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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