Topic: Error in example in N3857 "Improvements to std::future<T>
Author: Casey Carter <cartec69@gmail.com>
Date: Wed, 26 Mar 2014 08:40:18 -0700 (PDT)
Raw View
------=_Part_3360_11849772.1395848418170
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
The example given for when_all on page 10:
#include <future>=20
using namespace std;=20
=20
int main() {=20
shared_future<int> shared_future1 =3D async([] { return intResult(125); }=
);=20
future<string> future2 =3D async([]() { return stringResult(=E2=80=9Chi=
=E2=80=9D); });=20
future<tuple<shared_future<int>, future<string>>> all_f =3D=20
when_all(shared_future1, future2);=20
=20
future<int> result =3D all_f.then([](future<tuple<shared_future<int>, fut=
ure
<string>>> f) {=20
return doWork(f.get());=20
});=20
}
is incorrectly copying future2, since when_all accepts its parameters by=20
value but std::future is not copyable. It should be:
future<tuple<shared_future<int>, future<string>>> all_f =3D=20
when_all(shared_future1, std::move(future2));=20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_3360_11849772.1395848418170
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The example given for when_all on page 10:<div><br></=
div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #800;=
" class=3D"styled-by-prettify">#include</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"=
styled-by-prettify"><future></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> <br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">namespace</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> std</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><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</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">{</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> <br> shared_future</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> shared_future1 </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> async</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;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> intResult</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">125<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">});</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> <br><br> future</span><span =
style=3D"color: #080;" class=3D"styled-by-prettify"><string></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> future2 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> async</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"> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> stringResult</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(=E2=80=9C</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">hi</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=E2=80=9D);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">});</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br><br>&nb=
sp; future</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">shared_future</sp=
an><span style=3D"color: #080;" class=3D"styled-by-prettify"><int></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> future</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify"><string></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">>></span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> all_f </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> <br> when_all</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">shared_future1</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> future2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> <br> <br> future</span><=
span style=3D"color: #080;" class=3D"styled-by-prettify"><int></span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> result </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> all_f</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">then</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">([](</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">future</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">tuple</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">shared_future</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify"><int></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> future</span><span style=3D"color: #080;" class=3D"styled-by-prett=
ify"><string></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">>></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> f</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> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> doWork</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">f</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"sty=
led-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-pret=
tify"> <br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an></div></code></div><div><br>is incorrectly copying future2, since when_a=
ll accepts its parameters by value but std::future is not copyable. It shou=
ld be:</div><div><br></div><div><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> future</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">tuple</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">shared_future</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> future</span><span style=3D"colo=
r: #080;" class=3D"styled-by-prettify"><string></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">>></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> all_f </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> <br> when_all</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">shared_future1</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">move</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">future2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">));</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an></div></code></div><span class=3D"styled-by-prettify" style=3D"font-fami=
ly: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);">=
<br></span><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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_3360_11849772.1395848418170--
.
Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Thu, 27 Mar 2014 00:20:28 +0100
Raw View
--001a11c20decd404e904f58ab62c
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
From reading pages 16 and 17, I see that when_all() and when_any() take
"universal references" as Scott Meyer call them,
which basically mean that in the example you cite, IF I UNDERSTAND
CORRECTLY, shared_future1 and future2 are taken by reference.
It wouldn't make sense anyway if these functions would take futures by
copy, they need to manipulate the provided future instances anyway.
On Wed, Mar 26, 2014 at 4:40 PM, Casey Carter <cartec69@gmail.com> wrote:
> The example given for when_all on page 10:
>
> #include <future>
> using namespace std;
>
> int main() {
> shared_future<int> shared_future1 =3D async([] { return intResult(125);
> });
>
> future<string> future2 =3D async([]() { return stringResult(=E2=80=9Chi=
=E2=80=9D); });
>
> future<tuple<shared_future<int>, future<string>>> all_f =3D
> when_all(shared_future1, future2);
>
> future<int> result =3D all_f.then([](future<tuple<shared_future<int>, f=
uture
> <string>>> f) {
> return doWork(f.get());
> });
> }
>
> is incorrectly copying future2, since when_all accepts its parameters by
> value but std::future is not copyable. It should be:
>
> future<tuple<shared_future<int>, future<string>>> all_f =3D
> when_all(shared_future1, std::move(future2));
>
>
> --
>
> ---
> 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/.
--001a11c20decd404e904f58ab62c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">From reading pages 16 and 17, I see that when_all() and wh=
en_any() take "universal references" as Scott Meyer call them,<di=
v>which basically mean that in the example you cite, IF I UNDERSTAND CORREC=
TLY, shared_future1 and future2 are taken by reference.</div>
<div>It wouldn't make sense anyway if these functions would take future=
s by copy, they need to manipulate the provided future instances anyway.</d=
iv></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On W=
ed, Mar 26, 2014 at 4:40 PM, Casey Carter <span dir=3D"ltr"><<a href=3D"=
mailto:cartec69@gmail.com" target=3D"_blank">cartec69@gmail.com</a>></sp=
an> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">The example given for when_=
all=C2=A0on page 10:<div><br></div><div style=3D"background-color:rgb(250,2=
50,250);border:1px solid rgb(187,187,187);word-wrap:break-word">
<code><div><span style=3D"color:#800">#include</span><span style> </span><s=
pan style=3D"color:#080"><future></span><span style> <br></span><span=
style=3D"color:#008">using</span><span style> </span><span style=3D"color:=
#008">namespace</span><span style> std</span><span style=3D"color:#660">;</=
span><span style> <br>
=C2=A0<br></span><span style=3D"color:#008">int</span><span style> main</sp=
an><span style=3D"color:#660">()</span><span style> </span><span style=3D"c=
olor:#660">{</span><span style> <br>=C2=A0 shared_future</span><span style=
=3D"color:#080"><int></span><span style> shared_future1 </span><span =
style=3D"color:#660">=3D</span><span style> async</span><span style=3D"colo=
r:#660">([]</span><span style> </span><span style=3D"color:#660">{</span><s=
pan style> </span><span style=3D"color:#008">return</span><span style> intR=
esult</span><span style=3D"color:#660">(</span><span style=3D"color:#066">1=
25</span><span style=3D"color:#660">);</span><span style> </span><span styl=
e=3D"color:#660">});</span><span style> <br>
<br>=C2=A0 future</span><span style=3D"color:#080"><string></span><sp=
an style> future2 </span><span style=3D"color:#660">=3D</span><span style> =
async</span><span style=3D"color:#660">([]()</span><span style> </span><spa=
n style=3D"color:#660">{</span><span style> </span><span style=3D"color:#00=
8">return</span><span style> stringResult</span><span style=3D"color:#660">=
(=E2=80=9C</span><span style>hi</span><span style=3D"color:#660">=E2=80=9D)=
;</span><span style> </span><span style=3D"color:#660">});</span><span styl=
e> <br>
<br>=C2=A0 future</span><span style=3D"color:#660"><</span><span style>t=
uple</span><span style=3D"color:#660"><</span><span style>shared_future<=
/span><span style=3D"color:#080"><int></span><span style=3D"color:#66=
0">,</span><span style> future</span><span style=3D"color:#080"><string&=
gt;</span><span style=3D"color:#660">>></span><span style> all_f </sp=
an><span style=3D"color:#660">=3D</span><span style> <br>
=C2=A0 =C2=A0 when_all</span><span style=3D"color:#660">(</span><span style=
>shared_future1</span><span style=3D"color:#660">,</span><span style> futur=
e2</span><span style=3D"color:#660">);</span><span style> <br>=C2=A0<br>=C2=
=A0 future</span><span style=3D"color:#080"><int></span><span style> =
result </span><span style=3D"color:#660">=3D</span><span style> all_f</span=
><span style=3D"color:#660">.</span><span style=3D"color:#008">then</span><=
span style=3D"color:#660">([](</span><span style>future</span><span style=
=3D"color:#660"><</span><span style>tuple</span><span style=3D"color:#66=
0"><</span><span style>shared_future</span><span style=3D"color:#080">&l=
t;int></span><span style=3D"color:#660">,</span><span style> =C2=A0futur=
e</span><span style=3D"color:#080"><string></span><span style=3D"colo=
r:#660">>></span><span style> f</span><span style=3D"color:#660">)</s=
pan><span style> </span><span style=3D"color:#660">{</span><span style> <br=
>
=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style> d=
oWork</span><span style=3D"color:#660">(</span><span style>f</span><span st=
yle=3D"color:#660">.</span><span style=3D"color:#008">get</span><span style=
=3D"color:#660">());</span><span style> <br>
=C2=A0 </span><span style=3D"color:#660">});</span><span style> <br></span>=
<span style=3D"color:#660">}</span><span style><br></span></div></code></di=
v><div><br>is incorrectly copying future2, since when_all accepts its param=
eters by value but std::future is not copyable. It should be:</div>
<div><br></div><div><div style=3D"background-color:rgb(250,250,250);border:=
1px solid rgb(187,187,187);word-wrap:break-word"><code><div><span style>=C2=
=A0 future</span><span style=3D"color:#660"><</span><span style>tuple</s=
pan><span style=3D"color:#660"><</span><span style>shared_future</span><=
span style=3D"color:#080"><int></span><span style=3D"color:#660">,</s=
pan><span style> future</span><span style=3D"color:#080"><string></sp=
an><span style=3D"color:#660">>></span><span style> all_f </span><spa=
n style=3D"color:#660">=3D</span><span style> <br>
=C2=A0 =C2=A0 when_all</span><span style=3D"color:#660">(</span><span style=
>shared_future1</span><span style=3D"color:#660">,</span><span style> std</=
span><span style=3D"color:#660">::</span><span style>move</span><span style=
=3D"color:#660">(</span><span style>future2</span><span style=3D"color:#660=
">));</span><span class=3D"HOEnZb"><font color=3D"#888888"><span style> </s=
pan></font></span></div>
</code></div><span class=3D"HOEnZb"><font color=3D"#888888"><span style=3D"=
background-color:rgb(250,250,250);font-family:monospace"><br></span><br></f=
ont></span></div></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" 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></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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 />
--001a11c20decd404e904f58ab62c--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Wed, 26 Mar 2014 20:19:58 -0400
Raw View
On Wed, Mar 26, 2014 at 7:20 PM, Klaim - Jo=C3=ABl Lamotte <mjklaim@gmail.c=
om> wrote:
> From reading pages 16 and 17, I see that when_all() and when_any() take
> "universal references" as Scott Meyer call them,
> which basically mean that in the example you cite, IF I UNDERSTAND
> CORRECTLY, shared_future1 and future2 are taken by reference.
> It wouldn't make sense anyway if these functions would take futures by co=
py,
> they need to manipulate the provided future instances anyway.
No, they are taken by reference just to delay the copy (actually,
Boost implement these by taking values); the copy is mandated
for the return value:
(quote from the paper)
Effects:
Each future and shared_future is waited upon and then copied
into the collection of the output (returned) future, maintaining the
order of the futures in the input collection.
The term "copied" here seems to be problematic, the wording will
be carefully scanned anyway..., but the intention is clear, and the
`std::future` case needs an explicit `std::move`.
--=20
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/
--=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/.
.
Author: Casey Carter <cartec69@gmail.com>
Date: Thu, 27 Mar 2014 07:40:36 -0700 (PDT)
Raw View
------=_Part_152_28269845.1395931236830
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, March 26, 2014 6:20:28 PM UTC-5, Klaim - Jo=C3=ABl Lamotte wr=
ote:
>
> From reading pages 16 and 17, I see that when_all() and when_any() take=
=20
> "universal references" as Scott Meyer call them,
> which basically mean that in the example you cite, IF I UNDERSTAND=20
> CORRECTLY, shared_future1 and future2 are taken by reference.
> It wouldn't make sense anyway if these functions would take futures by=20
> copy, they need to manipulate the provided future instances anyway.
>
I stand corrected: both when_any and when_all are specified to have the=20
form:
template <typename... T>=20
see below when_all(T&&... futures);
with the additional requirement:
Requires: T is of type future<R> or shared_future<R>.=20
The implication is that when_all/when_any may only be called with rvalues.=
=20
Passing an lvalue would cause T to be deduced to e.g. future<R>& violating=
=20
the cited requirement.
--=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_152_28269845.1395931236830
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, March 26, 2014 6:20:28 PM UTC-5, Klaim - Jo=
=C3=ABl Lamotte 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">From reading pages 16 and 17, I see that when_all() and when_any()=
take "universal references" as Scott Meyer call them,<div>which basically =
mean that in the example you cite, IF I UNDERSTAND CORRECTLY, shared_future=
1 and future2 are taken by reference.</div>
<div>It wouldn't make sense anyway if these functions would take futures by=
copy, they need to manipulate the provided future instances anyway.</div><=
/div></blockquote><div><br></div><div>I stand corrected: both when_any and =
when_all are specified to have the form:</div><div><br></div><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">template</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: #008;" class=3D"styled-by-prettify">type=
name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> <br>see below when_all</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&&...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> futures</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><div><=
br>with the additional requirement:</div><div><br></div><div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: =
1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; paddi=
ng-left: 1ex;">Requires: T is of type future<R> or shared_future<R=
>. </blockquote></div><div><br></div><div>The implication is that w=
hen_all/when_any may only be called with rvalues. Passing an lvalue would c=
ause T to be deduced to e.g. future<R>& violating the cited requi=
rement.</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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_152_28269845.1395931236830--
.