
"David Abrahams" <dave@boost-consulting.com> wrote in message news:uwtwlb7yh.fsf@boost-consulting.com... | "Thorsten Ottosen" <nesotto@cs.auc.dk> writes: | | > "David Abrahams" <dave@boost-consulting.com> wrote in message | > news:u4qjqq4is.fsf@boost-consulting.com... | > | Thorsten Ottosen <nesotto@cs.auc.dk> writes: | > | > | > why can't you store a reference? | > | | > | Because you'd be storing a reference to a temporary, which would have | > | evaporated by the time you get to actually initiate the call. | > | > you must be confusing move-semantics with this situation, or I'm | > missing something. | | You're missing something. | | > there should be no difference between storing a temporary implicitly | > or explicitly...it's still there and still takes up stack-space no | > matter what. | | Yes, but your scheme requires copying that temporary into a new | object, where it is stored again. The proposed library allows a | reference to be bound to the temporary with no copying. And I | seriously doubt there is a compiler in existence today that can elide | that copy, because of the restrictions on where the object must be | stored. ah, yes I see it now. That is indeed a major benefit. Where in the standard are those restriction described? I mean I would have suspected that RVO could be extended to support classes like in this: struct X { Foo f; }; Foo foo(); X x; x.f = foo(); If I change the interface to set_foo( const Foo& r ) { f = r; } instead of a public member, it is slower, but otherwise not AFAICT (see attachment). -Thorsten begin 666 copy.cpp M(VEN8VQU9&4@/'9E8W1O<CX-"B-I;F-L=61E(#QI;W-T<F5A;3X-"@T*#0IS M=&0Z.G9E8W1O<CQI;G0^(&9O;R@I.PT*#0IT96UP;&%T93P@8VQA<W,@5B ^ M#0IL;VYG('!R:6YT*"!C;VYS="!6)B!V("D-"GL-"B @("!L;VYG(&P@/2 P M.PT*(" @( T*(" @(&9O<B@@<VEZ95]T(&D@/2 P.R!I("$]('8N<VEZ92@I M.R K*VD@*0T*(" @(" @("!L("L]('9;:5T[#0H-"B @("!R971U<FX@;#L@ M#0I]#0H-"G1E;7!L871E/"!C;&%S<R!6(#X-"G-T<G5C="!&;V\-"GL-"B @ M("!6('8[#0I].PT*#0HC:6YC;'5D92 \8F]O<W0O<')O9W)E<W,N:'!P/@T* M#0II;G0@;6%I;B@I#0I[#0H@(" @8V]N<W0@:6YT('-Z(#T@,3 P,# [#0H@ M(" @( T*(" @('L-"B @(" @(" @8F]O<W0Z.G!R;V=R97-S7W1I;65R('0[ M#0H-"B @(" @(" @;&]N9R!L(#T@,#L-"B @(" @(" @9F]R*"!I;G0@:2 ] M(# [(&D@(3T@<WH[("LK:2 I#0H@(" @(" @(" @("!L("L]('!R:6YT*"!F M;V\H*2 I.PT*#0H@(" @(" @('-T9#HZ8V]U=" \/"!L(#P\("(@(CL-"B @ M("!]#0H-"B @("![#0H@(" @(" @(&)O;W-T.CIP<F]G<F5S<U]T:6UE<B!T M.PT*#0H@(" @(" @(&QO;F<@;" ](# [#0H-"B @(" @(" @9F]R*"!I;G0@ M:2 ](# [(&D@(3T@<WH[("LK:2 I#0H@(" @(" @('L-"B @(" @(" @(" @ M("\O8V]N<W0@<W1D.CIV96-T;W(\:6YT/B8@=B ](&9O;R@I.PT*(" @(" @ M(" @(" @+R]L("L]('!R:6YT*"!V("D[#0H@(" @(" @(" @("!&;V\\('-T M9#HZ=F5C=&]R/&EN=#X@/B!F.PT*(" @(" @(" @(" @9BYV(#T@9F]O*"D[ M#0H@(" @(" @(" @("!L("L]('!R:6YT*"!F+G8@*3L-"@T*(" @(" @("!] M#0H-"B @(" @(" @<W1D.CIC;W5T(#P\(&P@/#P@(B B.PT*(" @('T-"@T* M?0T*#0IS=&0Z.G9E8W1O<CQI;G0^(&9O;U]I;7!L*"D-"GL-"B @("!C;VYS M="!I;G0@<WH@/2 S,# P.PT*(" @('-T9#HZ=F5C=&]R/&EN=#X@=CL-"B @ M("!F;W(H(&EN="!I(#T@,#L@:2 A/2!S>CL@*RMI("D-"B @(" @(" @=BYP M=7-H7V)A8VLH(&D@*3L-"B @("!R971U<FX@=CL-"GT-"@T*<W1D.CIV96-T M;W(\:6YT/B!F;V\H*0T*>PT*(" @('-T871I8R!S=&0Z.G9E8W1O<CQI;G0^ I('8H(&9O;U]I;7!L*"D@*3L-"B @("!R971U<FX@=CL-"GT-"@T*#0H` ` end