|
Boost : |
From: Eric Friedman (ebf_at_[hidden])
Date: 2003-11-03 18:45:34
Persson Jonas wrote:
>>-----Original Message-----
>>From: Eric Friedman [mailto:ebf_at_[hidden]]
>>Sent: den 31 oktober 2003 22:31
>>To: boost_at_[hidden]
>>Subject: [boost] Re: Variant size bug?
>>
>>Well, technically it's not a bug: variant<> *is*
>>variant<boost::empty>.
>>
>>I agree this may be unexpected, and so should probably be noted more
>>explicitly in the docs.
>>
>>Also, we _can_ argue whether this unexpectedness constitutes a bug in
>>variant's design. (It's certainly not an *implementation* bug though.)
>
>
> Well, I would argue that it is a (design) bug. It breaks the
> typelist <-> variant symmetry, and causes some of the mpl stuff to
> give the wrong result.
Before I comment on this, do you mean the (implementation) bug you
identified elsewhere in this thread?
If so, as I replied to your message, that bug has been fixed.
If not, then I think you'll have to be clearer.
> Is there any reason why the user would want the interface to work
> this way?
Well, yes: variant<> *is* variant<boost::empty>. As it stands currently,
there is no such thing as a variant with no content; the closest
approximation is a variant with boost::empty content.
Thus, visitors to variant<> must handle boost::empty. That
variant<>::types contains boost::empty seems only logical.
Is there any reason you want the interface to work *differently*?
> I use mpl to unroll the types in the variant, so I must have a
> termination condition. As it stands now I cannot use mpl::size or
> mpl::empty for that. How do I check at compile time if the variant
> contains any types or not?
Again, you'll have to be clearer.
Thanks,
Eric
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk