Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-15 11:10:45


"Peter Dimov" <pdimov_at_[hidden]> writes:

> David Abrahams wrote:
>> "Peter Dimov" <pdimov_at_[hidden]> writes:
>>
>>>>> Or variant_from_sequence<mpl-seq>::type?
>>>>
>>>> OK, sure.
>>>
>>> I take it back. The only correct interface is variant<mpl-seq>,
>>> without the variable-length enhancement.
>>
>> I'm confused about what you mean. Isn't that the one we already have?
>
> We have
>
> variant<T1, T2, ..., Tn>
>
> and
>
> variant<mpl-seq>
>
> There are two problems with it. First, there is a collision when n == 1.
> Second, if I write
>
> template<class Seq> void f( variant<Seq> const & v );
>
> my function will not match all variants.

Hmm, good point. The obvious question "what if you want to match a
variant with only N component types?" yields two obvious answers:

  1. Why would anyone want to do that
  2. enable_if

On the other hand, with an is_variant metafunction you could do

  template<class V>
  enable_if<is_variant<V>,void>::type f( V const & v );

So I guess I'm mildly leaning your way.

> I think that the correct but painful thing to do is to just drop the
> convenience T1..Tn form.

Still?

-- 
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