$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [Proto] Limiting function arity in grammar
From: Eric Niebler (eric_at_[hidden])
Date: 2008-10-02 16:43:17
Joel Falcou wrote:
> Eric Niebler a écrit :
>> You can use proto::if_ with some mpl meta-functions and 
>> proto::arity_of. See below:
> Ah, I missed that v_v Times to print out the new docs and pin it on my 
> office walls
> 
>> struct ArityLessThan3
>>   : proto::or_<
>>         proto::terminal<_>
>>       , proto::and_<
>>             proto::function< proto::vararg<ArityLessThan3> >
>>           , proto::if_< mpl::less< proto::arity_of<_>, mpl::long_<4> 
>> >() >
>>         >
>>     >
>> {};
> Shouldn't it be : proto::function< _, proto::vararg<ArityLessThan3> >  ?
> or does vararg also count the function tag ?
No, proto::function< proto::vararg<X> > is equivalent to 
proto::nary_expr< proto::tag::function, proto::vararg<X> >.
Note also that we compare to 4 instead of 3 above because Proto 
considers an expression like i(i,i,i) to have arity 4 ... because there 
are four child expressions.
HTH,
-- Eric Niebler BoostPro Computing http://www.boostpro.com