Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-10-31 16:30:30


David Abrahams wrote:
> Brian McNamara <lorgon_at_[hidden]> writes:
>
>
>>On Thu, Oct 30, 2003 at 02:18:11PM -1000, David Abrahams wrote:
>>
>>>Persson Jonas <jonas.persson_at_[hidden]> writes:
>>>
>>>>int main() {
>>>> typedef boost::variant<> Var0;
>>>> int s0 = boost::mpl::size<Var0::types>::type::value;
>>
>>...
>>
>>>>}
>>>>
>>>>>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.
>>
>>Looking closely, I don't think this is the issue.
>>The number he is printing is the compile-time-constant
>>length-of-list-of-types, and not the sizeof() any object, right?
>
>
> Oh, right.
>
>
>>You can have a zero-length MPL sequence, yes?
>
>
> Yep.
>
> 's a 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.)

Eric


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