Topic: Earlier creation of function return-value.


Author: sasho648 <sasho648@mail.bg>
Date: Sun, 7 Dec 2014 13:22:21 -0800 (PST)
Raw View
------=_Part_3598_1034102090.1417987341735
Content-Type: multipart/alternative;
 boundary="----=_Part_3599_568671459.1417987341735"

------=_Part_3599_568671459.1417987341735
Content-Type: text/plain; charset=UTF-8

I thought it would be a good idea to implement a language solution of the
return by value additional temporary creation which is optimized by
most-compilers but - you know it's better to make their life easier and
also fix the problem in those where the optimization isn't done at all.
What I mean is this:

struct SomeData { int a, int b, int c };


SomeData FuncRetSomeData()

{
    SomeData tmp; //creation of additional unneeded temporary



    //store some data in 'tmp'



    return tmp; //now second return object is created in the calling stack
with data copied from 'tmp'

}


Most compilers will optimize this code and never create the local 'tmp' but
instead store the data supposed to be held in it, directly in the return
temporary. I suggest creating an old-code compatible new syntax for
allowing similar behavior to be done explicitly by using '(return)' as an
alias to the return value temporary which will be created at function
beginning. Also an initialization syntax for the '(return)' will be
supported like when initializing a class members (if it was named
'return'). This new syntax will be supported only when used, otherwise
'return' statements will be the ones which will create the return value. So
the function "FuncRetSomeData" can be now written optimized like:

struct SomeData { int a, int b, int c };


SomeData FuncRetSomeData()

{

    //store some data in '(return)', like


    (return).a = 0;


    (return).b = 3; //etc.


    return; //only return statement with no value will be supported to exit
the function

}


'(return)' variable could be also initialized like class members. Example:

struct SomeData { int a, int b, int c };


SomeData FuncRetSomeData(int a, int b, int c) : return { a, b, c } {}


Old code will be supported too:

SomeData &FuncReturningRef()
{
    //Do Something and never use '(return)'



    return ref; //if 'ref' is from type 'SomeData', the return value will
be created now and the function will return (note if the '(return)' was
used above - this statement would be illegal)

}

--

---
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_3599_568671459.1417987341735
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I thought it would be a good idea to implement a language =
solution of the return by value additional temporary creation which is opti=
mized by most-compilers but - you know it's better to make their life easie=
r and also fix the problem in those where the optimization isn't done at al=
l. What I mean is this:<br><br><div class=3D"prettyprint" style=3D"border: =
1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(=
250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">SomeData</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> c </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br><br></span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">SomeData</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
FuncRetSomeData</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeDa=
ta</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tmp</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #800;" class=3D"styled-by-prettify">//creation of additional unneede=
d temporary</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br><br><br>&nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">//store some data in 'tmp'</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br><br><br><br>&nbsp; &nbsp; </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> tmp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//now second return object is created in the c=
alling stack with data copied from 'tmp'</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">}</span></div></code></div><div><br></div><div>=
<br></div><div>Most compilers will optimize this code and never create the =
local 'tmp' but instead store the data supposed to be held in it, directly =
in the return temporary. I suggest creating an old-code compatible new synt=
ax for allowing similar behavior to be done explicitly by using '(return)' =
as an alias to the return value temporary which will be created at function=
 beginning. Also an initialization syntax for the '(return)' will be suppor=
ted like when initializing a class members (if it was named 'return').&nbsp=
;This new syntax will be supported only when used, otherwise 'return' state=
ments will be the ones which will create the return value. So the function =
"<span style=3D"color: rgb(102, 0, 102); font-family: monospace; background=
-color: rgb(250, 250, 250);">FuncRetSomeData</span>" can be now written opt=
imized like:</div><div><br><span class=3D"styled-by-prettify" style=3D"font=
-family: monospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, =
250);"></span></div><div class=3D"prettyprint" style=3D"border: 1px solid r=
gb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 2=
50);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">SomeData</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> c </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
><br></span><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeD=
ata</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">FuncRetSomeData<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">//store some dat=
a in '(return)', like</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">return</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">).</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">b </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//etc.</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; =
&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">//only return statement w=
ith no value will be supported to exit the function</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span></div></code></div><div><spa=
n class=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(=
102, 102, 0); background-color: rgb(250, 250, 250);"><br></span></div><div>=
<span class=3D"styled-by-prettify" style=3D"font-family: monospace; color: =
rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span></div><=
div><span class=3D"styled-by-prettify" style=3D"background-color: rgb(250, =
250, 250);"><span style=3D"color: rgb(34, 34, 34); font-family: Arial, Helv=
etica, sans-serif; background-color: rgb(255, 255, 255);">'(return)' variab=
le could be also&nbsp;</span>initialized like class members. Example:<br><b=
r><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187);=
 word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">SomeData</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span=
 style=3D"color: #606;" class=3D"styled-by-prettify">SomeData</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">FuncRetSomeData</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> c</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> c </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></=
div></code></div><br></span>Old code will be supported too:<br><br></div><d=
iv class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); wor=
d-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><span style=3D"color: #606;" clas=
s=3D"styled-by-prettify">SomeData</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">FuncReturningRef</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> <br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//Do Something and never use '(return)'</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br><br><br><br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">ref</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//if 'ref' is from type 'SomeData', the return value will be=
 created now and the function will return (note if the '(return)' was used =
above - this statement would be illegal)</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">}</span></div></code></div><div><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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_3599_568671459.1417987341735--
------=_Part_3598_1034102090.1417987341735--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sun, 7 Dec 2014 23:26:55 +0200
Raw View
On 7 December 2014 at 23:22, sasho648 <sasho648@mail.bg> wrote:
> I thought it would be a good idea to implement a language solution of the
> return by value additional temporary creation which is optimized by
> most-compilers but - you know it's better to make their life easier and also
> fix the problem in those where the optimization isn't done at all. What I
> mean is this:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>     SomeData tmp; //creation of additional unneeded temporary
>
>
>
>     //store some data in 'tmp'
>
>
>
>     return tmp; //now second return object is created in the calling stack
> with data copied from 'tmp'
>
> }
>
>
> Most compilers will optimize this code and never create the local 'tmp' but
> instead store the data supposed to be held in it, directly in the return
> temporary. I suggest creating an old-code compatible new syntax for allowing
> similar behavior to be done explicitly by using '(return)' as an alias to
> the return value temporary which will be created at function beginning. Also
> an initialization syntax for the '(return)' will be supported like when
> initializing a class members (if it was named 'return'). This new syntax
> will be supported only when used, otherwise 'return' statements will be the
> ones which will create the return value. So the function "FuncRetSomeData"
> can be now written optimized like:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>
>     //store some data in '(return)', like
>
>
>     (return).a = 0;
>
>
>     (return).b = 3; //etc.
>
>
>     return; //only return statement with no value will be supported to exit
> the function
>
> }
>
>
> '(return)' variable could be also initialized like class members. Example:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData(int a, int b, int c) : return { a, b, c } {}
>
>
> Old code will be supported too:
>
> SomeData &FuncReturningRef()
> {
>     //Do Something and never use '(return)'
>
>
>
>     return ref; //if 'ref' is from type 'SomeData', the return value will be
> created now and the function will return (note if the '(return)' was used
> above - this statement would be illegal)
>
> }


So, you're suggesting that we force implementations that don't implement
return-value-optimization to implement it, and you also suggest that
every parser
must change, and you suggest that we teach this alternative technique
to a million
c++ users?

I think I'm going to say no thanks.

--

---
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/.

.


Author: "dgutson ." <danielgutson@gmail.com>
Date: Mon, 8 Dec 2014 03:44:04 -0300
Raw View
--047d7b86f08caa85e90509aec0a6
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Have you measured how many cases RVO failed? In which toolchains? I suggest
you to file problem reports to your toolchain vendor for such cases rather
than affect all the rest of the users, unless you have SPECIFIC real life
examples where the standard prevents RVO.

  Daniel.
El 07/12/2014 18:22, "sasho648" <sasho648@mail.bg> escribi=C3=B3:

> I thought it would be a good idea to implement a language solution of the
> return by value additional temporary creation which is optimized by
> most-compilers but - you know it's better to make their life easier and
> also fix the problem in those where the optimization isn't done at all.
> What I mean is this:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>     SomeData tmp; //creation of additional unneeded temporary
>
>
>
>     //store some data in 'tmp'
>
>
>
>     return tmp; //now second return object is created in the calling
> stack with data copied from 'tmp'
>
> }
>
>
> Most compilers will optimize this code and never create the local 'tmp'
> but instead store the data supposed to be held in it, directly in the
> return temporary. I suggest creating an old-code compatible new syntax fo=
r
> allowing similar behavior to be done explicitly by using '(return)' as an
> alias to the return value temporary which will be created at function
> beginning. Also an initialization syntax for the '(return)' will be
> supported like when initializing a class members (if it was named
> 'return'). This new syntax will be supported only when used, otherwise
> 'return' statements will be the ones which will create the return value. =
So
> the function "FuncRetSomeData" can be now written optimized like:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>
>     //store some data in '(return)', like
>
>
>     (return).a =3D 0;
>
>
>     (return).b =3D 3; //etc.
>
>
>     return; //only return statement with no value will be supported to
> exit the function
>
> }
>
>
> '(return)' variable could be also initialized like class members. Example=
:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData(int a, int b, int c) : return { a, b, c } {}
>
>
> Old code will be supported too:
>
> SomeData &FuncReturningRef()
> {
>     //Do Something and never use '(return)'
>
>
>
>     return ref; //if 'ref' is from type 'SomeData', the return value will
> be created now and the function will return (note if the '(return)' was
> used above - this statement would be illegal)
>
> }
>
>  --
>
> ---
> 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/.
>

--=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/.

--047d7b86f08caa85e90509aec0a6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p>Have you measured how many cases RVO failed? In which toolchains? I sugg=
est you to file problem reports to your toolchain vendor for such cases rat=
her than affect all the rest of the users, unless you have SPECIFIC real li=
fe examples where the standard prevents RVO.</p>
<p>=C2=A0 Daniel.</p>
<div class=3D"gmail_quote">El 07/12/2014 18:22, &quot;sasho648&quot; &lt;<a=
 href=3D"mailto:sasho648@mail.bg">sasho648@mail.bg</a>&gt; escribi=C3=B3:<b=
