On 9/30/2013 11:08 AM, Mathias Gaunard wrote: > On 30/09/13 08:01, Eric Niebler wrote: > >>> Therefore, to avoid performance issues, I'm considering moving to always >>> using references (with the default domain behaviour), and relying on >>> BOOST_FORCEINLINE to make it work as expected. >> >> Why is FORCEINLINE needed? > > The scenario is > > terminal a, b, c, r; > > auto tmp = a*b*c; > r = tmp + tmp; > > Assuming everything is held by reference, when used in r, tmp will refer > to a dangling reference (the a*b node). > > If everything is inlined, the problem may be avoided because it doesn't > require things to be present on the stack.
Yikes! You don't need me to tell you that's UB, and you really shouldn't encourage people to do that. You can independently control how intermediate nodes are captured, as opposed to how terminals are captured. In this case, you want a,b,c held by reference, and the temporary "a*b" to be held by value. Have you tried this, and still found it to be slow? -- Eric Niebler BoostPro Computing http://www.boostpro.com _______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto