Boost logo

Boost Users :

From: Hicham Mouline (hicham_at_[hidden])
Date: 2008-05-31 14:39:34


>AMDG
>>Hicham Mouline wrote:
>>
>> Question1: is the maximum number of variant<> arguments extendable?
>>
>The easiest way is to use make_variant_over which takes an MPL sequence.

It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES.
This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and
win-i386-vs2005- boost-1.35.0)

on both platforms,

#include <iostream>
#include <boost/mpl/vector.hpp>
#include <boost/variant.hpp>

class type0 {};
class type1 {};
class type2 {};
class type3 {};
class type4 {};
class type5 {};
class type6 {};
class type7 {};
class type8 {};
class type9 {};
class type10 {};
class type11 {};
class type12 {};
class type13 {};
class type14 {};
class type15 {};
class type16 {};
class type17 {};
class type18 {};
class type19 {};

int main()
{
        typedef boost::mpl::vector<
                int,
                type0,
                type1,
                type2,
                type3,
                type4,
                type5,
                type6,
                type7,
                type8,
                type9,
                type10,
                type11,
                type12,
                type13,
                type14,
                type15,
                type16,
                type17,
                type18
>
        types; // vector with 20 types, builds ok.

        boost::make_variant_over<types>::type v = 5;

        std::cout<< boost::get<int>(v) <<std::endl;
}

If I add type19, making the mpc vector have 21 types, compilation fails...

Rds,


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