r type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I th=
ought it would be a good idea to implement a language solution of the retur=
n by value additional temporary creation which is optimized by most-compile=
rs but - you know it&#39;s better to make their life easier and also fix th=
e problem in those where the optimization isn&#39;t done at all. What I mea=
n is this:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap=
:break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"co=
lor:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">SomeData</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">int</span><span style=3D"color:#000"> a</span><span style=3D"color:#=
660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
int</span><span style=3D"color:#000"> b</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#008">int</sp=
an><span style=3D"color:#000"> c </span><span style=3D"color:#660">};</span=
><span style=3D"color:#000"><br><br><br></span><span style=3D"color:#606">S=
omeData</span><span style=3D"color:#000"> </span><span style=3D"color:#606"=
>FuncRetSomeData</span><span style=3D"color:#660">()</span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#660">{</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#606">SomeData</=
span><span style=3D"color:#000"> tmp</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#800">//creation=
 of additional unneeded temporary</span><span style=3D"color:#000"><br><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">//store some data i=
n &#39;tmp&#39;</span><span style=3D"color:#000"><br><br><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:#00=
0"> tmp</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#800">//now second return object is created i=
n the calling stack with data copied from &#39;tmp&#39;</span><span style=
=3D"color:#000"><br><br></span><span style=3D"color:#660">}</span></div></c=
ode></div><div><br></div><div><br></div><div>Most compilers will optimize t=
his code and never create the local &#39;tmp&#39; but instead store the dat=
a supposed to be held in it, directly in the return temporary. I suggest cr=
eating an old-code compatible new syntax for allowing similar behavior to b=
e done explicitly by using &#39;(return)&#39; as an alias to the return val=
ue temporary which will be created at function beginning. Also an initializ=
ation syntax for the &#39;(return)&#39; will be supported like when initial=
izing a class members (if it was named &#39;return&#39;).=C2=A0This new syn=
tax will be supported only when used, otherwise &#39;return&#39; statements=
 will be the ones which will create the return value. So the function &quot=
;<span style=3D"color:rgb(102,0,102);font-family:monospace;background-color=
:rgb(250,250,250)">FuncRetSomeData</span>&quot; can be now written optimize=
d like:</div><div><br><span style=3D"font-family:monospace;color:rgb(0,0,13=
6);background-color:rgb(250,250,250)"></span></div><div style=3D"border:1px=
 solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,2=
50)"><code><div><span style=3D"color:#008">struct</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#606">SomeData</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000=
"> a</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">int</span><span style=3D"color:#000"> b</s=
pan><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">int</span><span style=3D"color:#000"> c </span><s=
pan style=3D"color:#660">};</span><span style=3D"color:#000"><br><br><br></=
span><span style=3D"color:#606">SomeData</span><span style=3D"color:#000"> =
</span><span style=3D"color:#606">FuncRetSomeData</span><span style=3D"colo=
r:#660">()</span><span style=3D"color:#000"><br><br></span><span style=3D"c=
olor:#660">{</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color:#800">//store some data in &#39;(return)&#39;, like</s=
pan><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">return</span><span style=
=3D"color:#660">).</span><span style=3D"color:#000">a </span><span style=3D=
"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#066">0</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#008">return</span><span style=3D"color:#660">).</span><=
span style=3D"color:#000">b </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#066">3</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//etc.</span><span style=3D"color:#000"><br><br><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#800"=
>//only return statement with no value will be supported to exit the functi=
on</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#66=
0">}</span></div></code></div><div><span style=3D"font-family:monospace;col=
or:rgb(102,102,0);background-color:rgb(250,250,250)"><br></span></div><div>=
<span style=3D"font-family:monospace;color:rgb(102,102,0);background-color:=
rgb(250,250,250)"><br></span></div><div><span style=3D"background-color:rgb=
(250,250,250)"><span style=3D"color:rgb(34,34,34);font-family:Arial,Helveti=
ca,sans-serif;background-color:rgb(255,255,255)">&#39;(return)&#39; variabl=
e could be also=C2=A0</span>initialized like class members. Example:<br><br=
><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backg=
round-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">struct<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">SomeDat=
a</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">int</span>=
<span style=3D"color:#000"> a</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#008">int</span><span s=
tyle=3D"color:#000"> b</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">int</span><span style=3D=
"color:#000"> c </span><span style=3D"color:#660">};</span><span style=3D"c=
olor:#000"><br><br><br></span><span style=3D"color:#606">SomeData</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#606">FuncRetSomeData<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#008">int</sp=
an><span style=3D"color:#000"> a</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">int</span><spa=
n style=3D"color:#000"> b</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> c</span><span style=3D"color:#660">)</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">:</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">return</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000=
"> a</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> b=
</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> c </s=
pan><span style=3D"color:#660">}</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">{}</span><span style=3D"color:#000"><br><br></spa=
n></div></code></div><br></span>Old code will be supported too:<br><br></di=
v><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;back=
ground-color:rgb(250,250,250)"><code><div><span style=3D"color:#606">SomeDa=
ta</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&amp=
;</span><span style=3D"color:#606">FuncReturningRef</span><span style=3D"co=
lor:#660">()</span><span style=3D"color:#000"> <br></span><span style=3D"co=
lor:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span=
 style=3D"color:#800">//Do Something and never use &#39;(return)&#39;</span=
><span style=3D"color:#000"><br><br><br><br>=C2=A0 =C2=A0 </span><span styl=
e=3D"color:#008">return</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">ref</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">//if &#39;ref&#39; is fr=
om type &#39;SomeData&#39;, the return value will be created now and the fu=
nction will return (note if the &#39;(return)&#39; was used above - this st=
atement would be illegal)</span><span style=3D"color:#000"><br><br></span><=
span style=3D"color:#660">}</span></div></code></div><div><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&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--047d7b86f08caa85e90509aec0a6--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Mon, 8 Dec 2014 21:31:49 +0330
Raw View
--f46d04389251abba580509b83923
Content-Type: text/plain; charset=UTF-8

Sorry fo overmuch frankness, but regarding your other posts, IMHO u better
collect more info about "rvalue ref", "perfect forwarding", "std::move",
"copy ellision", "RVO" & "NRVO". I don`t think there exists any practical
motivation for this kind of syntax proposals today. 10 years ago they might.

cheers,
FM.

2014-12-08 0:52 GMT+03:30 sasho648 <sasho648@mail.bg>:

> I thought it would be a good idea to implement a language solution of the
> return by value additional temporary creation which is optimized by
> most-compilers but - you know it's better to make their life easier and
> also fix the problem in those where the optimization isn't done at all.
> What I mean is this:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>     SomeData tmp; //creation of additional unneeded temporary
>
>
>
>     //store some data in 'tmp'
>
>
>
>     return tmp; //now second return object is created in the calling
> stack with data copied from 'tmp'
>
> }
>
>
> Most compilers will optimize this code and never create the local 'tmp'
> but instead store the data supposed to be held in it, directly in the
> return temporary. I suggest creating an old-code compatible new syntax for
> allowing similar behavior to be done explicitly by using '(return)' as an
> alias to the return value temporary which will be created at function
> beginning. Also an initialization syntax for the '(return)' will be
> supported like when initializing a class members (if it was named
> 'return'). This new syntax will be supported only when used, otherwise
> 'return' statements will be the ones which will create the return value. So
> the function "FuncRetSomeData" can be now written optimized like:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData()
>
> {
>
>     //store some data in '(return)', like
>
>
>     (return).a = 0;
>
>
>     (return).b = 3; //etc.
>
>
>     return; //only return statement with no value will be supported to
> exit the function
>
> }
>
>
> '(return)' variable could be also initialized like class members. Example:
>
> struct SomeData { int a, int b, int c };
>
>
> SomeData FuncRetSomeData(int a, int b, int c) : return { a, b, c } {}
>
>
> Old code will be supported too:
>
> SomeData &FuncReturningRef()
> {
>     //Do Something and never use '(return)'
>
>
>
>     return ref; //if 'ref' is from type 'SomeData', the return value will
> be created now and the function will return (note if the '(return)' was
> used above - this statement would be illegal)
>
> }
>
>  --
>
> ---
> 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/.
>



--
how am I supposed to end the twisted road of  your hair in the dark night??
unless the candle of your face does turn a lamp up on my way!!!

--

---
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/.

--f46d04389251abba580509b83923
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"rtl"><div dir=3D"ltr">Sorry fo overmuch frankness, but regardin=
g your other posts, IMHO u better collect more info about &quot;rvalue ref&=
quot;, &quot;perfect forwarding&quot;, &quot;std::move&quot;, &quot;copy el=
lision&quot;, &quot;RVO&quot; &amp; &quot;NRVO&quot;. I don`t think there e=
xists any practical motivation for this kind of syntax proposals today. 10 =
years ago they might.</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">chee=
rs,</div><div dir=3D"ltr">FM.</div></div><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote"><div dir=3D"ltr">2014-12-08 0:52 GMT+03:30 sasho648=
 <span dir=3D"ltr">&lt;<a href=3D"mailto:sasho648@mail.bg" target=3D"_blank=
">sasho648@mail.bg</a>&gt;</span>:</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
 dir=3D"ltr">I thought it would be a good idea to implement a language solu=
tion of the return by value additional temporary creation which is optimize=
d by most-compilers but - you know it&#39;s better to make their life easie=
r and also fix the problem in those where the optimization isn&#39;t done a=
t all. What I mean is this:<br><br><div style=3D"border:1px solid rgb(187,1=
87,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div>=
<span style=3D"color:#008">struct</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">SomeData</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">int</span><span style=3D"color:#000"> a</span><span=
 style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">int</span><span style=3D"color:#000"> b</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">int</span><span style=3D"color:#000"> c </span><span style=3D"co=
lor:#660">};</span><span style=3D"color:#000"><br><br><br></span><span styl=
e=3D"color:#606">SomeData</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#606">FuncRetSomeData</span><span style=3D"color:#660">()</spa=
n><span style=3D"color:#000"><br><br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r:#606">SomeData</span><span style=3D"color:#000"> tmp</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">//creation of additional unneeded temporary</span><span style=3D"co=
lor:#000"><br><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">/=
/store some data in &#39;tmp&#39;</span><span style=3D"color:#000"><br><br>=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span =
style=3D"color:#000"> tmp</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#800">//now second return o=
bject is created in the calling stack with data copied from &#39;tmp&#39;</=
span><span style=3D"color:#000"><br><br></span><span style=3D"color:#660">}=
</span></div></code></div><div><br></div><div><br></div><div>Most compilers=
 will optimize this code and never create the local &#39;tmp&#39; but inste=
ad store the data supposed to be held in it, directly in the return tempora=
ry. I suggest creating an old-code compatible new syntax for allowing simil=
ar behavior to be done explicitly by using &#39;(return)&#39; as an alias t=
o the return value temporary which will be created at function beginning. A=
lso an initialization syntax for the &#39;(return)&#39; will be supported l=
ike when initializing a class members (if it was named &#39;return&#39;).=
=C2=A0This new syntax will be supported only when used, otherwise &#39;retu=
rn&#39; statements will be the ones which will create the return value. So =
the function &quot;<span style=3D"color:rgb(102,0,102);font-family:monospac=
e;background-color:rgb(250,250,250)">FuncRetSomeData</span>&quot; can be no=
w written optimized like:</div><div><br><span style=3D"font-family:monospac=
e;color:rgb(0,0,136);background-color:rgb(250,250,250)"></span></div><div s=
tyle=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-c=
olor:rgb(250,250,250)"><code><div><span style=3D"color:#008">struct</span><=
span style=3D"color:#000"> </span><span style=3D"color:#606">SomeData</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#008">int</span><span s=
tyle=3D"color:#000"> a</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">int</span><span style=3D=
"color:#000"> b</span><span style=3D"color:#660">,</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> c </span><span style=3D"color:#660">};</span><span style=3D"color:#0=
00"><br><br><br></span><span style=3D"color:#606">SomeData</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">FuncRetSomeData</span><=
span style=3D"color:#660">()</span><span style=3D"color:#000"><br><br></spa=
n><span style=3D"color:#660">{</span><span style=3D"color:#000"><br><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#800">//store some data in &#39;(ret=
urn)&#39;, like</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#660">(</span><span style=3D"color:#008">return=
</span><span style=3D"color:#660">).</span><span style=3D"color:#000">a </s=
pan><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span=
><span style=3D"color:#066">0</span><span style=3D"color:#660">;</span><spa=
n style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#008">return</span><span style=3D"colo=
r:#660">).</span><span style=3D"color:#000">b </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066=
">3</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </=
span><span style=3D"color:#800">//etc.</span><span style=3D"color:#000"><br=
><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span=
 style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#800">//only return statement with no value will be supported to=
 exit the function</span><span style=3D"color:#000"><br><br></span><span st=
yle=3D"color:#660">}</span></div></code></div><div><span style=3D"font-fami=
ly:monospace;color:rgb(102,102,0);background-color:rgb(250,250,250)"><br></=
span></div><div><span style=3D"font-family:monospace;color:rgb(102,102,0);b=
ackground-color:rgb(250,250,250)"><br></span></div><div><span style=3D"back=
ground-color:rgb(250,250,250)"><span style=3D"color:rgb(34,34,34);font-fami=
ly:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)">&#39;(retu=
rn)&#39; variable could be also=C2=A0</span>initialized like class members.=
 Example:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:=
break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"col=
or:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#606">SomeData</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">{</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">int</span><span style=3D"color:#000"> a</span><span style=3D"color:#6=
60">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">i=
nt</span><span style=3D"color:#000"> b</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">int</spa=
n><span style=3D"color:#000"> c </span><span style=3D"color:#660">};</span>=
<span style=3D"color:#000"><br><br><br></span><span style=3D"color:#606">So=
meData</span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
FuncRetSomeData</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#008">int</span><span style=3D"color:#000"> a</span><span style=3D"color=
:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">int</span><span style=3D"color:#000"> b</span><span style=3D"color:#660">=
,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">int</=
span><span style=3D"color:#000"> c</span><span style=3D"color:#660">)</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">:</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#008">return</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"> a</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> b</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> c </span><span style=3D"color:#660">}</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">{}</span><span style=3D"color:#=
000"><br><br></span></div></code></div><br></span>Old code will be supporte=
d too:<br><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wr=
ap:break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"=
color:#606">SomeData</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&amp;</span><span style=3D"color:#606">FuncReturningRef</sp=
an><span style=3D"color:#660">()</span><span style=3D"color:#000"> <br></sp=
an><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0=
 =C2=A0 </span><span style=3D"color:#800">//Do Something and never use &#39=
;(return)&#39;</span><span style=3D"color:#000"><br><br><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">ref</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//if =
&#39;ref&#39; is from type &#39;SomeData&#39;, the return value will be cre=
ated now and the function will return (note if the &#39;(return)&#39; was u=
sed above - this statement would be illegal)</span><span style=3D"color:#00=
0"><br><br></span><span style=3D"color:#660">}</span></div></code></div><sp=
an class=3D"HOEnZb"><font color=3D"#888888"><div><br></div></font></span></=
div><span class=3D"HOEnZb"><font color=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r><div class=3D"gmail_signature"><div dir=3D"ltr">how am I supposed to end =
the twisted road of=C2=A0 your hair in the dark night??<br>unless the candl=
e of your face does turn a lamp up on my way!!!<br></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--f46d04389251abba580509b83923--

.


Author: sasho648 <sasho648@mail.bg>
Date: Mon, 8 Dec 2014 12:01:10 -0800 (PST)
Raw View
------=_Part_657_374911328.1418068870866
Content-Type: multipart/alternative;
 boundary="----=_Part_658_417669398.1418068870866"

------=_Part_658_417669398.1418068870866
Content-Type: text/plain; charset=UTF-8

I don't know what's your problem with the solution. Why implement those
complex optimization as we can just add this feature (*compatible with
old-code*) which will make them useless and perhaps lift the requirement
that 'arrays' can't be returned (because they can't be copied so allowing
them to be returned by value is useless as only constant expressions will
be allowed to return). Also there is already such feature introduced with
C++11 which made the "NRVO" useless - the 'rvalue' reference which when
bound to a 'prvalue', as the function return one, extends it's life-time.

So if this feature is introduced, arrays could be returned like this:

int FuncReturningArrays()[5] return
{
    for(size_t i(0); i < 5; ++i)

        return[i] = /*SomeValue*/;
}

The 'return' keyword will be also an specifier (like 'noexcept'), which
when appear after a function declaration will specify that in the function
'return' won't be an statement but instead a variable naming the return
value.

--

---
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_658_417669398.1418068870866
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I don't know what's your problem with the solution. Why im=
plement those complex optimization as we can just add this feature (<b>comp=
atible with old-code</b>) which will make them useless and perhaps lift the=
 requirement that 'arrays' can't be returned (because they can't be copied =
so allowing them to be returned by value is useless as only constant expres=
sions will be allowed to return). Also there is already such feature introd=
uced with C++11 which made the&nbsp;"NRVO" useless - the 'rvalue' reference=
 which when bound to a 'prvalue', as the function return one, extends it's =
life-time.<div><br></div><div>So if this feature is introduced, arrays coul=
d be returned like this:<br><br></div><div class=3D"prettyprint" style=3D"b=
order: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-colo=
r: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">FuncReturningArrays</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">()[</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">for</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">siz=
e_t i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> i </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">++<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">i</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">re=
turn</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">i</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">/*SomeValue*/</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">}</span></div></code></div><div><br></div><div>The 'return' keyword wi=
ll be also an specifier (like 'noexcept'), which when appear after a functi=
on declaration will specify that in the function 'return' won't be an state=
ment but instead a variable naming the return value.</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_658_417669398.1418068870866--
------=_Part_657_374911328.1418068870866--

.


Author: "Daniel Gutson" <danielgutson@gmail.com>
Date: Mon, 8 Dec 2014 20:13:43 +0000
Raw View
--part4138-boundary-231050504-1727274612
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

I think this is a solution to a no-problem, since almost all toolchains alr=
eady implement this optimization. I suggest you to answer my previous email=
 where I asked you to provide a real-life usecase where the standard as-is =
prevents the rvo, or where real toolchains are analytically incapable to de=
tect and perform the optimization.
Otherwise, I think you are proposing an anacronyc proposal.
-----Original Message-----
From: sasho648 <sasho648@mail.bg>
Date: Mon, 8 Dec 2014 12:01:10=20
To: <std-proposals@isocpp.org>
Reply-To: std-proposals@isocpp.org
Subject: [std-proposals] Re: Earlier creation of function return-value.

I don't know what's your problem with the solution. Why implement those=20
complex optimization as we can just add this feature (*compatible with=20
old-code*) which will make them useless and perhaps lift the requirement=20
that 'arrays' can't be returned (because they can't be copied so allowing=
=20
them to be returned by value is useless as only constant expressions will=
=20
be allowed to return). Also there is already such feature introduced with=
=20
C++11 which made the "NRVO" useless - the 'rvalue' reference which when=20
bound to a 'prvalue', as the function return one, extends it's life-time.

So if this feature is introduced, arrays could be returned like this:

int FuncReturningArrays()[5] return
{
    for(size_t i(0); i < 5; ++i)

        return[i] =3D /*SomeValue*/;
}

The 'return' keyword will be also an specifier (like 'noexcept'), which=20
when appear after a function declaration will specify that in the function=
=20
'return' won't be an statement but instead a variable naming the return=20
value.

--=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/.

--=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/.

--part4138-boundary-231050504-1727274612
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><=
meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type"></h=
ead><body>I think this is a solution to a no-problem, since almost all tool=
chains already implement this optimization. I suggest you to answer my prev=
ious email where I asked you to provide a real-life usecase where the stand=
ard as-is prevents the rvo, or where real toolchains are analytically incap=
able to detect and perform the optimization.<br/>Otherwise, I think you are=
 proposing an anacronyc proposal.<hr/><div><b>From: </b> sasho648 &lt;sasho=
648@mail.bg&gt;
</div><div><b>Date: </b>Mon, 8 Dec 2014 12:01:10 -0800 (PST)</div><div><b>T=
o: </b>&lt;std-proposals@isocpp.org&gt;</div><div><b>ReplyTo: </b> std-prop=
osals@isocpp.org
</div><div><b>Subject: </b>[std-proposals] Re: Earlier creation of function=
 return-value.</div><div><br/></div><div dir=3D"ltr">I don't know what's yo=
ur problem with the solution. Why implement those complex optimization as w=
e can just add this feature (<b>compatible with old-code</b>) which will ma=
ke them useless and perhaps lift the requirement that 'arrays' can't be ret=
urned (because they can't be copied so allowing them to be returned by valu=
e is useless as only constant expressions will be allowed to return). Also =
there is already such feature introduced with C++11 which made the&nbsp;"NR=
VO" useless - the 'rvalue' reference which when bound to a 'prvalue', as th=
e function return one, extends it's life-time.<div><br></div><div>So if thi=
s feature is introduced, arrays could be returned like this:<br><br></div><=
div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); wo=
rd-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">FuncReturningArrays</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">()[</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">size_t i</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> i </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">++</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">i</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">return</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">i</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">/*SomeValue*/</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span></div></code></div><div><b=
r></div><div>The 'return' keyword will be also an specifier (like 'noexcept=
'), which when appear after a function declaration will specify that in the=
 function 'return' won't be an statement but instead a variable naming the =
return value.</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

</body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--part4138-boundary-231050504-1727274612--


.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 8 Dec 2014 22:16:00 +0200
Raw View
On 8 December 2014 at 22:01, sasho648 <sasho648@mail.bg> wrote:
> I don't know what's your problem with the solution. Why implement those

It's a solution looking for a problem, in the presence of move semantics
and widely-implemented RVO/NRVO. The cost/benefit ratio is not there.

> complex optimization as we can just add this feature (compatible with
> old-code) which will make them useless and perhaps lift the requirement that

This feature doesn't make RVO/NRVO useless.

> 'arrays' can't be returned (because they can't be copied so allowing them to

I don't need to return arrays, I can return std::arrays.

--

---
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/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Tue, 9 Dec 2014 14:45:23 -0800 (PST)
Raw View
------=_Part_5717_1363659495.1418165124119
Content-Type: multipart/alternative;
 boundary="----=_Part_5718_1079651681.1418165124120"

------=_Part_5718_1079651681.1418165124120
Content-Type: text/plain; charset=UTF-8

What about - when we don't know exactly what local will be returned? In
this case (at least my GCC compiler, even with '-02') haven't implemented
any 'RVO'. By using a named variable which represents the return value, we
can store one of those temporaries directly into it and in one of the cases
no copying will be performed. Here is what I mean:

struct S
{
    S () { pSomeMemory = new char[250], cout << "S::S()" << endl; }

    S (const S &arg) : S() { memcpy(pSomeMemory, arg.pSomeMemory, sizeof(
char) * 250), cout << "S::S(const S &arg)" << endl; }

    S (S &&arg) : S() { pSomeMemory = arg.pSomeMemory, arg.pSomeMemory =
nullptr, cout << "S::S(S &&arg)" << endl; }

    ~S () { delete[] pSomeMemory; }

    char *pSomeMemory;
};


S FunctionReturningS(bool b)
{
    //the below 2 temporaries must be constructed

    S temp;

    S temp1;

    //store some data at 'temp' and 'temp1'

    temp.pSomeMemory[0] = '\0';

    temp1.pSomeMemory[5] = '6';

    return (b ? (S&&)temp : (S&&)temp1); // return either 'temp' or 'temp1'
}

Life example <http://coliru.stacked-crooked.com/a/70566400ba29bac4>.

Using my new syntax we can optimize 'FunctionReturningS' like this:

S FunctionReturningS(bool b) return
{
    //the below 1 temporarie + 'return' must be constructed

    S temp;

    //store some data at 'temp' and 'return'

    temp.pSomeMemory[0] = '\0';

    return.pSomeMemory[5] = '6';

    if(!b) return; //just exit the function (temp1 is replaced by 'return')

    return.~return(); //calling explicit destructor on 'return'

    new (&return) S((&&)temp); //placement new, re-constructs 'return' by
'temp'
}

As in my case if 'b' is 'false' no copy-construction will be done.

--

---
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_5718_1079651681.1418165124120
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">What about - when we don't know exactly what local will be=
 returned? In this case (at least my GCC compiler, even with '-02') haven't=
 implemented any 'RVO'. By using a named variable which represents the retu=
rn value, we can store one of those temporaries directly into it and in one=
 of the cases no copying will be performed. Here is what I mean:<br><br><di=
v class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word=
-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pr=
ettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> S<br></span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; S </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> pSomeMem=
ory </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">new</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">char</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">250</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> cout </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"S::S(=
)"</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; S </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> S </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">arg</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> memcpy</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> arg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">pSomeMemory</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">char</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">250</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">),</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"S::S(const S &amp;arg)"</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br>&nbsp; &nbsp; S </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">S </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">arg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> pSomeMemory </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> arg</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">pSom=
eMemory</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">pSomeMemory </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">nullptr</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"S::S(S &amp;&amp;arg)"</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">~</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">S </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">[]</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp;=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">pSomeMemory</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br><br>S </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FunctionReturningS</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//the =
below 2 temporaries must be constructed</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; S temp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; S temp1</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//store some da=
ta at 'temp' and 'temp1'</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br><br>&nbsp; &nbsp; temp</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">pSomeMemory</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">'\0'</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; temp1</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">pSomeMemory</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">'6'</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">b </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">&nbsp;</span><span style=3D"color: rgb(0, 0, 0); fo=
nt-family: Arial, Helvetica, sans-serif;">(S&amp;&amp;)</span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(0, 0, 0);">temp </span><span class=3D"styled-by-prettify" style=
=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 102, 0);">:<=
/span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helve=
tica, sans-serif; color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: =
rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif;">(S&amp;&amp;)</sp=
an><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetic=
a, sans-serif; color: rgb(0, 0, 0);">temp1</span><span class=3D"styled-by-p=
rettify" style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102=
, 102, 0);">);</span><span class=3D"styled-by-prettify" style=3D"font-famil=
y: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(136, 0, 0);">// return either 'temp' or 'temp1'</span></div><di=
v class=3D"subprettyprint"><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span></div></code></div><div><br>Life <a href=3D"http://coliru=
..stacked-crooked.com/a/70566400ba29bac4">example</a>.</div><div><br></div><=
div>Using my new syntax we can optimize '<span style=3D"color: rgb(102, 0, =
102); font-family: monospace; background-color: rgb(250, 250, 250);">Functi=
onReturningS</span>' like this:</div><div><br><span class=3D"styled-by-pret=
tify" style=3D"font-family: monospace; color: rgb(0, 0, 0); background-colo=
r: rgb(250, 250, 250);"></span></div><div class=3D"prettyprint" style=3D"bo=
rder: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: #000;" class=3D"styled-by-prettify">S </span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>&nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-=
by-prettify">//the below 1 temporarie + 'return' must be constructed</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &n=
bsp; S temp</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
&nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//store some data at 'temp' and 'return'</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; temp</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">pSomeMemory</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">'\0'</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">pSomeMemory</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">'=
6'</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">return</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">//just exit the function (temp1 is replaced by 'return')</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">.~</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">//calling explicit destructor on 'return'<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nb=
sp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>new</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> S</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">((&amp;&amp;)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">temp</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//placement new, re-constructs 'return' by 'temp'</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></div>=
<div><span class=3D"styled-by-prettify" style=3D"font-family: monospace; co=
lor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span>As=
 in my case if 'b' is 'false' no copy-construction will be done.</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_5718_1079651681.1418165124120--
------=_Part_5717_1363659495.1418165124119--

.


Author: sasho648 <sasho648@mail.bg>
Date: Tue, 9 Dec 2014 14:50:44 -0800 (PST)
Raw View
------=_Part_2382_84056808.1418165444886
Content-Type: multipart/alternative;
 boundary="----=_Part_2383_1846015977.1418165444886"

------=_Part_2383_1846015977.1418165444886
Content-Type: text/plain; charset=UTF-8

Also don't you believe that this 'RVO' can create an unexpected behavior in
some cases. Maybe there are programs which rely on return-values to be
copied n-times, instead of being optimized.

--

---
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_2383_1846015977.1418165444886
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Also don't you believe that this 'RVO' can create an unexpected behavior in some cases. Maybe there are programs which rely on return-values to be copied n-times, instead of being optimized.</div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_2383_1846015977.1418165444886--
------=_Part_2382_84056808.1418165444886--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 10 Dec 2014 00:53:59 +0200
Raw View
On 10 December 2014 at 00:50, sasho648 <sasho648@mail.bg> wrote:
> Also don't you believe that this 'RVO' can create an unexpected behavior in
> some cases. Maybe there are programs which rely on return-values to be
> copied n-times, instead of being optimized.


Such programs are already broken.

--

---
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/.

.


Author: "Daniel Gutson" <danielgutson@gmail.com>
Date: Tue, 9 Dec 2014 22:54:11 +0000
Raw View
--part4338-boundary-580526182-15063547
Content-Type: text/plain; charset=UTF-8

-O3 is a decent level.
Besides that, why didn't you provide a move ctor?
-----Original Message-----
From: sasho648 <sasho648@mail.bg>
Date: Tue, 9 Dec 2014 14:45:23
To: <std-proposals@isocpp.org>
Reply-To: std-proposals@isocpp.org
Subject: [std-proposals] Re: Earlier creation of function return-value.

What about - when we don't know exactly what local will be returned? In
this case (at least my GCC compiler, even with '-02') haven't implemented
any 'RVO'. By using a named variable which represents the return value, we
can store one of those temporaries directly into it and in one of the cases
no copying will be performed. Here is what I mean:

struct S
{
    S () { pSomeMemory = new char[250], cout << "S::S()" << endl; }

    S (const S &arg) : S() { memcpy(pSomeMemory, arg.pSomeMemory, sizeof(
char) * 250), cout << "S::S(const S &arg)" << endl; }

    S (S &&arg) : S() { pSomeMemory = arg.pSomeMemory, arg.pSomeMemory =
nullptr, cout << "S::S(S &&arg)" << endl; }

