Boost logo

Boost Users :

Subject: Re: [Boost-users] [proto] const-ness of references
From: Eric Niebler (eric_at_[hidden])
Date: 2010-03-04 23:01:23


On 3/4/2010 4:21 PM, Manjunath Kudlur wrote:
>> proto::make_expr tries to enforce uniformity in the trees it returns. In
>> particular, it wants all the child nodes to be in the same domain as the
>> parent node it returns. When the domains don't match (as they don't in this
>> case because int32_ is in the default_domain), it passes the child through
>> the domain's generator.
>
> I follow you up to here.
>
>> The result gets stored by value instead of by
>> reference as you're requesting.
>
> I lost you here. In my case, I pass program_() and boost::ref(a0) as
> children to make_expr. My generator would match otherwise(_) rule (I
> don't have it in the program I sent, but suppose I add it to
> program_generator). So the result is the expression unmodified, no?
> What gets stored by value, where, like you say?

Well, your domain's generator is a little unusual in that not all the
expressions it generates are, in fact, within your domain. That's not a
stated post-condition of the Generator parameter, but it probably should
be. In short, make_expr is assuming that the generator is returning a
new object, and so it is storing it by value.

I could hack Proto to make this case work, but doing so makes me
uncomfortable. I don't think I want to support generators that don't
return expressions in the right domain.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net