
On 03/20/08 19:11, Eric Niebler wrote:
Larry Evans wrote:
On 03/20/08 18:10, Eric Niebler wrote:
Tags don't have arities, expressions do. The arity of tag::function could be anything. The arity represents the number of children of an expression node. So the arity is a very real part of an expression.
So:
expr<tag::shift_right, Args, 20>
is a valid expression?
If Args has 20 elements in it, sure.
Fair enough. That's a lotta freedom. That also allows: expr<tag::shift_right, Args, 0> I guess. However, I'd imagine some people would want this restricted to just two elements, which could be done with something like: template<class Tag,int Arity> struct tag_arity { private: tag_arity(void) ; void operator=(tag_arity const&) ; }; struct shift_right; template<> struct tag_arity<shift_right,2> { public: tag_arity(void) {} void operator=(tag_arity const&) {} }; tag_arity<shift_right,2> tag_shift_right_2; tag_arity<shift_right,1> tag_shift_right_1;//fails compile And now, if size<Args>::value is restricted to the Arity in tag_arity<shift_right,Arity> then it would be restricted to 2. Now to handle the case of function, just do: struct function; template<int Arity> struct tag_arity<function,Arity> { public: tag_arity(void) {} void operator=(tag_arity const&) {} }; So anything with function will allow any int value for size<Args>::value.