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 3 of 3 Topic 9504 of 9831
Post > Topic >>

Re: boost variant template type argument count

by courpron@[EMAIL PROTECTED] Apr 16, 2008 at 11:33 AM

On Apr 16, 7:43 am, thant.tess...@[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?

Yes, the limit is 20 by default. Look at "boost/variant/
variant_fwd.hpp" and search for the macro BOOST_VARIANT_LIMIT_TYPES
which defines this limit. See also the macro
BOOST_VARIANT_VISITATION_UNROLLING_LIMIT  in "boost/variant/detail/
visitation_impl.hpp", which defines the limit specifically for the
visitation mechanism (also 20 by default).

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


20 is an arbitrary choice that had to be made for putting a max limit
on :

- the number of template arguments a variant can handle, since C++
doesn't sup****t variadic templates yet.

- the number of cases in the switch-case statement of the
apply_visitor function. Note that, no matter the actual number of
types given when instantiating a variant, that switch-case will always
have the maximal number of cases (20 cases or, more accurately
BOOST_VARIANT_VISITATION_UNROLLING_LIMIT cases) , which is a pity
since there are techniques to adapt the number of cases depending on
the number of template arguments.

Alexandre Courpron.




-- 
      [ 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 26 2:42:20 CDT 2008.