Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-11-15 20:25:38

Peter Dimov wrote:

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

Since the thread you're referring to, I've actually changed it to

   variant<T1, T2, ..., Tn>


   make_variant_over< mpl-seq >::type

where the latter produces an unspecified variant<...> of some sort.

> Second, if I write
> template<class Seq> void f( variant<Seq> const & v );
> my function will not match all variants. I think that the correct but
> painful thing to do is to just drop the convenience T1..Tn form.

The approach I currently recommend in the variant documentation is the

   template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
   void f( variant<BOOST_VARIANT_ENUM_PARAMS(T)> const & v );

I don't know if this is to be considered better or worse than

   template <typename V>
     typename enable_if< is_variant<V> >::type
   f( V const & v );

Of course, the latter only works on compilers with SFINAE. So perhaps we
could offer both. I'd have to provide is_variant, though.


Boost list run by bdawes at, gregod at, cpdaniel at, john at