|
Boost : |
Subject: Re: [boost] [proto] small breaking change
From: Eric Niebler (eric_at_[hidden])
Date: 2010-06-14 15:53:36
On 6/14/2010 2:10 AM, joel falcou wrote:
> Eric Niebler wrote:
>> Heck, it's simple enough. I just checked in the fix on trunk. Let me
>> know how that works for you.
>>
> OK the base case is working now. I just got a last small problem.
>
> If I try to evaluate :
>
> m = l+k,
> x = x + y;
>
> with the former code given earlier and the latest trunk, the display of
> the evaluation is:
>
<snip>
> Which means that the x = x+y expression is copied and destroyed four
> time despite my "no-eval" policy in the constructor of expr. I assume
> some temporary copy are made which are not captured by my no-eval code
> in nt2::containers::expr.
>
> Did I missed some customization to make subdomain/domain expression be
> captured by reference or should I had some new copy
> constructor/operator= in my expression class in which I have to toggle
> the "no-eval" switch ?
I was mistaken about falling foul of RVO. Here is what is happening. You
have two domains in play, both with different generators. You compose
some expressions in different domains, A and B. Proto decides the
resulting expression R should be in domain B. Proto prefers things to be
nice and uniform, so before making A a child of R, it puts it also into
B's domain by applying B's generator. That causes the extra copy you're
seeing. If A and B had had the same generator, no extra invocation of
the generator would be performed.
Why does Proto put expression A into B's domain? Good question. It just
seemed like the right thing to do when I wrote the code. Right now, that
looks like a dubious decision. Lemme think on it for a bit.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk