Subject: Re: [boost] [xint] Boost.XInt formal review
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-03-07 05:48:51
On 7 Mar 2011, at 06:34, Joel Falcou wrote:
> On 07/03/11 03:25, Peter Dimov wrote:
>> I probably should note that expression templates require CoW, as far as I can see; if you return an expression from a*b instead of computing the product, the expression needs to keep a and b alive. Having it store copies would defeat the purpose. Storing references wouldn't work well in generic code such as a forwarding function. Even something as simple as auto x = f() + y; would be a subtle bug.
> Well , ET based code usually keep references to large terminals. the 'auto'/ET interaction is known and is likely to never occurs.
> And if needed, well, that's what proto::deep_copy is for.
So users of a expression-template based xint would need to know about proto::deep_copy?
Also, I would expect these problems to become more serious in C++0x code, because users will probably write expressions like:
auto i = x + y;
Which would be fine for built-in types, and introduce bugs if x or y was an xint::integer, using proto.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk