From: Eric Niebler (eric_at_[hidden])
Date: 2008-03-22 23:06:47
Larry Evans wrote:
> On 03/20/08 20:17, Eric Niebler wrote:
>> Larry Evans wrote:
>>> However, I'd imagine some people would want
>>> this restricted to just two elements, which could be
>>> done with something like:
>>> And now, if size<Args>::value is
>>> restricted to the Arity in
>>> tag_arity<shift_right,Arity> then it
>>> would be restricted to 2.
>> Users may very well want to restrict tag::plus to arity 2 *in their
>> domain*, but they shouldn't be foisting that decision on other
>> consumers of Proto.
> Good point. I agree. then just define:
> template<class Tag,int Arity,class Domain=default_domain>
> which has no restrictions on arity, but it allow the user to
> specify restrictions by specializaing on Domain.
Proto provides this functionality, but in a different way. When defining
your domain, you can specify the grammar to which all expressions within
that domain must conform. If you do that, Proto will ensure that only
expressions that conform to your grammar are created. It does this by
disabling (via SFINAE) the operator overloads that would create
>> The best way to ensure that expressions have the arity you expect is
>> to encode that in the grammar for your domain, and check it with
> Like in the attached?
You got it.
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk