Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-20 13:43:27

On 03/10/08 13:16, Larry Evans wrote:
> On 03/10/08 12:08, Eric Niebler wrote:
>> Markus Werle wrote:
>>> Steven Watanabe <watanabesj <at>> writes:
>>>> The definition of expr is something like:
>>>> template<class Tag, class Args, int Arity = Args::arity>
>>>> struct expr;
> [snip]
>>> OK, and what is the advantage of the 3rd template argument Arity then?
>>> AFAICS this is needed for the BOOST_PP_ITERATION magic, but strictly speaking
>>> it is not necessary for the data _representation_, right?
>> You have to partially specialize on *something*. That's what the 3rd
>> template parameter is for. This is not something I can remove. I can't
>> get the design I need without it.
> Couldn't you use a helper template, e.g. expr_arity,
> *with* the third parameter = size<Args>::value and
> then expr_arity is specialized on that last arg?
> OOPS, then you'd be the same place you are now with an
> the 2 arg expr and the 3 arg expr_arity specialized the
> same number of times as the existing 3 arg expr. Since
> there no gain is ability be extra templates, the better
> solution is the existing 3 arg expr with specialization
> on last arg. IOW, I kinda agree with Eric here.

What about recording the arity *with* the tag instead of in
the expression associated with the tag? IOW, instead of:




Why? Well, it directly associates the arity with the Tag instead
of with the expression. After all, sin(X) is not expressed
as sin(x,1). [or in lisp terms, (sin x) is not expressed as
(sin x 1) ].

Boost list run by bdawes at, gregod at, cpdaniel at, john at