Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: boost varia...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 9504 of 9807
Post > Topic >>

Re: boost variant template type argument count

by Carl Barron <cbarron413@[EMAIL PROTECTED] > Apr 16, 2008 at 04:13 AM

In article
<894696dc-a056-4b9c-b90f-38280a72321c@[EMAIL PROTECTED]
>,
<thant.tessman@[EMAIL PROTECTED]
> wrote:

> I'm using an instance of the boost::variant type as the token value of
> a non-trivial grammar. The type list is 24 items long. Apparently
> there is a type list limit of 20 items. Is this correct? Is  this just
> a matter of building the cases, or is it dictated by some platform
> limit on template type arguments? (Is it actually dictated by the
> apply_visitor template?)
> 
> Thanks for any info. (I briefly wandered around the boost headers, but
> their organization is not transparent to the uninitiated.)
> 
> -thant
    It is defined as BOOST_MPL_LIMIT_LIST_SIZE so if you need more than
20 items, you will need to reconfigure mpl and not use its preprocessed
headers which is the default.  Perhaps you can split the variant into
two variants and have a variant of variants.

can four or more be split off.

typedef boost::variant< T1,T2,T3,T4,T5,...,T12>  varaint_1;
typedef boost::variant<T12,T13,....,T24> variant_2;

typedef boost::variant<variant_1,variant_2>  my_variant;

struct my_visitor:public boost::static_visitor<T>
{
    struct visitor_1:boost::static_visitor<T>
    {
       T operator () (T1 x);
       // handle T1 - T12;
    };

    struct visitor_2:boost::static_visitor<T>
    {
       // handle T13-T24
    };

    T operator () (variant_1 const &x)
    {
       return boost::apply_visitor(visitor_1(),x);
    }
    T operator () (variant_2 const &x)
    {
       return boost::apply_visitor(visitor_2(),x);
    }
};

should be able to visit your 24 types.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 3 Posts in Topic:
boost variant template type argument count
thant.tessman@[EMAIL PROT  2008-04-15 23:43:13 
Re: boost variant template type argument count
Carl Barron <cbarron41  2008-04-16 04:13:20 
Re: boost variant template type argument count
courpron@[EMAIL PROTECTED  2008-04-16 11:33:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 20:09:12 CDT 2008.