Topic: Copy elision in rvalue-ref-qualified member functions
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 4 Jan 2014 04:48:41 -0800 (PST)
Raw View
------=_Part_731_3407361.1388839721092
Content-Type: text/plain; charset=ISO-8859-1
In the following cases it is natural to allow copy elision to take place:
class A
{
double *v;
std::size_t n;
public:
. . .
A operator+(A x) const &
{
for (std::size_t i = 0; i < n; i++)
{
x.v[i] += v[i];
}
return x; // copy elision will take place here
}
A operator+(const A& x) && // rvalue-ref-qualified
{
for (std::size_t i = 0; i < n; i++)
{
v[i] += x.v[i];
}
return std::move(*this); // At present, std::move is required here
in order to get the desired affect
}
.. . .
};
The proposal can be accessed through the following link:
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_731_3407361.1388839721092
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>In the following cases it is natural to allow copy el=
ision to take place:</div><div> </div><div>class A<br>{<br>  =
; double *v;<br> std::size_t n; <=
br> <br> <br>public:<br> . . .<br> A opera=
tor+(A x) const &<br> {<br> &n=
bsp; for (std::size_t i =3D 0; i < n; i++)<br> &n=
bsp; {<br>  =
; x.v[i] +=3D v[i];<br> &nbs=
p; }<br> return x; //=
copy elision will take place here<br> }<br> <br>&nb=
sp; <font color=3D"#0000ff">A operator+(const A& x) &&a=
mp; // rvalue-ref-qualified<br> { =
<br> for (std:=
:size_t i =3D 0; i < n; i++)<br> &nbs=
p; {<br> &=
nbsp; v[i] +=3D x.v[i];<br> }<br>=
return std::move(*this); // At p=
resent, std::move is required here in order to get the desired affect<br>&n=
bsp; }</font><br>. . .<br>};</div><div> </div><div>The pro=
posal can be accessed through the following link:</div><div><a href=3D"http=
s://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</a></div><div> </div><div> </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_731_3407361.1388839721092--
.