Boost logo

Proto :

Subject: Re: [proto] Holding children by copy or reference
From: Eric Niebler (eric_at_[hidden])
Date: 2013-10-01 18:28:42


On 10/1/2013 12:05 AM, Bart Janssens wrote:
> On Tue, Oct 1, 2013 at 12:59 AM, Mathias Gaunard
> <mathias.gaunard_at_[hidden]> wrote:
>> To clarify, in terms of performance, from best-to-worst:
>> 1) everything by reference: no problem with performance (but problematic
>> dangling references in some scenarios)
>> 2) everything by value: no CSE or other optimizations
>> 3) nodes by value, terminals by reference: no CSE or other optimizations +
>> loads when accessing the terminals
>
> Just out of interest: would holding the a*b temporary node by rvalue
> reference be possible and would it be of any help?

Possible in theory, yes. In practice, it probably doesn't work since
proto-v4 is not C++11 aware. But even if it worked, it wouldn't solve
anything. Rvalue refs have the same lifetime issues that (const) lvalue
refs have. The temporary object to which they refer will not outlive the
full expression.

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

Proto list run by eric at boostpro.com