    ~S () { delete[] pSomeMemory; }

    char *pSomeMemory;
};


S FunctionReturningS(bool b)
{
    //the below 2 temporaries must be constructed

    S temp;

    S temp1;

    //store some data at 'temp' and 'temp1'

    temp.pSomeMemory[0] = '\0';

    temp1.pSomeMemory[5] = '6';

    return (b ? (S&&)temp : (S&&)temp1); // return either 'temp' or 'temp1'
}

Life example <http://coliru.stacked-crooked.com/a/70566400ba29bac4>.

Using my new syntax we can optimize 'FunctionReturningS' like this:

S FunctionReturningS(bool b) return
{
    //the below 1 temporarie + 'return' must be constructed

    S temp;

    //store some data at 'temp' and 'return'

    temp.pSomeMemory[0] = '\0';

    return.pSomeMemory[5] = '6';

    if(!b) return; //just exit the function (temp1 is replaced by 'return')

    return.~return(); //calling explicit destructor on 'return'

    new (&return) S((&&)temp); //placement new, re-constructs 'return' by
'temp'
}

As in my case if 'b' is 'false' no copy-construction will be done.

--

---
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/.

--

---
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/.

--part4338-boundary-580526182-15063547
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><=
meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type"></h=
ead><body>-O3 is a decent level.<br/>Besides that, why didn't you provide a=
 move ctor?<hr/><div><b>From: </b> sasho648 &lt;sasho648@mail.bg&gt;
</div><div><b>Date: </b>Tue, 9 Dec 2014 14:45:23 -0800 (PST)</div><div><b>T=
o: </b>&lt;std-proposals@isocpp.org&gt;</div><div><b>ReplyTo: </b> std-prop=
osals@isocpp.org
</div><div><b>Subject: </b>[std-proposals] Re: Earlier creation of function=
 return-value.</div><div><br/></div><div dir=3D"ltr">What about - when we d=
on't know exactly what local will be returned? In this case (at least my GC=
C compiler, even with '-02') haven't implemented any 'RVO'. By using a name=
d variable which represents the return value, we can store one of those tem=
poraries directly into it and in one of the cases no copying will be perfor=
med. Here is what I mean:<br><br><div class=3D"prettyprint" style=3D"border=
: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rg=
b(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> S<br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; S </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> pSomeMemory </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
char</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">250</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> cout </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080=
;" class=3D"styled-by-prettify">"S::S()"</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp=
; &nbsp; S </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> S </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">arg</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> S</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> memcpy</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">pSomeMemory</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> arg</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">pSomeMemory</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">250</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>"S::S(const S &amp;arg)"</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; S </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">S </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">arg</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> S</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> pSomeMemory </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">pSomeMemory</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> arg</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">pSomeMemory </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">nullp=
tr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> cout </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #080;" class=3D"styled-by-prettify">"S::S(S &amp;&amp;arg)"</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">~</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">S </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">delete</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> pSomeMemory</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">char</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>S </spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturni=
ngS</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">//the below 2 temporaries must be construct=
ed</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
&nbsp; &nbsp; S temp</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br>&nbsp; &nbsp; S temp1</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//store some data at 'temp' and 'temp1'</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; =
temp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">pSomeMemory</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">'\0'</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r>&nbsp; &nbsp; temp1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cla=
ss=3D"styled-by-prettify">'6'</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">b </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp;</span><s=
pan style=3D"color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif=
;">(S&amp;&amp;)</span><span class=3D"styled-by-prettify" style=3D"font-fam=
ily: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">temp </span><span =
class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-s=
erif; color: rgb(102, 102, 0);">:</span><span class=3D"styled-by-prettify" =
style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">&=
nbsp;</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, Helveti=
ca, sans-serif;">(S&amp;&amp;)</span><span class=3D"styled-by-prettify" sty=
le=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">temp=
1</span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Hel=
vetica, sans-serif; color: rgb(102, 102, 0);">);</span><span class=3D"style=
d-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif; color: r=
gb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"font-fami=
ly: Arial, Helvetica, sans-serif; color: rgb(136, 0, 0);">// return either =
'temp' or 'temp1'</span></div><div class=3D"subprettyprint"><span style=3D"=
color: #660;" class=3D"styled-by-prettify">}</span></div></code></div><div>=
<br>Life <a href=3D"http://coliru.stacked-crooked.com/a/70566400ba29bac4">e=
xample</a>.</div><div><br></div><div>Using my new syntax we can optimize '<=
span style=3D"color: rgb(102, 0, 102); font-family: monospace; background-c=
olor: rgb(250, 250, 250);">FunctionReturningS</span>' like this:</div><div>=
<br><span class=3D"styled-by-prettify" style=3D"font-family: monospace; col=
or: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"></span></div><div =
class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">S </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">FunctionReturningS</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//the below 1 temporarie + '=
return' must be constructed</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br>&nbsp; &nbsp; S temp</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//store some data at 'temp' and 'retu=
rn'</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
>&nbsp; &nbsp; temp</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">'\0'</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">pSomeMemory</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
5</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080=
;" class=3D"styled-by-prettify">'6'</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//just exit the function (temp1 is re=
placed by 'return')</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">.~</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">//calling e=
xplicit destructor on 'return'</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">new</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(&amp;</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">return</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
S</span><span style=3D"color: #660;" class=3D"styled-by-prettify">((&amp;&a=
mp;)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">temp</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//placement new, re-construc=
ts 'return' by 'temp'</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">}</span></div></code></div><div><span class=3D"styled-by-prettify" sty=
le=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: rg=
b(250, 250, 250);"><br></span>As in my case if 'b' is 'false' no copy-const=
ruction will be done.</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

</body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--part4338-boundary-580526182-15063547--


.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 10 Dec 2014 01:18:46 +0200
Raw View
On 10 December 2014 at 00:45, sasho648 <sasho648@mail.bg> wrote:
> What about - when we don't know exactly what local will be returned? In this
> case (at least my GCC compiler, even with '-02') haven't implemented any
> 'RVO'. By using a named variable which represents the return value, we can
> store one of those temporaries directly into it and in one of the cases no
> copying will be performed. Here is what I mean:
>
> struct S
> {
>     S () { pSomeMemory = new char[250], cout << "S::S()" << endl; }
>
>     S (const S &arg) : S() { memcpy(pSomeMemory, arg.pSomeMemory,
> sizeof(char) * 250), cout << "S::S(const S &arg)" << endl; }
>
>     S (S &&arg) : S() { pSomeMemory = arg.pSomeMemory, arg.pSomeMemory =

The move constructor should not delegate to the default constructor.

> Using my new syntax we can optimize 'FunctionReturningS' like this:
>
> S FunctionReturningS(bool b) return
> {
>     //the below 1 temporarie + 'return' must be constructed
>
>     S temp;
>
>     //store some data at 'temp' and 'return'
>
>     temp.pSomeMemory[0] = '\0';
>
>     return.pSomeMemory[5] = '6';
>
>     if(!b) return; //just exit the function (temp1 is replaced by 'return')
>
>     return.~return(); //calling explicit destructor on 'return'
>
>     new (&return) S((&&)temp); //placement new, re-constructs 'return' by
> 'temp'
> }
>
> As in my case if 'b' is 'false' no copy-construction will be done.

Same thing can be achieved by destroying temp and placement-newing
the result of moving temp1 on top of it. No copy is made in the other
branch. See
http://melpon.org/wandbox/permlink/YhHuzt68IsYRSwPr

--

---
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/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 09 Dec 2014 15:21:47 -0800
Raw View
On Tuesday 09 December 2014 14:45:23 sasho648 wrote:
> S FunctionReturningS(bool b) return
> {
>     //the below 1 temporarie + 'return' must be constructed
>
>     S temp;
>
>     //store some data at 'temp' and 'return'
>
>     temp.pSomeMemory[0] = '\0';
>
>     return.pSomeMemory[5] = '6';
>
>     if(!b) return; //just exit the function (temp1 is replaced by 'return')
>
>     return.~return(); //calling explicit destructor on 'return'
>
>     new (&return) S((&&)temp); //placement new, re-constructs 'return' by
> 'temp'
> }


What happens if the type is not trivial and I do something like this:

S FunctionReturningS(bool b) return
{
     return.setFoo(b);
     return S{1234};
}

Note the following:

 1) I called a member function in the hidden return value, which implies its
constructor must have been called

 2) I did not return the object, which in turn implies that the hidden member
needs to be destroyed before it can be returned with the move constructor.
Alternatively, we can have a behaviour change and instead use the assignment-
move operator called.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
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/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Wed, 10 Dec 2014 12:35:57 -0800 (PST)
Raw View
------=_Part_863_1198208871.1418243757276
Content-Type: multipart/alternative;
 boundary="----=_Part_864_1342336978.1418243757276"

------=_Part_864_1342336978.1418243757276
Content-Type: text/plain; charset=UTF-8

Never mind. It seems I actually find a way to implement this without the
need of introducing a new syntax by using class constructors like this:

struct FunctionReturningS
{
    explicit FunctionReturningS(bool b)
    {
        S temp;

        //store some data at 'temp' and 'return_value'

        temp.pSomeMemory[0] = '9';

        return_value.pSomeMemory[5] = '6';

        if(!b) return; //just exit the function (temp1 is replaced by
'return_value')

        return_value.~S(); //calling explicit destructor on 'return_value'

        new (&return_value) S((S &&)temp); //placement new, re-constructs
'return_value' by 'temp'
    }


    S return_value;
};

So you can instance the function like:

int main()
{
    auto &&RetValue = FunctionReturningS(true).return_value;

    cout << RetValue.pSomeMemory[0] << endl;

    auto &&RetValue1 = FunctionReturningS(false);

    return 0;
}


Thanks for your opinions anyway.

--

---
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_864_1342336978.1418243757276
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Never mind. It seems I actually find a way to implement th=
is without the need of introducing a new syntax by using class constructors=
 like this:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">FunctionReturningS</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">explicit</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FunctionReturningS</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; &nbsp; &nbsp; &nbsp; S temp</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//store some data at 'temp' =
and 'return_value'</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; temp</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">pSomeMemory</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #080;" class=3D"styled-by-prettify">'9'</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; r=
eturn_value</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">pSomeMem=
ory</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">'6'</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//just exit the function (temp1 is re=
placed by 'return_value')</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; return_value</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">.~</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">S</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//calling explicit destructor on 'return_value'</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp;=
 &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">return_v=
alue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">S </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&amp;&amp;)</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">temp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//placement new, re-constructs 'return_value' by 'temp'</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbs=
p; &nbsp; S return_value</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
;</span></div></code></div><div><br></div><div>So you can instance the func=
tion like:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rgb=
(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250=
);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&amp;&amp;</span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">RetValue</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">return_value</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; cout </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">RetValue</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">pSomeMemory</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">RetValue1</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FunctionReturningS</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">false</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div=
></code></div><div><br><br>Thanks for your opinions anyway.</div></div></di=
v>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_864_1342336978.1418243757276--
------=_Part_863_1198208871.1418243757276--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 10 Dec 2014 13:46:24 -0800 (PST)
Raw View
------=_Part_3845_1332356562.1418247984683
Content-Type: multipart/alternative;
 boundary="----=_Part_3846_1104750265.1418247984683"

------=_Part_3846_1104750265.1418247984683
Content-Type: text/plain; charset=UTF-8

What would be useful is for a way to get the type of the return type of a
function.

std::vector<int> foo(int n) {
  decltype(return) v; //decltype(v) == std::vector<int>
  for(int i = 0; i < n; ++i) {
    v.push_back(i);
  }
  return v;
}



--

---
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_3846_1104750265.1418247984683
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>What would be useful is for a way to get the type of =
the return type of&nbsp;a function.</div><div>&nbsp;</div><div><div style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);" class=3D"prettyprint"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: rgb(0, 0, 0);" clas=
s=3D"styled-by-prettify">std</span><span style=3D"color: rgb(102, 102, 0);"=
 class=3D"styled-by-prettify">::</span><span style=3D"color: rgb(0, 0, 0);"=
 class=3D"styled-by-prettify">vector</span><span style=3D"color: rgb(0, 136=
, 0);" class=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color:=
 rgb(0, 0, 0);" class=3D"styled-by-prettify"> foo</span><span style=3D"colo=
r: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: rgb(0, 0, 136);" class=3D"styled-by-prettify">int</span><span style=
=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> n</span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">)</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{</span><span =
style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>&nbsp; </sp=
an><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">decl=
type</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pre=
ttify">return</span><span style=3D"color: rgb(102, 102, 0);" class=3D"style=
d-by-prettify">)</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled=
-by-prettify"> v</span><span style=3D"color: rgb(102, 102, 0);" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: rgb(136, 0, 0);" class=3D"st=
yled-by-prettify">//decltype(v) =3D=3D std::vector&lt;int&gt;</span><span s=
tyle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>&nbsp; </spa=
n><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">for</=
span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">=
(</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify"=
>int</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify=
"> i </span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: rgb(0, 102, 102);" class=3D"styled-by=
-prettify">0</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled=
-by-prettify">;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-=
by-prettify"> i </span><span style=3D"color: rgb(102, 102, 0);" class=3D"st=
yled-by-prettify">&lt;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"=
styled-by-prettify"> n</span><span style=3D"color: rgb(102, 102, 0);" class=
=3D"styled-by-prettify">;</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0);" cl=
ass=3D"styled-by-prettify">++</span><span style=3D"color: rgb(0, 0, 0);" cl=
ass=3D"styled-by-prettify">i</span><span style=3D"color: rgb(102, 102, 0);"=
 class=3D"styled-by-prettify">)</span><span style=3D"color: rgb(0, 0, 0);" =
class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0)=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: rgb(0, 0, 0);=
" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; v</span><span style=3D"col=
or: rgb(102, 102, 0);" class=3D"styled-by-prettify">.</span><span style=3D"=
color: rgb(0, 0, 0);" class=3D"styled-by-prettify">push_back</span><span st=
yle=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">i</span><span =
style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">);</span><s=
pan style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>&nbsp; =
</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify=
">}</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"=
><br>&nbsp; </span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-b=
y-prettify">return</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styl=
ed-by-prettify"> v</span><span style=3D"color: rgb(102, 102, 0);" class=3D"=
styled-by-prettify">;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: rgb(102, 102, 0);" clas=
s=3D"styled-by-prettify">}</span></div></code></div><br>&nbsp;</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_3846_1104750265.1418247984683--
------=_Part_3845_1332356562.1418247984683--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Wed, 10 Dec 2014 22:51:24 +0000
Raw View
What would happen with:

auto fn() {
  decltype (return) result;
  // ...
  return result;
}

On 12/10/14, Matthew Fioravante <fmatthew5876@gmail.com> wrote:
> What would be useful is for a way to get the type of the return type of a
> function.
>
> std::vector<int> foo(int n) {
>   decltype(return) v; //decltype(v) == std::vector<int>
>   for(int i = 0; i < n; ++i) {
>     v.push_back(i);
>   }
>   return v;
> }
>
>
>
> --
>
> ---
> 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/.
>

--

---
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/.

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 10 Dec 2014 15:00:13 -0800 (PST)
Raw View
------=_Part_2_758494308.1418252413488
Content-Type: multipart/alternative;
 boundary="----=_Part_3_550905964.1418252413489"

------=_Part_3_550905964.1418252413489
Content-Type: text/plain; charset=UTF-8


On Wednesday, December 10, 2014 5:51:26 PM UTC-5, Douglas Boffey wrote:
>
> What would happen with:
>
> auto fn() {
>   decltype (return) result;
>   // ...
>   return result;
> }
>

A compiler error of course. You can either deduce the return type from the
objects being returned (auto return type) or have a fixed return type and
do type deduction inside (decltype(return)).

--

---
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_3_550905964.1418252413489
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>On Wednesday, December 10, 2014 5:51:26 PM UTC-5, Doug=
las Boffey wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;" class=3D"gmail_quote">What would happen with:
<br>
<br>auto fn() {
<br>&nbsp; decltype (return) result;
<br>&nbsp; // ...
<br>&nbsp; return result;
<br>}
<br></blockquote><div>&nbsp;</div><div>A compiler error of course. You can =
either deduce the return type from the objects being returned (auto return =
type) or have a fixed return type and do type deduction inside (decltype(re=
turn)).</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_3_550905964.1418252413489--
------=_Part_2_758494308.1418252413488--

.


Author: Chet <chet.skolos@gmail.com>
Date: Wed, 10 Dec 2014 15:24:56 -0800 (PST)
Raw View
------=_Part_7552_1337290038.1418253896716
Content-Type: multipart/alternative;
 boundary="----=_Part_7553_269819164.1418253896716"

------=_Part_7553_269819164.1418253896716
Content-Type: text/plain; charset=UTF-8

What about this spelling instead:

std::vector<int> foo(int n) {
  decltype(foo(n)) v; //decltype(v) == std::vector<int>
  for(int i = 0; i < n; ++i) {
    v.push_back(i);
  }
  return v;
}

I tried it on ideone and it seems to work as expected.

On Wednesday, 10 December 2014 15:00:13 UTC-8, Matthew Fioravante wrote:
>
>
> On Wednesday, December 10, 2014 5:51:26 PM UTC-5, Douglas Boffey wrote:
>>
>> What would happen with:
>>
>> auto fn() {
>>   decltype (return) result;
>>   // ...
>>   return result;
>> }
>>
>
> A compiler error of course. You can either deduce the return type from the
> objects being returned (auto return type) or have a fixed return type and
> do type deduction inside (decltype(return)).
>

--

---
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_7553_269819164.1418253896716
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">What about this spelling instead:<div><br></div><div><div>=
std::vector&lt;int&gt; foo(int n) {</div><div>&nbsp; decltype(foo(n)) v; //=
decltype(v) =3D=3D std::vector&lt;int&gt;</div><div>&nbsp; for(int i =3D 0;=
 i &lt; n; ++i) {</div><div>&nbsp; &nbsp; v.push_back(i);</div><div>&nbsp; =
}</div><div>&nbsp; return v;</div><div>}</div><div><br></div><div>I tried i=
t on ideone and it seems to work as expected.&nbsp;</div><br>On Wednesday, =
10 December 2014 15:00:13 UTC-8, Matthew Fioravante  wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><br>On Wednesday, December 10=
, 2014 5:51:26 PM UTC-5, Douglas Boffey wrote:<blockquote style=3D"margin:0=
px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border=
-left-width:1px;border-left-style:solid" class=3D"gmail_quote">What would h=
appen with:
<br>
<br>auto fn() {
<br>&nbsp; decltype (return) result;
<br>&nbsp; // ...
<br>&nbsp; return result;
<br>}
<br></blockquote><div>&nbsp;</div><div>A compiler error of course. You can =
either deduce the return type from the objects being returned (auto return =
type) or have a fixed return type and do type deduction inside (decltype(re=
turn)).</div></div></blockquote></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_7553_269819164.1418253896716--
------=_Part_7552_1337290038.1418253896716--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 11 Dec 2014 18:09:53 -0800 (PST)
Raw View
------=_Part_47_705308233.1418350193790
Content-Type: multipart/alternative;
 boundary="----=_Part_48_5740591.1418350193790"

------=_Part_48_5740591.1418350193790
Content-Type: text/plain; charset=UTF-8



On Wednesday, December 10, 2014 6:24:56 PM UTC-5, Chet wrote:
>
> What about this spelling instead:
>
> std::vector<int> foo(int n) {
>   decltype(foo(n)) v; //decltype(v) == std::vector<int>
>   for(int i = 0; i < n; ++i) {
>     v.push_back(i);
>   }
>   return v;
> }
>

That works in this case but its still less than ideal. Type deduction lets
you reduce dependencies and your example still has a dependency on the
function name and arguments. Even worse if the arguments are changed this
might silently fail if it triggers a different overload. It also doesn't
work for lambda's and would be extremely clumsy for long function names and
templates.

--

