Boost logo

Boost :

Subject: Re: [boost] [xint] Third release is ready, requesting preliminary review
From: DE (satan66613_at_[hidden])
Date: 2010-05-04 11:49:48


on 04.05.2010 at 19:36
 Stewart, Robert wrote :

> DE wrote:
>> i don't understand how is that different to
>>
>> X operator- (const X &x)
>> {
>> X ret(x);
>> //modify 'ret'
>> return ret;
>> }

> As the article states, the compiler can elide the copy in various
> cases. With your version, the copy is unconditional.

now i'm confused
will the copy be elided in this case?

>> what about idiomatic
>>
>> return X().swap(x); //x is modified

> That incurs the default constructor overhead, whatever that may be,
> before the swap.
i see

> That also requires that the function argument be a
> reference to non-const X and the caller would be justifiably surprised at the effect.
of course
or 'x' being an argument passed by value

but what about copy elision?

-- 
Pavel
P.S.
if you notice a grammar mistake or weird phrasing in my message
please point it out

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk