Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][Variant] Sequence instantiation
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-08-26 00:32:35


On Tue, Aug 25, 2009 at 10:12 PM, Steven Watanabe<watanabesj_at_[hidden]> wrote:
> AMDG
>
> Ryan McConnehey wrote:
>>
>> I have a sequence of types defined with the Loki library.  I believe the
>> equivalent would be boost::mpl::vector.  The sequence is used to cause
>> compile time asserts for unsupported types being passed to template
>> functions.  Boost variant can be created with a given list of types.
>>
>> typedef boost::variant< int, std::string, short, long > type_list;
>> | <boost/variant.html>|
>> Is it possible to create a variant from a sequence by either passing the
>> sequence or iterating through each value in the sequence?  This would reduce
>> the code duplication of having one sequence for assert checking and the
>> other for variants.
>
> Use the metafunction boost::make_variant_over.

I doubt Boost.Variant is the best choice for this. You say a template
function to enforce types, I would say Boost.Enable_if combined with
Boost.Type_traits and Boost.MPL would make it real easy.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net