---
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_48_5740591.1418350193790
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, December 10, 2014 6:24:56 PM UTC-5, =
Chet wrote:<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">Wh=
at about this spelling instead:<div><br></div><div><div>std::vector&lt;int&=
gt; foo(int n) {</div><div>&nbsp; decltype(foo(n)) v; //decltype(v) =3D=3D =
std::vector&lt;int&gt;</div><div>&nbsp; for(int i =3D 0; i &lt; n; ++i) {</=
div><div>&nbsp; &nbsp; v.push_back(i);</div><div>&nbsp; }</div><div>&nbsp; =
return v;</div><div>}</div></div></div></blockquote><div><br></div><div>Tha=
t works in this case but its still less than ideal. Type deduction lets you=
 reduce dependencies and your example still has a dependency on the functio=
n name and arguments. Even worse if the arguments are changed this might si=
lently fail if it triggers a different overload. It also doesn't work for l=
ambda's and would be extremely clumsy for long function names and templates=
..</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_48_5740591.1418350193790--
------=_Part_47_705308233.1418350193790--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Sun, 14 Dec 2014 21:28:35 +0330
Raw View
--001a1135f456236e00050a30e1fc
Content-Type: text/plain; charset=UTF-8

Don`t make it personal plz. Just try to 'adapt, adopt, and at the very end,
develope'. I am trying to say there is no strong motive to change how
modern C++ treats temporaries. The problem of unnecessarily copying
temporaries has been solved to the last bit for most (I tend to say all)
imaginable scenarios. The idea of named return variables is as old as
compiler design industry. I can instantly name a few long-lived languages
who have devised this feature. Ten years ago - when perfect forwarding was
a programming challenge -, a well-organised proposal on current article
might attract some attention. The 'rvalue refference' proposal and related
articles(move semantics...) have offered elegant solutions t a variety of
problems - including temporary recopying:

class a_heavy_type{
public:
      a_heavy_type(a_heavy_type&);//copy
      a_heavy_type(a_heavy_type&&);//move
      ...
};

a_heavy_type foo(){
      a_heavy_type result;
      ...
      return result;
};

int main()
{
      a_heavy_type a_heavy_object {foo()};
      ....
};

no copy occurs in the above sample code. So what are we going to optimize
with a new feature?

regards,
FM.



2014-12-08 23:31 GMT+03:30 sasho648 <sasho648@mail.bg>:
>
> I don't know what's your problem with the solution. Why implement those
> complex optimization as we can just add this feature (*compatible with
> old-code*) which will make them useless and perhaps lift the requirement
> that 'arrays' can't be returned (because they can't be copied so allowing
> them to be returned by value is useless as only constant expressions will
> be allowed to return). Also there is already such feature introduced with
> C++11 which made the "NRVO" useless - the 'rvalue' reference which when
> bound to a 'prvalue', as the function return one, extends it's life-time.
>
> So if this feature is introduced, arrays could be returned like this:
>
> int FuncReturningArrays()[5] return
> {
>     for(size_t i(0); i < 5; ++i)
>
>         return[i] = /*SomeValue*/;
> }
>
> The 'return' keyword will be also an specifier (like 'noexcept'), which
> when appear after a function declaration will specify that in the function
> 'return' won't be an statement but instead a variable naming the return
> value.
>
 --

---
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/.


--
how am I supposed to end the twisted road of  your hair in the dark night??
unless the candle of your face does turn a lamp up on my way!!!

--

---
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/.

--001a1135f456236e00050a30e1fc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"rtl"><div dir=3D"ltr">Don`t make it personal plz. Just try to &=
#39;adapt, adopt, and at the very end, develope&#39;. I am trying to say th=
ere is no strong motive to change how modern C++ treats temporaries. The pr=
oblem of unnecessarily copying temporaries has been solved to the last bit =
for most (I tend to say all) imaginable scenarios. The idea of named return=
 variables is as old as compiler design industry. I can instantly name a fe=
w long-lived languages who have devised this feature. Ten years ago - when =
perfect forwarding was a programming challenge -, a well-organised proposal=
 on current article might attract some attention. The &#39;rvalue refferenc=
e&#39; proposal and related articles(move semantics...) have offered elegan=
t solutions t a variety of problems - including temporary recopying:</div><=
div dir=3D"ltr"><br></div><div dir=3D"ltr">class a_heavy_type{</div><div di=
r=3D"ltr">public:</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 a_heavy_type(a=
_heavy_type&amp;);//copy</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 a_heavy=
_type(a_heavy_type&amp;&amp;);//move</div><div dir=3D"ltr">=C2=A0 =C2=A0 =
=C2=A0 ...</div><div dir=3D"ltr">};</div><div dir=3D"ltr"><br></div><div di=
r=3D"ltr">a_heavy_type foo(){</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 a_=
heavy_type result;</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 ...</div><div=
 dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 return result;</div><div dir=3D"ltr">};<b=
r></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">int main()</div><div di=
r=3D"ltr">{</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 a_heavy_type a_heavy=
_object {foo()};</div><div dir=3D"ltr">=C2=A0 =C2=A0 =C2=A0 ....</div><div =
dir=3D"ltr">};</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">no copy occ=
urs in the above sample code. So what are we going to optimize with a new f=
eature?</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">regards,</div><div=
 dir=3D"ltr">FM.</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div=
><div class=3D"gmail_extra"><div dir=3D"ltr"><br><div class=3D"gmail_quote"=
>2014-12-08 23:31 GMT+03:30 sasho648 <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:sasho648@mail.bg" target=3D"_blank">sasho648@mail.bg</a>&gt;</span>:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex">I don&#39;t know what&#39;s your problem with the=
 solution. Why implement those complex optimization as we can just add this=
 feature (<b>compatible with old-code</b>) which will make them useless and=
 perhaps lift the requirement that &#39;arrays&#39; can&#39;t be returned (=
because they can&#39;t be copied so allowing them to be returned by value i=
s useless as only constant expressions will be allowed to return). Also the=
re is already such feature introduced with C++11 which made the=C2=A0&quot;=
NRVO&quot; useless - the &#39;rvalue&#39; reference which when bound to a &=
#39;prvalue&#39;, as the function return one, extends it&#39;s life-time.<d=
iv><br></div><div>So if this feature is introduced, arrays could be returne=
d like this:<br><br></div><div style=3D"border:1px solid rgb(187,187,187);w=
ord-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span sty=
le=3D"color:#008">int</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">FuncReturningArrays</span><span style=3D"color:#660">()[</s=
pan><span style=3D"color:#066">5</span><span style=3D"color:#660">]</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">return</span><=
span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>for</span><span style=3D"color:#660">(</span><span style=3D"color:#000">si=
ze_t i</span><span style=3D"color:#660">(</span><span style=3D"color:#066">=
0</span><span style=3D"color:#660">);</span><span style=3D"color:#000"> i <=
/span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#066">5</span><span style=3D"color:#660">;</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">++</span><span=
 style=3D"color:#000">i</span><span style=3D"color:#660">)</span><span styl=
e=3D"color:#000"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color:#008">return</span><span style=3D"color:#660">[</span><span style=3D"=
color:#000">i</span><span style=3D"color:#660">]</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#800">/*SomeValue*/</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">}</span></div></code></div><div><br></div><div>The &#39;return&#39=
; keyword will be also an specifier (like &#39;noexcept&#39;), which when a=
ppear after a function declaration will specify that in the function &#39;r=
eturn&#39; won&#39;t be an statement but instead a variable naming the retu=
rn value.</div></blockquote></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&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></div><br clear=3D"all"><div><br></div>-- <br><div><div dir=3D"=
ltr">how am I supposed to end the twisted road of=C2=A0 your hair in the da=
rk night??<br>unless the candle of your face does turn a lamp up on my way!=
!!<br></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--001a1135f456236e00050a30e1fc--

.


Author: sasho648 <sasho648@mail.bg>
Date: Sun, 14 Dec 2014 10:40:29 -0800 (PST)
Raw View
------=_Part_324_831078286.1418582429104
Content-Type: multipart/alternative;
 boundary="----=_Part_325_699112714.1418582429104"

------=_Part_325_699112714.1418582429104
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Have you been following the discussion. Read the text, quoted above - I=20
already gave up the idea because it seemed it can be already simulated:

10 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=
=8F=D0=B4=D0=B0, 22:35:57 UTC+2, sasho648 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0:
>
> Never mind. It seems I actually find a way to implement this without the=
=20
> need of introducing a new syntax by using class constructors like this:
>
> struct FunctionReturningS
> {
>     explicit FunctionReturningS(bool b)
>     {
>         S temp;
>
>         //store some data at 'temp' and 'return_value'
>
>         temp.pSomeMemory[0] =3D '9';
>
>         return_value.pSomeMemory[5] =3D '6';
>
>         if(!b) return; //just exit the function (temp1 is replaced by=20
> 'return_value')
>
>         return_value.~S(); //calling explicit destructor on 'return_value=
'
>
>         new (&return_value) S((S &&)temp); //placement new, re-constructs=
=20
> 'return_value' by 'temp'
>     }
>
>
>     S return_value;
> };
>
> So you can instance the function like:
>
> int main()
> {
>     auto &&RetValue =3D FunctionReturningS(true).return_value;
>
>     cout << RetValue.pSomeMemory[0] << endl;
>
>     auto &&RetValue1 =3D FunctionReturningS(false);
>
>     return 0;
> }
>
>
> Thanks for your opinions anyway.
>

--=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_325_699112714.1418582429104
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Have you been following the discussion. Read the text, quo=
ted above - I already gave up the idea because it seemed it can be already =
simulated:<br><br>10 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014,=
 =D1=81=D1=80=D1=8F=D0=B4=D0=B0, 22:35:57 UTC+2, sasho648 =D0=BD=D0=B0=D0=
=BF=D0=B8=D1=81=D0=B0:<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">Never mind. It seems I actually find a way to implement this witho=
ut the need of introducing a new syntax by using class constructors like th=
is:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-=
word;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#00=
8">struct</span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">FunctionReturningS</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </sp=
an><span style=3D"color:#008">explicit</span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">FunctionReturningS</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#008">bool</span><span style=3D"color=
:#000"> b</span><span style=3D"color:#660">)</span><span style=3D"color:#00=
0"><br>&nbsp; &nbsp; </span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; S temp</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp=
; &nbsp; </span><span style=3D"color:#800">//store some data at 'temp' and =
'return_value'</span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp=
; &nbsp; temp</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">pSomeMemory</span><span style=3D"color:#660">[</span><span style=3D"=
color:#066">0</span><span style=3D"color:#660">]</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#080">'9'</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; ret=
urn_value</span><span style=3D"color:#660">.</span><span style=3D"color:#00=
0">pSomeMemory</span><span style=3D"color:#660">[</span><span style=3D"colo=
r:#066">5</span><span style=3D"color:#660">]</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
 </span><span style=3D"color:#080">'6'</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span>=
