Topic: Proposal: Copy elision in rvalue-ref-qualified
Author: Marc <marc.glisse@gmail.com>
Date: Sun, 5 Jan 2014 02:43:16 -0800 (PST)
Raw View
------=_Part_923_499940.1388918596454
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Le samedi 4 janvier 2014 16:56:59 UTC+1, Mikhail Semenov a =E9crit :
>
> This proposal can be accessed through the following link:=20
>
> *https://dl.dropboxusercontent.com/u/35715999/copy_elision_for_r_value_qu=
alified_members.htm*<https://dl.dropboxusercontent.com/u/35715999/copy_elis=
ion_for_r_value_qualified_members.htm>
>
Note that what you are discussing here is not copy elision (paragraph 31,=
=20
the call to copy/move is removed) but implicit move (paragraph 32, copy is=
=20
replaced with move).=20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_923_499940.1388918596454
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Le samedi 4 janvier 2014 16:56:59 UTC+1, Mikhail Semenov a=
=E9crit :<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
"><p>This proposal can be accessed through the following link: </p>
<div><a href=3D"https://dl.dropboxusercontent.com/u/35715999/copy_elision_f=
or_r_value_qualified_members.htm" target=3D"_blank" onmousedown=3D"this.hre=
f=3D'https://www.google.com/url?q\75https%3A%2F%2Fdl.dropboxusercontent.com=
%2Fu%2F35715999%2Fcopy_elision_for_r_value_qualified_members.htm\46sa\75D\4=
6sntz\0751\46usg\75AFQjCNHazxh1EhnflBbFqlpJPeuiVbyBFw';return true;" onclic=
k=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fdl.dropboxus=
ercontent.com%2Fu%2F35715999%2Fcopy_elision_for_r_value_qualified_members.h=
tm\46sa\75D\46sntz\0751\46usg\75AFQjCNHazxh1EhnflBbFqlpJPeuiVbyBFw';return =
true;"><u><font color=3D"#0000ff">https://dl.dropboxusercontent.<wbr>com/u/=
35715999/copy_elision_<wbr>for_r_value_qualified_members.<wbr>htm</font></u=
></a></div></div></blockquote><div><br>Note that what you are discussing he=
re is not copy elision (paragraph 31, the call to copy/move is removed) but=
implicit move (paragraph 32, copy is replaced with move). <br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_923_499940.1388918596454--
.
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sun, 5 Jan 2014 05:25:20 -0800 (PST)
Raw View
------=_Part_2_6741835.1388928320256
Content-Type: text/plain; charset=ISO-8859-1
> >Note that what you are discussing here is not copy elision (paragraph 31,
> the call to copy/move is removed) but implicit move (paragraph 32, copy is
> replaced with move).
>
(1) If a function returns the whole object A in the example,
it can be elaborated.
If no move constructor is defined and say there is the following
constructor (for the sake of illustration):
*A(const std::vector<double>& v); *
we may write:
A z = A({1.1, 2.0, 3.5)} + y;
The point is that copy elision should be be allowed here: object A({1.1,
2.0, 3.5}) will be constructed directly in place of z.
Paragraph 32 states that if only move constructor is defined then it will
be used instead of copy and the elision may take place.
The bottom line is that I meant elision. But to achieve the same effect, I
had to use move to illustrate the point.
My understanding is that from a user point of view, there is little
difference between copy elision and move, although it is a good feature
that even when
the move constructor is not defined copy elision will take place.
(2) On the other hand, if a function returns a member:
class P
{
S r;
....
public:
P();
...
S f() &&
{
. . .
return a.r;
}
}
S w = P().f();
In this case, you are probably right, the desired effect can be achieved
only if the *move *constructor for S is defined.
I have updated the document:
*https://dl.dropboxusercontent.com/u/35715999/copy_elision_for_r_value_qualified_members.htm*<https://dl.dropboxusercontent.com/u/35715999/copy_elision_for_r_value_qualified_members.htm>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2_6741835.1388928320256
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div> </div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(20=
4, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir=
=3D"ltr"><div>>Note that what you are discussing here is not copy elisio=
n (paragraph 31, the call to copy/move is removed) but implicit move (parag=
raph 32, copy is replaced with move). <br></div></div></blockquote><div>&nb=
sp;</div><div>(1) If a function returns the whole object A in the exam=
ple,</div><div>it can be elaborated.</div><div> </div><div>If no move =
constructor is defined and say there is the following constructor (for the =
sake of illustration):</div><div><strong>A(const std::vector<double>&=
amp; v); </strong></div><div> </div><div>we may write:</div><div> =
;</div><div>A z =3D A({1.1, 2.0, 3.5)} + y;</div><div> </div><div>The =
point is that copy elision should be be allowed here: object A({1=
..1, 2.0, 3.5}) will be constructed directly in place of z.</div><div> =
</div><div>Paragraph 32 states that if only move constructor is defined the=
n it will be used instead of copy and the elision may take place.</div><div=
> </div><div>The bottom line is that I meant elision. But t=
o achieve the same effect, I had to use move to illustrate the point. </div=
><div> </div><div>My understanding is that from a user point of view, =
there is little difference between copy elision and move, although it is a =
good feature that even when </div><div>the move constructor is not defined =
copy elision will take place.</div><div> </div><div>(2) On the other h=
and, if a function returns a member:</div><div> </div><div>class P</di=
v><div>{</div><div> S r;</div><div>...</div><div>pu=
blic:</div><div> P();</div><div> &=
nbsp; ...<div> S f() &&</div><div> &nb=
sp; {</div><div> . . .</div><div>=
return a.r;</div><di=
v> }</div></div><div>}</div><div> </div><div>S=
w =3D P().f();</div><div><font color=3D"#0000ff"></font> </div><=
div>In this case, you are probably right, the desired effect can be ac=
hieved only if the <font color=3D"#0000ff"><strong>move </strong></font><fo=
nt color=3D"#000000">constructor</font> for S is defined. </div><div> =
</div><div>I have updated the document:</div><div><a onmousedown=3D"this.hr=
ef=3D'https://www.google.com/url?q\75https%3A%2F%2Fdl.dropboxusercontent.co=
m%2Fu%2F35715999%2Fcopy_elision_for_r_value_qualified_members.htm\46sa\75D\=
46sntz\0751\46usg\75AFQjCNHazxh1EhnflBbFqlpJPeuiVbyBFw';return true;" oncli=
ck=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fdl.dropboxu=
sercontent.com%2Fu%2F35715999%2Fcopy_elision_for_r_value_qualified_members.=
htm\46sa\75D\46sntz\0751\46usg\75AFQjCNHazxh1EhnflBbFqlpJPeuiVbyBFw';return=
true;" href=3D"https://dl.dropboxusercontent.com/u/35715999/copy_elision_f=
or_r_value_qualified_members.htm" target=3D"_blank"><u><font color=3D"#0000=
ff">https://dl.dropboxusercontent.<wbr>com/u/35715999/copy_elision_<wbr>for=
_r_value_qualified_members.<wbr>htm</font></u></a></div><div> </div><d=
iv> </div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2_6741835.1388928320256--
.