<span style=3D"color:#008">if</span><span style=3D"color:#660">(!</span><sp=
an style=3D"color:#000">b</span><span style=3D"color:#660">)</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">return</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//just exit the function (temp1 is replaced by 'return_valu=
e')</span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; re=
turn_value</span><span style=3D"color:#660">.~</span><span style=3D"color:#=
000">S</span><span style=3D"color:#660">();</span><span style=3D"color:#000=
"> </span><span style=3D"color:#800">//calling explicit destructor on 'retu=
rn_value'</span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; &nbsp; &nb=
sp; </span><span style=3D"color:#008">new</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">(&amp;</span><span style=3D"color:#000">=
return_value</span><span style=3D"color:#660">)</span><span style=3D"color:=
#000"> S</span><span style=3D"color:#660">((</span><span style=3D"color:#00=
0">S </span><span style=3D"color:#660">&amp;&amp;)</span><span style=3D"col=
or:#000">temp</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">//placement new, re-constructs '=
return_value' by 'temp'</span><span style=3D"color:#000"><br>&nbsp; &nbsp; =
</span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><b=
r><br>&nbsp; &nbsp; S return_value</span><span style=3D"color:#660">;</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</span>=
</div></code></div><div><br></div><div>So you can instance the function lik=
e:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-w=
ord;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#008=
">int</span><span style=3D"color:#000"> main</span><span style=3D"color:#66=
0">()</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&amp;&amp;</span><span style=3D"color:#606">RetValue</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#606">FunctionReturnin=
gS</span><span style=3D"color:#660">(</span><span style=3D"color:#008">true=
</span><span style=3D"color:#660">).</span><span style=3D"color:#000">retur=
<wbr>n_value</span><span style=3D"color:#660">;</span><span style=3D"color:=
#000"><br><br>&nbsp; &nbsp; cout </span><span style=3D"color:#660">&lt;&lt;=
</span><span style=3D"color:#000"> </span><span style=3D"color:#606">RetVal=
ue</span><span style=3D"color:#660">.</span><span style=3D"color:#000">pSom=
eMemory</span><span style=3D"color:#660">[</span><span style=3D"color:#066"=
>0</span><span style=3D"color:#660">]</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> e=
ndl</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br=
><br>&nbsp; &nbsp; </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&amp;&amp;</span><span s=
tyle=3D"color:#606">RetValue1</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#606">FunctionReturningS</span><span style=3D"color:#660">(</=
span><span style=3D"color:#008">false</span><span style=3D"color:#660">);</=
span><span style=3D"color:#000"><br><br>&nbsp; &nbsp; </span><span style=3D=
"color:#008">return</span><span style=3D"color:#000"> </span><span style=3D=
"color:#066">0</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#660">}</span></div></code></div><d=
iv><br><br>Thanks for your opinions anyway.</div></div></div></blockquote><=
/div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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_325_699112714.1418582429104--
------=_Part_324_831078286.1418582429104--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Tue, 16 Dec 2014 21:49:28 +0330
Raw View
--001a1134c69c89d21b050a59672a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

sorry, I am a very hurried post reader. I just felt the need to reply a
direct question. By the way I did not mean that the idea is bad, just not
an emergency. that is why i believe it might get some attention 10 years
ago.

regards,
FM.

2014-12-14 22:10 GMT+03:30 sasho648 <sasho648@mail.bg>:
>
> Have you been following the discussion. Read the text, quoted above - I
> already gave up the idea because it seemed it can be already simulated:
>
> 10 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=
=8F=D0=B4=D0=B0, 22:35:57 UTC+2, sasho648 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0:
>
>> Never mind. It seems I actually find a way to implement this without the
>> need of introducing a new syntax by using class constructors like this:
>>
>> struct FunctionReturningS
>> {
>>     explicit FunctionReturningS(bool b)
>>     {
>>         S temp;
>>
>>         //store some data at 'temp' and 'return_value'
>>
>>         temp.pSomeMemory[0] =3D '9';
>>
>>         return_value.pSomeMemory[5] =3D '6';
>>
>>         if(!b) return; //just exit the function (temp1 is replaced by
>> 'return_value')
>>
>>         return_value.~S(); //calling explicit destructor on
>> 'return_value'
>>
>>         new (&return_value) S((S &&)temp); //placement new,
>> re-constructs 'return_value' by 'temp'
>>     }
>>
>>
>>     S return_value;
>> };
>>
>> So you can instance the function like:
>>
>> int main()
>> {
>>     auto &&RetValue =3D FunctionReturningS(true).return_value;
>>
>>     cout << RetValue.pSomeMemory[0] << endl;
>>
>>     auto &&RetValue1 =3D FunctionReturningS(false);
>>
>>     return 0;
>> }
>>
>>
>> Thanks for your opinions anyway.
>>
>  --

---
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/.


--=20
how am I supposed to end the twisted road of  your hair in the dark night??
unless the candle of your face does turn a lamp up on my way!!!

--=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/.

--001a1134c69c89d21b050a59672a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"rtl"><div dir=3D"ltr">sorry, I am a very hurried post reader. I=
 just felt the need to reply a direct question. By the way I did not mean t=
hat the idea is bad, just not an emergency. that is why i believe it might =
get some attention 10 years ago.</div><div dir=3D"ltr"><br></div><div dir=
=3D"ltr">regards,</div><div dir=3D"ltr">FM.</div></div><div class=3D"gmail_=
extra"><div dir=3D"ltr"><br><div class=3D"gmail_quote">2014-12-14 22:10 GMT=
+03:30 sasho648 <span dir=3D"ltr">&lt;<a href=3D"mailto:sasho648@mail.bg" t=
arget=3D"_blank">sasho648@mail.bg</a>&gt;</span>:<blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex">Have you been following the discussion. Read the text, quoted above - =
I already gave up the idea because it seemed it can be already simulated:<b=
r><br>10 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=
=80=D1=8F=D0=B4=D0=B0, 22:35:57 UTC+2, sasho648 =D0=BD=D0=B0=D0=BF=D0=B8=D1=
=81=D0=B0:<div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D=
"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr">Never mind. It seems I actually find a way to implement this=
 without the need of introducing a new syntax by using class constructors l=
ike this:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:=
break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"col=
or:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#606">FunctionReturningS</span><span style=3D"color:#000"><br></span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">explicit</span><span style=3D"color:#=
000"> </span><span style=3D"color:#606">FunctionReturningS</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#008">bool</span><span style=
=3D"color:#000"> b</span><span style=3D"color:#660">)</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 S temp</span><span =
style=3D"color:#660">;</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#800">//store some data at &#=
39;temp&#39; and &#39;return_value&#39;</span><span style=3D"color:#000"><b=
r><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 temp</span><span style=3D"color:#660">.</=
span><span style=3D"color:#000">pSomeMemory</span><span style=3D"color:#660=
">[</span><span style=3D"color:#066">0</span><span style=3D"color:#660">]</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39;9&#39;=
</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return_value</span><span style=3D"color:#660"=
>.</span><span style=3D"color:#000">pSomeMemory</span><span style=3D"color:=
#660">[</span><span style=3D"color:#066">5</span><span style=3D"color:#660"=
>]</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39;6&=
#39;</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">if</spa=
n><span style=3D"color:#660">(!</span><span style=3D"color:#000">b</span><s=
pan style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#008">return</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#800">//just exit the func=
tion (temp1 is replaced by &#39;return_value&#39;)</span><span style=3D"col=
or:#000"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return_value</span><span style=
=3D"color:#660">.~</span><span style=3D"color:#000">S</span><span style=3D"=
color:#660">();</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#800">//calling explicit destructor on &#39;return_value&#39;</span><spa=
n style=3D"color:#000"><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span sty=
le=3D"color:#008">new</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">(&amp;</span><span style=3D"color:#000">return_value</span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"> S</span><spa=
n style=3D"color:#660">((</span><span style=3D"color:#000">S </span><span s=
tyle=3D"color:#660">&amp;&amp;)</span><span style=3D"color:#000">temp</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#800">//placement new, re-constructs &#39;return_value&#3=
9; by &#39;temp&#39;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><br><=
br>=C2=A0 =C2=A0 S return_value</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#660">};</span></d=
iv></code></div><div><br></div><div>So you can instance the function like:<=
br><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word=
;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">i=
nt</span><span style=3D"color:#000"> main</span><span style=3D"color:#660">=
()</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">{=
</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"c=
olor:#008">auto</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">&amp;&amp;</span><span style=3D"color:#606">RetValue</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">FunctionReturningS</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#008">true</span>=
<span style=3D"color:#660">).</span><span style=3D"color:#000">retur<u></u>=
n_value</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
><br><br>=C2=A0 =C2=A0 cout </span><span style=3D"color:#660">&lt;&lt;</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#606">RetValue</s=
pan><span style=3D"color:#660">.</span><span style=3D"color:#000">pSomeMemo=
ry</span><span style=3D"color:#660">[</span><span style=3D"color:#066">0</s=
pan><span style=3D"color:#660">]</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> endl</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">auto</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">&amp;&amp;</span><span style=
=3D"color:#606">RetValue1</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">FunctionReturningS</span><span style=3D"color:#660">(</span=
><span style=3D"color:#008">false</span><span style=3D"color:#660">);</span=
><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or:#008">return</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#066">0</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">}</span></div></code></div><div><=
br><br>Thanks for your opinions anyway.</div></div></div></blockquote></div=
></div></blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></div><br clear=3D"all"><div><br></div>-- <br><div class=3D"gma=
il_signature"><div dir=3D"ltr">how am I supposed to end the twisted road of=
=C2=A0 your hair in the dark night??<br>unless the candle of your face does=
 turn a lamp up on my way!!!<br></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

--001a1134c69c89d21b050a59672a--

.