Topic: Extending the scope of generalized lambda


Author: "D. B." <db0451@gmail.com>
Date: Thu, 15 Dec 2016 13:30:46 +0000
Raw View
--001a114ccb68019af10543b276c4
Content-Type: text/plain; charset=UTF-8

This sounds eminently sensible and desirable to me. After all, the return
type *trails after* the capture, so one would reasonably expect it to have
access to anything declared before that point.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhHTChb5fEw9svJgeOkd%3DyAJh9yU%2BaZdUOs_DaF%2BV%3DWR-g%40mail.gmail.com.

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

<div dir=3D"ltr">This sounds eminently sensible and desirable to me. After =
all, the return type <i>trails after</i> the capture, so one would reasonab=
ly expect it to have access to anything declared before that point.<br></di=
v>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhHTChb5fEw9svJgeOkd%3DyAJh9yU%2=
BaZdUOs_DaF%2BV%3DWR-g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhHT=
Chb5fEw9svJgeOkd%3DyAJh9yU%2BaZdUOs_DaF%2BV%3DWR-g%40mail.gmail.com</a>.<br=
 />

--001a114ccb68019af10543b276c4--

.


Author: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Date: Thu, 15 Dec 2016 09:00:35 -0800 (PST)
Raw View
------=_Part_331_582422957.1481821235805
Content-Type: multipart/alternative;
 boundary="----=_Part_332_640824950.1481821235806"

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



I would like to write a proposal, but I just realized that it would be a=20
breaking change:
http://melpon.org/wandbox/permlink/g9eAszk1SoGPA1Lf


struct Foo { };

int main()
{
    Foo x;
    auto l =3D [x =3D 10]() -> decltype(x) { return 10; };
} =20

If  the proposal is accepted, this code will behave differently!
This still feels very counter-intuitive though... I'm inclined to think=20
it's worth bringing this to the attention of the committee anyway.


On Thursday, 15 December 2016 13:27:06 UTC, Vittorio Romeo wrote:
>
> int main(){
>     auto l =3D [x =3D 10]() -> decltype(x) {};}
>
>
>
>
>    -=20
>   =20
>    *clang++ 4.0* rejects this code=20
>    <http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe> with the=20
>    following error:
>    -=20
>   =20
>    error: use of undeclared identifier 'x'
>            auto l =3D [x =3D 10]() -> decltype(x) {};
>                                            ^
>   =20
>    -=20
>   =20
>    *g++ 7* rejects this code=20
>    <http://melpon.org/wandbox/permlink/LXamt4MieU6n77Xs> with the=20
>    following error:
>   =20
>    In function 'int main()':
>    error: 'x' was not declared in this scope
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>    error: 'x' was not declared in this scopeIn lambda function:
>    warning: no return statement in function returning non-void [-Wreturn-=
type]
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>   =20
>   =20
>   =20
> I posted this today on StackOverflow thinking it was a compiler bug:
> http://stackoverflow.com/questions/41162200/
>
> But it's not - the standard says that the scope of `x` is limited to the=
=20
> body of the lambda. This answer has the details:=20
> http://stackoverflow.com/a/41162972/598696
> (quoted below)
>
> ---
>
> *TL;DR*: Compilers behave as expected.
>
> The standard defines lambda semantics as follows [expr.prim.lambda,=20
> section 1]:
>
> lambda-expression:
>
>    lambda-introducer lambda-declarator_opt compound-statement
>
> Here *compound-statement* is just the body of lambda between {}, because=
=20
> everything else is included in *lambda-declarator*:
>
> lambda-declarator:
>
>    ( parameter-declaration-clause ) decl-specifier-seq_opt
>        exception-specification_opt attribute-specifier-seq_opt trailing-r=
eturn-type_opt
>
> Also, in section 12 of the same chapter, it's said that
>
> An init-capture behaves as if it declares and explicitly captures a=20
> variable of the form =E2=80=9Cauto init-capture ;=E2=80=9D whose declarat=
ive region is the=20
> lambda-expression=E2=80=99s compound-statement, except that:
>
> (12.1) =E2=80=94 if the capture is by copy (see below), the non-static da=
ta member=20
> declared for the capture and the variable are treated as two different wa=
ys=20
> of referring to the same object, which has the lifetime of the non-static=
=20
> data member, and no additional copy and destruction is performed, and
>
> (12.2) =E2=80=94 if the capture is by reference, the variable=E2=80=99s l=
ifetime ends when=20
> the closure object=E2=80=99s lifetime ends.
>
> So, in your first example, variable x scope is the lambda body only, not=
=20
> including the decltypeexpression. In the second example, obviously, x sco=
pe=20
> is the function main.
>
> ---
>
> Do you think that writing a proposal to relax these rules and to=20
> explicitly allow generalized captures to be used inside the trailing retu=
rn=20
> type would be worthwhile?
>
> One possible use case is when the generalized captures are initialized=20
> with complex expressions. I encountered this while experimenting today (
> http://melpon.org/wandbox/permlink/aVasfHaK6boC6NZt).
> In general, it would be beneficial to have this feature whenever the=20
> generalized capture is used as part of the return expression in the lambd=
a=20
> body.
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/db5c50d4-3ca2-4ad9-8431-04d48326f51f%40isocpp.or=
g.

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

<div dir=3D"ltr"><p style=3D"color: rgb(0, 0, 0); font-family: Calibri, Ari=
al, Helvetica, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Em=
oji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji=
&quot;, EmojiSymbols; font-size: 16px;">I would like to write a proposal, b=
ut I just realized that it would be a breaking change:<br><a href=3D"http:/=
/melpon.org/wandbox/permlink/g9eAszk1SoGPA1Lf" class=3D"OWAAutoLink" id=3D"=
LPlnk672857" previewremoved=3D"true">http://melpon.org/wandbox/permlink/g9e=
Aszk1SoGPA1Lf</a></p><p style=3D"color: rgb(0, 0, 0); font-family: Calibri,=
 Arial, Helvetica, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe U=
I Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android E=
moji&quot;, EmojiSymbols; font-size: 16px;"><br></p><p style=3D"color: rgb(=
0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif, &quot;Apple C=
olor Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe U=
I Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: 16px;">=
</p><div><span style=3D"font-family: Consolas, monospace;">struct Foo { };<=
/span></div><div><br></div><div><span style=3D"font-family: Consolas, monos=
pace;">int main()</span></div><div><span style=3D"font-family: Consolas, mo=
nospace;">{</span></div><div><span style=3D"font-family: Consolas, monospac=
e;">=C2=A0 =C2=A0 Foo x;</span></div><div><span style=3D"font-family: Conso=
las, monospace;">=C2=A0 =C2=A0 auto l =3D [x =3D 10]() -&gt; decltype(x) { =
return 10; };</span></div><div><span style=3D"font-family: Consolas, monosp=
ace;">} =C2=A0</span></div><div></div><br><p></p><p style=3D"color: rgb(0, =
0, 0); font-family: Calibri, Arial, Helvetica, sans-serif, &quot;Apple Colo=
r Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe UI S=
ymbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols; font-size: 16px;">If =
=C2=A0the proposal is accepted, this code will behave differently!<br>This =
still feels very counter-intuitive though...=C2=A0I&#39;m inclined to think=
 it&#39;s worth=C2=A0bringing this to the attention of the committee anyway=
..</p><div><br></div><br>On Thursday, 15 December 2016 13:27:06 UTC, Vittori=
o Romeo  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=
"><pre class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><code style=3D"font-family:Con=
solas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&=
quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Cour=
ier New&quot;,monospace,sans-serif;white-space:inherit"><span style=3D"colo=
r:rgb(43,145,175)">int</span><span style=3D"color:rgb(48,51,54)"> main</spa=
n><span style=3D"color:rgb(48,51,54)">()</span><span style=3D"color:rgb(48,=
51,54)">
</span><span style=3D"color:rgb(48,51,54)">{</span><span style=3D"color:rgb=
(48,51,54)">
    </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"c=
olor:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span=
><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51=
,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"c=
olor:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><=
span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51=
,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"=
color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </spa=
n><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:=
rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </=
span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb=
(48,51,54)">
</span><span style=3D"color:rgb(48,51,54)">}
</span></code></pre><br><br><ul style=3D"margin:0px 0px 1em 30px;padding:0p=
x;border:0px;font-size:15px;font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;color:rgb(36,39,41)"><li style=3D"margin:0px 0px 0.5em;p=
adding:0px;border:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=
=3D"http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe" rel=3D"nofollow" s=
tyle=3D"color:rgb(0,89,153);font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;font-size:15px" target=3D"_blank" onmousedown=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%=
2Fpermlink%2FzsFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWA=
WY4JcXh_a1opBWZW0-WwRMw&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2Fz=
sFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWAWY4JcXh_a1opBW=
ZW0-WwRMw&#39;;return true;"><strong style=3D"color:rgb(0,89,153);font-fami=
ly:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15px">cl=
ang++ 4.0</strong><font color=3D"#005999" style=3D"color:rgb(0,89,153);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15p=
x"><span>=C2=A0rejects this code</span></font></a><font color=3D"#242729" f=
ace=3D"Arial, Helvetica Neue, Helvetica, sans-serif"><span style=3D"font-si=
ze:15px">=C2=A0with the following error:</span></font><br></p></li><li styl=
e=3D"margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word"><pre=
 style=3D"margin-top:0.5em;margin-bottom:1em;padding:5px;font-size:13px;wid=
th:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,&q=
uot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono=
&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospa=
ce,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wr=
ap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot;Lucida Co=
nsole&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;=
Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif=
;white-space:inherit"><span style=3D"color:rgb(48,51,54)">error</span><span=
 style=3D"color:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">=
 use of undeclared identifier </span><span style=3D"color:rgb(125,39,39)">&=
#39;x&#39;</span><span style=3D"color:rgb(48,51,54)">
        </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=
=3D"color:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D<=
/span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(=
48,51,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=
=3D"color:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </s=
pan><span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(=
48,51,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span styl=
e=3D"color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> =
</span><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"c=
olor:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><sp=
an style=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)=
"> </span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"colo=
r:rgb(48,51,54)">
                                        </span><span style=3D"color:rgb(48,=
51,54)">^</span></code></pre></li><li style=3D"margin:0px;padding:0px;borde=
r:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=3D"http://melpo=
n.org/wandbox/permlink/LXamt4MieU6n77Xs" rel=3D"nofollow" style=3D"color:rg=
b(0,89,153)" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.g=
oogle.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4Mie=
U6n77Xs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFB=
w&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?=
q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4MieU6n77Xs\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFBw&#39;;return =
true;"><strong>g++ 7</strong>=C2=A0rejects this code</a>=C2=A0with the foll=
owing error:</p><pre style=3D"margin-top:0.5em;margin-bottom:1em;padding:5p=
x;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Cons=
olas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&q=
uot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Couri=
er New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:r=
gb(57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Mo=
naco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sa=
ns Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,=
monospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(43,145,1=
75)">In</span><span style=3D"color:rgb(48,51,54)"> function </span><span st=
yle=3D"color:rgb(125,39,39)">&#39;int main()&#39;</span><span style=3D"colo=
r:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
</span><span style=3D"color:rgb(43,145,175)">In</span><span style=3D"color:=
rgb(48,51,54)"> lambda function</span><span style=3D"color:rgb(48,51,54)">:=
</span><span style=3D"color:rgb(48,51,54)">
warning</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"co=
lor:rgb(48,51,54)"> no </span><span style=3D"color:rgb(16,16,148)">return</=
span><span style=3D"color:rgb(48,51,54)"> statement in function returning n=
on</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(16,16,148)">void</span><span style=3D"color:rgb(48,51,54)"> </span><span=
 style=3D"color:rgb(48,51,54)">[-</span><span style=3D"color:rgb(43,145,175=
)">Wreturn</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D=
"color:rgb(48,51,54)">type</span><span style=3D"color:rgb(48,51,54)">]</spa=
n><span style=3D"color:rgb(48,51,54)">
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span></code></pre><br></li></ul><font color=3D"#303336" face=3D"Consol=
as, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitst=
ream Vera Sans Mono, Courier New, monospace, sans-serif"><span style=3D"whi=
te-space:pre">I posted this today on StackOverflow thinking it was a compil=
er bug:</span></font><div><font color=3D"#303336" face=3D"Consolas, Menlo, =
Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera S=
ans Mono, Courier New, monospace, sans-serif"><span style=3D"white-space:pr=
e"><a href=3D"http://stackoverflow.com/questions/41162200/" target=3D"_blan=
k" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/u=
rl?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true=
;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F=
stackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true;">http://stackoverfl=
ow.com/<wbr>questions/41162200/</a></span><br></font></div><div><font color=
=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mo=
no, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, san=
s-serif"><span style=3D"white-space:pre"><br></span></font></div><div><font=
 color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberat=
ion Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospac=
e, sans-serif"><span style=3D"white-space:pre">But it&#39;s not - the stand=
ard says that the scope of `x` is limited to the body of the lambda. This a=
nswer has the details:</span>
</font></div><div><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, =
Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono=
, Courier New, monospace, sans-serif"><span style=3D"white-space:pre"><a hr=
ef=3D"http://stackoverflow.com/a/41162972/598696" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fstackoverflow.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d=
1\x26usg\x3dAFQjCNEkofXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverf=
low.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEko=
fXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;">http://stackoverflow.com/a/<wb=
r>41162972/598696</a></span><br></font></div><div><font color=3D"#303336" f=
ace=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu San=
s Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif"><span=
 style=3D"white-space:pre">(quoted below)</span></font></div><div><font col=
or=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation =
Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, s=
ans-serif"><span style=3D"white-space:pre"><br></span></font></div><div><fo=
nt color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liber=
ation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monosp=
ace, sans-serif"><span style=3D"white-space:pre">---</span></font></div><di=
v><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, =
Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, m=
onospace, sans-serif"><span style=3D"white-space:pre"><br></span></font></d=
iv><div><p style=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(3=
6,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"=
><strong>TL;DR</strong>: Compilers behave as expected.</p><p style=3D"margi=
n-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Aria=
l,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">The standard defines lam=
bda semantics as follows [expr.prim.lambda, section 1]:</p><blockquote styl=
e=3D"margin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-t=
op-style:initial;border-right-style:initial;border-bottom-style:initial;bor=
der-left-style:solid;border-top-color:initial;border-right-color:initial;bo=
rder-bottom-color:initial;border-left-color:rgb(255,235,142);font-size:15px=
;quotes:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-fam=
ily:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"marg=
in-bottom:1em;clear:both">lambda-expression:</p><pre style=3D"padding:5px;f=
ont-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consola=
s,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot=
;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier =
New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(=
57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monac=
o,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans =
Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mon=
ospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">=
   lambda</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"=
color:rgb(48,51,54)">introducer lambda</span><span style=3D"color:rgb(48,51=
,54)">-</span><span style=3D"color:rgb(48,51,54)">declarator_opt compound</=
span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(4=
8,51,54)">statement</span></code></pre></blockquote><p style=3D"margin-bott=
om:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quo=
t;Helvetica Neue&quot;,Helvetica,sans-serif">Here=C2=A0<em>compound-stateme=
nt</em>=C2=A0is just the body of lambda between {}, because everything else=
 is included in=C2=A0<em>lambda-declarator</em>:</p><blockquote style=3D"ma=
rgin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-top-styl=
e:initial;border-right-style:initial;border-bottom-style:initial;border-lef=
t-style:solid;border-top-color:initial;border-right-color:initial;border-bo=
ttom-color:initial;border-left-color:rgb(255,235,142);font-size:15px;quotes=
:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-family:Ari=
al,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"margin-bott=
om:1em;clear:both">lambda-declarator:</p><pre style=3D"padding:5px;font-siz=
e:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,2=
4);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot=
;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&qu=
ot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,=
sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">   </sp=
an><span style=3D"color:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,=
51,54)"> parameter</span><span style=3D"color:rgb(48,51,54)">-</span><span =
style=3D"color:rgb(48,51,54)">declaration</span><span style=3D"color:rgb(48=
,51,54)">-</span><span style=3D"color:rgb(48,51,54)">clause </span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> de=
cl</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(48,51,54)">specifier</span><span style=3D"color:rgb(48,51,54)">-</span><=
span style=3D"color:rgb(48,51,54)">seq_opt
       exception</span><span style=3D"color:rgb(48,51,54)">-</span><span st=
yle=3D"color:rgb(48,51,54)">specification_opt attribute</span><span style=
=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">specif=
ier</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:=
rgb(48,51,54)">seq_opt trailing</span><span style=3D"color:rgb(48,51,54)">-=
</span><span style=3D"color:rgb(16,16,148)">return</span><span style=3D"col=
or:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">type_opt</spa=
n></code></pre></blockquote><p style=3D"margin-bottom:1em;font-size:15px;cl=
ear:both;color:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,H=
elvetica,sans-serif">Also, in section 12 of the same chapter, it&#39;s said=
 that</p><blockquote style=3D"margin:0px 0px 10px;padding:10px;border-width=
:0px 0px 0px 2px;border-top-style:initial;border-right-style:initial;border=
-bottom-style:initial;border-left-style:solid;border-top-color:initial;bord=
er-right-color:initial;border-bottom-color:initial;border-left-color:rgb(25=
5,235,142);font-size:15px;quotes:none;background-color:rgb(255,248,220);col=
or:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,san=
s-serif"><p style=3D"margin-bottom:1em;clear:both">An init-capture behaves =
as if it declares and explicitly captures a variable of the form =E2=80=9Ca=
uto init-capture ;=E2=80=9D whose declarative region is the lambda-expressi=
on=E2=80=99s compound-statement, except that:</p><p style=3D"margin-bottom:=
1em;clear:both">(12.1) =E2=80=94 if the capture is by copy (see below), the=
 non-static data member declared for the capture and the variable are treat=
ed as two different ways of referring to the same object, which has the lif=
etime of the non-static data member, and no additional copy and destruction=
 is performed, and</p><p style=3D"clear:both">(12.2) =E2=80=94 if the captu=
re is by reference, the variable=E2=80=99s lifetime ends when the closure o=
bject=E2=80=99s lifetime ends.</p></blockquote><p style=3D"margin-bottom:1e=
m;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quot;Hel=
vetica Neue&quot;,Helvetica,sans-serif">So, in your first example, variable=
=C2=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Me=
nlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;Dej=
aVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&=
quot;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pr=
e-wrap">x</code>=C2=A0scope is the lambda body only, not including the=C2=
=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-w=
rap">decltype</code>expression. In the second example, obviously,=C2=A0<cod=
e style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo,Monaco=
,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans M=
ono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mono=
space,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">x<=
/code>=C2=A0scope is the function=C2=A0<code style=3D"padding:1px 5px;font-=
size:13px;font-family:Consolas,Menlo,Monaco,&quot;Lucida Console&quot;,&quo=
t;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera S=
ans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif;background-colo=
r:rgb(239,240,241);white-space:pre-wrap">main</code>.</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">---</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">Do you think that writing=
 a proposal to relax these rules and to explicitly allow generalized captur=
es to be used inside the trailing return type would be worthwhile?</p><p st=
yle=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">One possible=
 use case is when the generalized captures are initialized with complex exp=
ressions. I encountered this while experimenting today (<a href=3D"http://m=
elpon.org/wandbox/permlink/aVasfHaK6boC6NZt" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A=
%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz=
\x3d1\x26usg\x3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.o=
rg%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;">http://melpon.org/w=
andbox/<wbr>permlink/aVasfHaK6boC6NZt</a>).<br>In general, it would be bene=
ficial to have this feature whenever the generalized capture is used as par=
t of the return expression in the lambda body.</p></div></div></blockquote>=
</div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/db5c50d4-3ca2-4ad9-8431-04d48326f51f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/db5c50d4-3ca2-4ad9-8431-04d48326f51f=
%40isocpp.org</a>.<br />

------=_Part_332_640824950.1481821235806--

------=_Part_331_582422957.1481821235805--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 15 Dec 2016 09:10:56 -0800 (PST)
Raw View
------=_Part_393_1191957542.1481821856841
Content-Type: multipart/alternative;
 boundary="----=_Part_394_1631465146.1481821856841"

------=_Part_394_1631465146.1481821856841
Content-Type: text/plain; charset=UTF-8



On Thursday, December 15, 2016 at 12:00:35 PM UTC-5, Vittorio Romeo wrote:
>
> I would like to write a proposal, but I just realized that it would be a
> breaking change:
> http://melpon.org/wandbox/permlink/g9eAszk1SoGPA1Lf
>
>
> struct Foo { };
>
> int main()
> {
>     Foo x;
>     auto l = [x = 10]() -> decltype(x) { return 10; };
> }
>
> If  the proposal is accepted, this code will behave differently!
> This still feels very counter-intuitive though... I'm inclined to think
> it's worth bringing this to the attention of the committee anyway.
>
>
Wait a minute. This *wouldn't* have been a breaking change until C++14.
Back then, if you declared a capture, then there *must* have been a
variable outside the lambda with that exact name and type. So in that case,
`[x]() -> decltype(x) {...}` would be fine, since `lambda::x` and `x` have
the same type.

It was C++14's generalized lambda capture that made it *possible* for
`lambda::x` and `x` to have different types. So the fact that it represents
a breaking change may not be that important.

I agree that you should try to move forward on it. If the committee wants
to reject it due to being a breaking change, so be it. But you should note
that it is only breaking when using generalized capture.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1ecc764b-3dce-49ff-86b0-4d1505138fd0%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Thursday, December 15, 2016 at 12:00:35 PM UTC-=
5, Vittorio Romeo wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><p style=3D"color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica=
,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoCo=
lorEmoji,&quot;Segoe UI Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols=
;font-size:16px">I would like to write a proposal, but I just realized that=
 it would be a breaking change:<br><a href=3D"http://melpon.org/wandbox/per=
mlink/g9eAszk1SoGPA1Lf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwa=
ndbox%2Fpermlink%2Fg9eAszk1SoGPA1Lf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NEXRbzdXhldonpALH6E9xwzcko6ig&#39;;return true;" onclick=3D"this.href=3D&#3=
9;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermli=
nk%2Fg9eAszk1SoGPA1Lf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEXRbzdXhldonp=
ALH6E9xwzcko6ig&#39;;return true;">http://melpon.org/wandbox/<wbr>permlink/=
g9eAszk1SoGPA1Lf</a></p><p style=3D"color:rgb(0,0,0);font-family:Calibri,Ar=
ial,Helvetica,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji=
&quot;,NotoColorEmoji,&quot;Segoe UI Symbol&quot;,&quot;Android Emoji&quot;=
,EmojiSymbols;font-size:16px"><br></p><p style=3D"color:rgb(0,0,0);font-fam=
ily:Calibri,Arial,Helvetica,sans-serif,&quot;Apple Color Emoji&quot;,&quot;=
Segoe UI Emoji&quot;,NotoColorEmoji,&quot;Segoe UI Symbol&quot;,&quot;Andro=
id Emoji&quot;,EmojiSymbols;font-size:16px"></p><div><span style=3D"font-fa=
mily:Consolas,monospace">struct Foo { };</span></div><div><br></div><div><s=
pan style=3D"font-family:Consolas,monospace">int main()</span></div><div><s=
pan style=3D"font-family:Consolas,monospace">{</span></div><div><span style=
=3D"font-family:Consolas,monospace">=C2=A0 =C2=A0 Foo x;</span></div><div><=
span style=3D"font-family:Consolas,monospace">=C2=A0 =C2=A0 auto l =3D [x =
=3D 10]() -&gt; decltype(x) { return 10; };</span></div><div><span style=3D=
"font-family:Consolas,monospace">} =C2=A0</span></div><div></div><br><p></p=
><p style=3D"color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-seri=
f,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&=
quot;Segoe UI Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols;font-size=
:16px">If =C2=A0the proposal is accepted, this code will behave differently=
!<br>This still feels very counter-intuitive though...=C2=A0I&#39;m incline=
d to think it&#39;s worth=C2=A0bringing this to the attention of the commit=
tee anyway.</p><br></div></blockquote><div><br>Wait a minute. This <i>would=
n&#39;t</i> have been a breaking change until C++14. Back then, if you decl=
ared a capture, then there <i>must</i> have been a variable outside the lam=
bda with that exact name and type. So in that case, `[x]() -&gt; decltype(x=
) {...}` would be fine, since `lambda::x` and `x` have the same type.<br><b=
r>It was C++14&#39;s generalized lambda capture that made it <i>possible</i=
> for `lambda::x` and `x` to have different types. So the fact that it repr=
esents a breaking change may not be that important.<br><br>I agree that you=
 should try to move forward on it. If the committee wants to reject it due =
to being a breaking change, so be it. But you should note that it is only b=
reaking when using generalized capture.<br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1ecc764b-3dce-49ff-86b0-4d1505138fd0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1ecc764b-3dce-49ff-86b0-4d1505138fd0=
%40isocpp.org</a>.<br />

------=_Part_394_1631465146.1481821856841--

------=_Part_393_1191957542.1481821856841--

.


Author: "D. B." <db0451@gmail.com>
Date: Thu, 15 Dec 2016 17:13:49 +0000
Raw View
--001a1145b1beb99da80543b5930c
Content-Type: text/plain; charset=UTF-8

Perhaps it could even be classed as a defect.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908fKbkC%3DhKriPMCcUeqw%40mail.gmail.com.

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

<div dir=3D"ltr">Perhaps it could even be classed as a defect.<br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908=
fKbkC%3DhKriPMCcUeqw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vn=
KUcVg9Uu%3Dy%2BWvPsNLVG908fKbkC%3DhKriPMCcUeqw%40mail.gmail.com</a>.<br />

--001a1145b1beb99da80543b5930c--

.


Author: =?UTF-8?Q?Micha=C5=82_Dominiak?= <griwes@griwes.info>
Date: Thu, 15 Dec 2016 17:20:42 +0000
Raw View
--001a113cf89af185e90543b5ac36
Content-Type: text/plain; charset=UTF-8

I agree that it could be classified as a defect, especially since `auto
foo(int x) -> decltype(x)` is one of the main advertised uses of late
return types, which this is inconsistent with.

On Thu, Dec 15, 2016 at 6:13 PM D. B. <db0451@gmail.com> wrote:

> Perhaps it could even be classed as a defect.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908fKbkC%3DhKriPMCcUeqw%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908fKbkC%3DhKriPMCcUeqw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdTqQupm%2BuzmO7dz_EihEDEuV6yaWbWHT%3D7b70dtKyHnQg%40mail.gmail.com.

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

<div dir=3D"ltr">I agree that it could be classified as a defect, especiall=
y since `auto foo(int x) -&gt; decltype(x)` is one of the main advertised u=
ses of late return types, which this is inconsistent with.</div><br><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr">On Thu, Dec 15, 2016 at 6:13 PM D. B. =
&lt;<a href=3D"mailto:db0451@gmail.com">db0451@gmail.com</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr" class=3D"gmail_msg">P=
erhaps it could even be classed as a defect.<br class=3D"gmail_msg"></div>

<p class=3D"gmail_msg"></p>

-- <br class=3D"gmail_msg">
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br class=3D"gmail_msg=
">
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" class=3D"gm=
ail_msg" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br cla=
ss=3D"gmail_msg">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"gmail_msg" target=3D"_blank">std-proposals@isocpp.org</a>.<b=
r class=3D"gmail_msg">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908=
fKbkC%3DhKriPMCcUeqw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Df=
ooter" class=3D"gmail_msg" target=3D"_blank">https://groups.google.com/a/is=
ocpp.org/d/msgid/std-proposals/CACGiwhF2vnKUcVg9Uu%3Dy%2BWvPsNLVG908fKbkC%3=
DhKriPMCcUeqw%40mail.gmail.com</a>.<br class=3D"gmail_msg">
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAPCFJdTqQupm%2BuzmO7dz_EihEDEuV6yaWb=
WHT%3D7b70dtKyHnQg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdTqQupm=
%2BuzmO7dz_EihEDEuV6yaWbWHT%3D7b70dtKyHnQg%40mail.gmail.com</a>.<br />

--001a113cf89af185e90543b5ac36--

.


Author: "D. B." <db0451@gmail.com>
Date: Thu, 15 Dec 2016 17:32:17 +0000
Raw View
--001a11442612bd4a610543b5d573
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 15, 2016 at 5:20 PM, Micha=C5=82 Dominiak <griwes@griwes.info> =
wrote:

> I agree that it could be classified as a defect, especially since `auto
> foo(int x) -> decltype(x)` is one of the main advertised uses of late
> return types, which this is inconsistent with.
>

To be fair, that's not inconsistent per se, because one is a capture and
one is an argument.

However, it's inconsistent in the sense that, unlike arguments, in the case
of captures, something that is declared - horizontally and logically -
before the trailing return type is nonetheless not available for use by it.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CACGiwhESOaDixUXBXesoWUV84gf9ESoHEU%2B%2BK_rve69=
q2cHDBQ%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Dec 15, 2016 at 5:20 PM, Micha=C5=82 Dominiak <span dir=3D"ltr">&lt;<a =
href=3D"mailto:griwes@griwes.info" target=3D"_blank">griwes@griwes.info</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di=
v dir=3D"ltr">I agree that it could be classified as a defect, especially s=
ince `auto foo(int x) -&gt; decltype(x)` is one of the main advertised uses=
 of late return types, which this is inconsistent with.</div></blockquote><=
div><br></div><div>To be fair, that&#39;s not inconsistent per se, because =
one is a capture and one is an argument.<br><br></div><div>However, it&#39;=
s inconsistent in the sense that, unlike arguments, in the case of captures=
, something that is declared - horizontally and logically - before the trai=
ling return type is nonetheless not available for use by it.<br></div><br><=
/div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhESOaDixUXBXesoWUV84gf9ESoHEU%2=
B%2BK_rve69q2cHDBQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhESOaDi=
xUXBXesoWUV84gf9ESoHEU%2B%2BK_rve69q2cHDBQ%40mail.gmail.com</a>.<br />

--001a11442612bd4a610543b5d573--

.


Author: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Date: Thu, 15 Dec 2016 14:33:13 -0800 (PST)
Raw View
------=_Part_328_324748185.1481841193748
Content-Type: multipart/alternative;
 boundary="----=_Part_329_723080626.1481841193749"

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

I wrote a primitive draft of the proposal/defect report.=20
http://vittorioromeo.info/Misc/lambda_issue_draft.html

I still have to add a small section on the fact that the proposed wording=
=20
is a breaking change and an acknowledgments section.

Some questions:

   - Is it more appropriate to submit a finished version of this document=
=20
   as a proposal or as a defect report?
   - Should my standard citations/links be directed to the latest draft?
   - What is the correct notation to cite a paragraph from the standard? I=
=20
   used '$x.y.z.w' as a placeholder, couldn't find an "official way".
   - My proposed wording changes a small part of the paragraph. What's the=
=20
   official notation to say "unchanged after this [...]"?
   - My current changes propose that the init-captures should have "two=20
   declarative regions". Is that acceptable, or should I change the wording=
 to=20
   say something like "the declarative region should be the union of A and =
B"?



On Thursday, 15 December 2016 13:27:06 UTC, Vittorio Romeo wrote:
>
> int main(){
>     auto l =3D [x =3D 10]() -> decltype(x) {};}
>
>
>
>
>    -=20
>   =20
>    *clang++ 4.0* rejects this code=20
>    <http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe> with the=20
>    following error:
>    -=20
>   =20
>    error: use of undeclared identifier 'x'
>            auto l =3D [x =3D 10]() -> decltype(x) {};
>                                            ^
>   =20
>    -=20
>   =20
>    *g++ 7* rejects this code=20
>    <http://melpon.org/wandbox/permlink/LXamt4MieU6n77Xs> with the=20
>    following error:
>   =20
>    In function 'int main()':
>    error: 'x' was not declared in this scope
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>    error: 'x' was not declared in this scopeIn lambda function:
>    warning: no return statement in function returning non-void [-Wreturn-=
type]
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>   =20
>   =20
>   =20
> I posted this today on StackOverflow thinking it was a compiler bug:
> http://stackoverflow.com/questions/41162200/
>
> But it's not - the standard says that the scope of `x` is limited to the=
=20
> body of the lambda. This answer has the details:=20
> http://stackoverflow.com/a/41162972/598696
> (quoted below)
>
> ---
>
> *TL;DR*: Compilers behave as expected.
>
> The standard defines lambda semantics as follows [expr.prim.lambda,=20
> section 1]:
>
> lambda-expression:
>
>    lambda-introducer lambda-declarator_opt compound-statement
>
> Here *compound-statement* is just the body of lambda between {}, because=
=20
> everything else is included in *lambda-declarator*:
>
> lambda-declarator:
>
>    ( parameter-declaration-clause ) decl-specifier-seq_opt
>        exception-specification_opt attribute-specifier-seq_opt trailing-r=
eturn-type_opt
>
> Also, in section 12 of the same chapter, it's said that
>
> An init-capture behaves as if it declares and explicitly captures a=20
> variable of the form =E2=80=9Cauto init-capture ;=E2=80=9D whose declarat=
ive region is the=20
> lambda-expression=E2=80=99s compound-statement, except that:
>
> (12.1) =E2=80=94 if the capture is by copy (see below), the non-static da=
ta member=20
> declared for the capture and the variable are treated as two different wa=
ys=20
> of referring to the same object, which has the lifetime of the non-static=
=20
> data member, and no additional copy and destruction is performed, and
>
> (12.2) =E2=80=94 if the capture is by reference, the variable=E2=80=99s l=
ifetime ends when=20
> the closure object=E2=80=99s lifetime ends.
>
> So, in your first example, variable x scope is the lambda body only, not=
=20
> including the decltypeexpression. In the second example, obviously, x sco=
pe=20
> is the function main.
>
> ---
>
> Do you think that writing a proposal to relax these rules and to=20
> explicitly allow generalized captures to be used inside the trailing retu=
rn=20
> type would be worthwhile?
>
> One possible use case is when the generalized captures are initialized=20
> with complex expressions. I encountered this while experimenting today (
> http://melpon.org/wandbox/permlink/aVasfHaK6boC6NZt).
> In general, it would be beneficial to have this feature whenever the=20
> generalized capture is used as part of the return expression in the lambd=
a=20
> body.
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/a0ffbb00-88dc-4d6d-ad07-00ccaaf3627d%40isocpp.or=
g.

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

<div dir=3D"ltr">I wrote a primitive draft of the proposal/defect report.=
=C2=A0<br><a href=3D"http://vittorioromeo.info/Misc/lambda_issue_draft.html=
">http://vittorioromeo.info/Misc/lambda_issue_draft.html</a><br><br>I still=
 have to add a small section on the fact that the proposed wording is a bre=
aking change and an acknowledgments section.<br><div><br></div><div>Some qu=
estions:<br><ul><li>Is it more appropriate to submit a finished version of =
this document as a proposal or as a defect report?<br></li><li>Should my st=
andard citations/links be directed to the latest draft?</li><li>What is the=
 correct notation to cite a paragraph from the standard? I used &#39;$x.y.z=
..w&#39; as a placeholder, couldn&#39;t find an &quot;official way&quot;.</l=
i><li>My proposed wording changes a small part of the paragraph. What&#39;s=
 the official notation to say &quot;unchanged after this [...]&quot;?</li><=
li>My current changes propose that the init-captures should have &quot;two =
declarative regions&quot;. Is that acceptable, or should I change the wordi=
ng to say something like &quot;the declarative region should be the union o=
f A and B&quot;?</li></ul><br><br>On Thursday, 15 December 2016 13:27:06 UT=
C, Vittorio Romeo  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"><pre class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex"><code style=3D"font-=
family:Consolas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mo=
no&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,=
&quot;Courier New&quot;,monospace,sans-serif;white-space:inherit"><span sty=
le=3D"color:rgb(43,145,175)">int</span><span style=3D"color:rgb(48,51,54)">=
 main</span><span style=3D"color:rgb(48,51,54)">()</span><span style=3D"col=
or:rgb(48,51,54)">
</span><span style=3D"color:rgb(48,51,54)">{</span><span style=3D"color:rgb=
(48,51,54)">
    </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"c=
olor:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span=
><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51=
,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"c=
olor:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><=
span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51=
,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"=
color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </spa=
n><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:=
rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </=
span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb=
(48,51,54)">
</span><span style=3D"color:rgb(48,51,54)">}
</span></code></pre><br><br><ul style=3D"margin:0px 0px 1em 30px;padding:0p=
x;border:0px;font-size:15px;font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;color:rgb(36,39,41)"><li style=3D"margin:0px 0px 0.5em;p=
adding:0px;border:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=
=3D"http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe" rel=3D"nofollow" s=
tyle=3D"color:rgb(0,89,153);font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;font-size:15px" target=3D"_blank" onmousedown=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%=
2Fpermlink%2FzsFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWA=
WY4JcXh_a1opBWZW0-WwRMw&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2Fz=
sFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWAWY4JcXh_a1opBW=
ZW0-WwRMw&#39;;return true;"><strong style=3D"color:rgb(0,89,153);font-fami=
ly:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15px">cl=
ang++ 4.0</strong><font color=3D"#005999" style=3D"color:rgb(0,89,153);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15p=
x"><span>=C2=A0rejects this code</span></font></a><font color=3D"#242729" f=
ace=3D"Arial, Helvetica Neue, Helvetica, sans-serif"><span style=3D"font-si=
ze:15px">=C2=A0with the following error:</span></font><br></p></li><li styl=
e=3D"margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word"><pre=
 style=3D"margin-top:0.5em;margin-bottom:1em;padding:5px;font-size:13px;wid=
th:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,&q=
uot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono=
&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospa=
ce,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wr=
ap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot;Lucida Co=
nsole&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;=
Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif=
;white-space:inherit"><span style=3D"color:rgb(48,51,54)">error</span><span=
 style=3D"color:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">=
 use of undeclared identifier </span><span style=3D"color:rgb(125,39,39)">&=
#39;x&#39;</span><span style=3D"color:rgb(48,51,54)">
        </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=
=3D"color:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D<=
/span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(=
48,51,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=
=3D"color:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </s=
pan><span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(=
48,51,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span styl=
e=3D"color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> =
</span><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"c=
olor:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><sp=
an style=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)=
"> </span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"colo=
r:rgb(48,51,54)">
                                        </span><span style=3D"color:rgb(48,=
51,54)">^</span></code></pre></li><li style=3D"margin:0px;padding:0px;borde=
r:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=3D"http://melpo=
n.org/wandbox/permlink/LXamt4MieU6n77Xs" rel=3D"nofollow" style=3D"color:rg=
b(0,89,153)" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.g=
oogle.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4Mie=
U6n77Xs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFB=
w&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?=
q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4MieU6n77Xs\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFBw&#39;;return =
true;"><strong>g++ 7</strong>=C2=A0rejects this code</a>=C2=A0with the foll=
owing error:</p><pre style=3D"margin-top:0.5em;margin-bottom:1em;padding:5p=
x;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Cons=
olas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&q=
uot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Couri=
er New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:r=
gb(57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Mo=
naco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sa=
ns Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,=
monospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(43,145,1=
75)">In</span><span style=3D"color:rgb(48,51,54)"> function </span><span st=
yle=3D"color:rgb(125,39,39)">&#39;int main()&#39;</span><span style=3D"colo=
r:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
</span><span style=3D"color:rgb(43,145,175)">In</span><span style=3D"color:=
rgb(48,51,54)"> lambda function</span><span style=3D"color:rgb(48,51,54)">:=
</span><span style=3D"color:rgb(48,51,54)">
warning</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"co=
lor:rgb(48,51,54)"> no </span><span style=3D"color:rgb(16,16,148)">return</=
span><span style=3D"color:rgb(48,51,54)"> statement in function returning n=
on</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(16,16,148)">void</span><span style=3D"color:rgb(48,51,54)"> </span><span=
 style=3D"color:rgb(48,51,54)">[-</span><span style=3D"color:rgb(43,145,175=
)">Wreturn</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D=
"color:rgb(48,51,54)">type</span><span style=3D"color:rgb(48,51,54)">]</spa=
n><span style=3D"color:rgb(48,51,54)">
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span></code></pre><br></li></ul><font color=3D"#303336" face=3D"Consol=
as, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitst=
ream Vera Sans Mono, Courier New, monospace, sans-serif"><span style=3D"whi=
te-space:pre">I posted this today on StackOverflow thinking it was a compil=
er bug:</span></font><div><font color=3D"#303336" face=3D"Consolas, Menlo, =
Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera S=
ans Mono, Courier New, monospace, sans-serif"><span style=3D"white-space:pr=
e"><a href=3D"http://stackoverflow.com/questions/41162200/" target=3D"_blan=
k" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/u=
rl?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true=
;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F=
stackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true;">http://stackoverfl=
ow.com/<wbr>questions/41162200/</a></span><br></font></div><div><font color=
=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mo=
no, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, san=
s-serif"><span style=3D"white-space:pre"><br></span></font></div><div><font=
 color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberat=
ion Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospac=
e, sans-serif"><span style=3D"white-space:pre">But it&#39;s not - the stand=
ard says that the scope of `x` is limited to the body of the lambda. This a=
nswer has the details:</span>
</font></div><div><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, =
Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono=
, Courier New, monospace, sans-serif"><span style=3D"white-space:pre"><a hr=
ef=3D"http://stackoverflow.com/a/41162972/598696" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fstackoverflow.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d=
1\x26usg\x3dAFQjCNEkofXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverf=
low.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEko=
fXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;">http://stackoverflow.com/a/<wb=
r>41162972/598696</a></span><br></font></div><div><font color=3D"#303336" f=
ace=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu San=
s Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif"><span=
 style=3D"white-space:pre">(quoted below)</span></font></div><div><font col=
or=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation =
Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, s=
ans-serif"><span style=3D"white-space:pre"><br></span></font></div><div><fo=
nt color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liber=
ation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monosp=
ace, sans-serif"><span style=3D"white-space:pre">---</span></font></div><di=
v><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, =
Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, m=
onospace, sans-serif"><span style=3D"white-space:pre"><br></span></font></d=
iv><div><p style=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(3=
6,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"=
><strong>TL;DR</strong>: Compilers behave as expected.</p><p style=3D"margi=
n-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Aria=
l,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">The standard defines lam=
bda semantics as follows [expr.prim.lambda, section 1]:</p><blockquote styl=
e=3D"margin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-t=
op-style:initial;border-right-style:initial;border-bottom-style:initial;bor=
der-left-style:solid;border-top-color:initial;border-right-color:initial;bo=
rder-bottom-color:initial;border-left-color:rgb(255,235,142);font-size:15px=
;quotes:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-fam=
ily:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"marg=
in-bottom:1em;clear:both">lambda-expression:</p><pre style=3D"padding:5px;f=
ont-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consola=
s,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot=
;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier =
New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(=
57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monac=
o,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans =
Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mon=
ospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">=
   lambda</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"=
color:rgb(48,51,54)">introducer lambda</span><span style=3D"color:rgb(48,51=
,54)">-</span><span style=3D"color:rgb(48,51,54)">declarator_opt compound</=
span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(4=
8,51,54)">statement</span></code></pre></blockquote><p style=3D"margin-bott=
om:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quo=
t;Helvetica Neue&quot;,Helvetica,sans-serif">Here=C2=A0<em>compound-stateme=
nt</em>=C2=A0is just the body of lambda between {}, because everything else=
 is included in=C2=A0<em>lambda-declarator</em>:</p><blockquote style=3D"ma=
rgin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-top-styl=
e:initial;border-right-style:initial;border-bottom-style:initial;border-lef=
t-style:solid;border-top-color:initial;border-right-color:initial;border-bo=
ttom-color:initial;border-left-color:rgb(255,235,142);font-size:15px;quotes=
:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-family:Ari=
al,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"margin-bott=
om:1em;clear:both">lambda-declarator:</p><pre style=3D"padding:5px;font-siz=
e:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,2=
4);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot=
;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&qu=
ot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,=
sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">   </sp=
an><span style=3D"color:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,=
51,54)"> parameter</span><span style=3D"color:rgb(48,51,54)">-</span><span =
style=3D"color:rgb(48,51,54)">declaration</span><span style=3D"color:rgb(48=
,51,54)">-</span><span style=3D"color:rgb(48,51,54)">clause </span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> de=
cl</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(48,51,54)">specifier</span><span style=3D"color:rgb(48,51,54)">-</span><=
span style=3D"color:rgb(48,51,54)">seq_opt
       exception</span><span style=3D"color:rgb(48,51,54)">-</span><span st=
yle=3D"color:rgb(48,51,54)">specification_opt attribute</span><span style=
=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">specif=
ier</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:=
rgb(48,51,54)">seq_opt trailing</span><span style=3D"color:rgb(48,51,54)">-=
</span><span style=3D"color:rgb(16,16,148)">return</span><span style=3D"col=
or:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">type_opt</spa=
n></code></pre></blockquote><p style=3D"margin-bottom:1em;font-size:15px;cl=
ear:both;color:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,H=
elvetica,sans-serif">Also, in section 12 of the same chapter, it&#39;s said=
 that</p><blockquote style=3D"margin:0px 0px 10px;padding:10px;border-width=
:0px 0px 0px 2px;border-top-style:initial;border-right-style:initial;border=
-bottom-style:initial;border-left-style:solid;border-top-color:initial;bord=
er-right-color:initial;border-bottom-color:initial;border-left-color:rgb(25=
5,235,142);font-size:15px;quotes:none;background-color:rgb(255,248,220);col=
or:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,san=
s-serif"><p style=3D"margin-bottom:1em;clear:both">An init-capture behaves =
as if it declares and explicitly captures a variable of the form =E2=80=9Ca=
uto init-capture ;=E2=80=9D whose declarative region is the lambda-expressi=
on=E2=80=99s compound-statement, except that:</p><p style=3D"margin-bottom:=
1em;clear:both">(12.1) =E2=80=94 if the capture is by copy (see below), the=
 non-static data member declared for the capture and the variable are treat=
ed as two different ways of referring to the same object, which has the lif=
etime of the non-static data member, and no additional copy and destruction=
 is performed, and</p><p style=3D"clear:both">(12.2) =E2=80=94 if the captu=
re is by reference, the variable=E2=80=99s lifetime ends when the closure o=
bject=E2=80=99s lifetime ends.</p></blockquote><p style=3D"margin-bottom:1e=
m;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quot;Hel=
vetica Neue&quot;,Helvetica,sans-serif">So, in your first example, variable=
=C2=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Me=
nlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;Dej=
aVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&=
quot;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pr=
e-wrap">x</code>=C2=A0scope is the lambda body only, not including the=C2=
=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-w=
rap">decltype</code>expression. In the second example, obviously,=C2=A0<cod=
e style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo,Monaco=
,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans M=
ono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mono=
space,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">x<=
/code>=C2=A0scope is the function=C2=A0<code style=3D"padding:1px 5px;font-=
size:13px;font-family:Consolas,Menlo,Monaco,&quot;Lucida Console&quot;,&quo=
t;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera S=
ans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif;background-colo=
r:rgb(239,240,241);white-space:pre-wrap">main</code>.</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">---</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">Do you think that writing=
 a proposal to relax these rules and to explicitly allow generalized captur=
es to be used inside the trailing return type would be worthwhile?</p><p st=
yle=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">One possible=
 use case is when the generalized captures are initialized with complex exp=
ressions. I encountered this while experimenting today (<a href=3D"http://m=
elpon.org/wandbox/permlink/aVasfHaK6boC6NZt" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A=
%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz=
\x3d1\x26usg\x3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.o=
rg%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;">http://melpon.org/w=
andbox/<wbr>permlink/aVasfHaK6boC6NZt</a>).<br>In general, it would be bene=
ficial to have this feature whenever the generalized capture is used as par=
t of the return expression in the lambda body.</p></div></div></blockquote>=
</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a0ffbb00-88dc-4d6d-ad07-00ccaaf3627d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a0ffbb00-88dc-4d6d-ad07-00ccaaf3627d=
%40isocpp.org</a>.<br />

------=_Part_329_723080626.1481841193749--

------=_Part_328_324748185.1481841193748--

.


Author: "T. C." <rs2740@gmail.com>
Date: Thu, 15 Dec 2016 15:05:02 -0800 (PST)
Raw View
------=_Part_370_1929266798.1481843102472
Content-Type: multipart/alternative;
 boundary="----=_Part_371_1102299708.1481843102473"

------=_Part_371_1102299708.1481843102473
Content-Type: text/plain; charset=UTF-8



On Thursday, December 15, 2016 at 5:33:13 PM UTC-5, Vittorio Romeo wrote:
>
> I wrote a primitive draft of the proposal/defect report.
> http://vittorioromeo.info/Misc/lambda_issue_draft.html
>
> I still have to add a small section on the fact that the proposed wording
> is a breaking change and an acknowledgments section.
>
> Some questions:
>

>    - Is it more appropriate to submit a finished version of this document
>    as a proposal or as a defect report?
>
>  I think there are design issues here (see below) which would indicate a
paper.

>
>    - Should my standard citations/links be directed to the latest draft?
>
> I think it should be the version in the most recent mailing (which means
not my version generated from tip of trunk - thanks for the link though
:P). I may set up something for that though - just like N3337/N4140.

>
>    - What is the correct notation to cite a paragraph from the standard?
>    I used '$x.y.z.w' as a placeholder, couldn't find an "official way".
>    - My proposed wording changes a small part of the paragraph. What's
>    the official notation to say "unchanged after this [...]"?
>
> Just grab an existing paper by an established author (e.g., P013{5,6,7}R1,
all pure-wording papers by the project editor). There's no consistent
style. For paragraph references, it's a good idea to include the section
number and the stable name, and put the paragraph number separately

>
>    - My current changes propose that the init-captures should have "two
>    declarative regions". Is that acceptable, or should I change the wording to
>    say something like "the declarative region should be the union of A and B"?
>
> "two declarative regions" is definitely not good, but "declarative region"
in general is a mess and not used particularly consistently (search the
core issue list). I'd just let CWG handle it when/if it gets that far.

A couple points that I think the paper should address:

1. What is decltype((x)) in the lambda-declarator
- before the decl-specifier-seq?
- after the decl-specifier-seq?

2. What about consistency with simple captures and with ordinary classes?

void f() {
    int i;

    // for comparison:
    struct lambda {
        int i;
        auto operator()(decltype((i))) const {} // This is (int&)
        auto operator()() const -> decltype((i)) {} // This returns const
int&
    };

    [i](decltype((i))){ }; // this is [i](int&){} currently
    [i]() -> decltype((i)) { return /* ... */ }; // this is [i]() -> int& {
.... } currently

    [j = i](decltype((j))){ }; // this is [j = i](???){}?
    [j = i]() -> decltype((j)) { return /* ... */; }; // this is [j = i]()
-> ??? { ... }?
}


--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e683e594-bfd2-45f5-9a67-4b16bc5ec576%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Thursday, December 15, 2016 at 5:33:13 PM UTC-5=
, Vittorio Romeo wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">I wrote a primitive draft of the proposal/defect report.=C2=A0<br=
><a href=3D"http://vittorioromeo.info/Misc/lambda_issue_draft.html" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fvittorioromeo.info%2FMisc%2Flambda_issue_draf=
t.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFpniO-MxF01fSQOsIgvIMuGcx1OQ=
&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fvittorioromeo.info%2FMisc%2Flambda_issue_draft.html\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFpniO-MxF01fSQOsIgvIMuGcx1OQ&#39;;return =
true;">http://vittorioromeo.info/<wbr>Misc/lambda_issue_draft.html</a><br><=
br>I still have to add a small section on the fact that the proposed wordin=
g is a breaking change and an acknowledgments section.<br><div><br></div></=
div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div>Some questions:<br></div></div></blockquote><blockquote class=3D"g=
mail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(=
204, 204, 204); padding-left: 1ex;"><ul><li>Is it more appropriate to submi=
t a finished version of this document as a proposal or as a defect report?<=
br></li></ul></blockquote><div>=C2=A0I think there are design issues here (=
see below) which would indicate a paper.</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;"><ul><li>Should my standard citations/links be =
directed to the latest draft?<br></li></ul></blockquote><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid=
 rgb(204, 204, 204); padding-left: 1ex;"><div dir=3D"ltr"></div></blockquot=
e><div>I think it should be the version in the most recent mailing (which m=
eans not my version generated from tip of trunk=C2=A0- thanks for the link =
though :P). I may set up something for that though - just like N3337/N4140.=
</div><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: =
1ex;"><ul><li>What is the correct notation to cite a paragraph from the sta=
ndard? I used &#39;$x.y.z.w&#39; as a placeholder, couldn&#39;t find an &qu=
ot;official way&quot;.</li><li>My proposed wording changes a small part of =
the paragraph. What&#39;s the official notation to say &quot;unchanged afte=
r this [...]&quot;?</li></ul></blockquote><div>Just grab an existing paper =
by an established author (e.g., P013{5,6,7}R1, all pure-wording papers by t=
he project editor). There&#39;s no consistent style. For paragraph referenc=
es, it&#39;s a good idea to include the section number and the stable=C2=A0=
name,=C2=A0and put the paragraph number separately</div></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><ul><li>My current changes=
 propose that the init-captures should have &quot;two declarative regions&q=
uot;. Is that acceptable, or should I change the wording to say something l=
ike &quot;the declarative region should be the union of A and B&quot;?</li>=
</ul></div></blockquote><div>&quot;two declarative regions&quot; is definit=
ely not good, but &quot;declarative region&quot; in general is a mess and n=
ot used particularly consistently (search=C2=A0the core issue list). I&#39;=
d just let CWG handle it when/if it gets that far.</div><div><br></div>A co=
uple points that I think the paper should address:<br><br>1. What is declty=
pe((x)) in the lambda-declarator<br>- before the decl-specifier-seq?<br>- a=
fter the decl-specifier-seq?<div><br>2. What about consistency with simple =
captures and with ordinary classes?</div><br><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"s=
tyled-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"> <br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> <br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// for=
 comparison:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">lam=
bda</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"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">()(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=3D"colo=
r: #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: #008;" class=3D"style=
d-by-prettify">const</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: #800;" class=3D"styled-by-prettify">// This is (int&=
amp;)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>()()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">decltype</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"style=
d-by-prettify">))</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </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: #800;" class=3D"styled-by-prettify">// This returns con=
st int&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>=C2=A0 =C2=A0 </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>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">](</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">decltype</spa=
n><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;" c=
lass=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">// this is [i](int&amp;){} currently</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </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"style=
d-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>decltype</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 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"> </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: #800;" 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 style=3D"color: #800;" class=3D"styled-by-prettify">// this is [i]()=
 -&gt; int&amp; { ... } currently</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">j </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> i</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">](</span><span style=3D"color: #008;" class=3D"styled-by-prettify">decl=
type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">((</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">j</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 style=3D"color: #800;" class=3D=
"styled-by-prettify">// this is [j =3D i](???){}?</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">j </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=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-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">decltype</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">j</span><span style=3D"c=
olor: #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"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" 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: #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">// this is [j =3D i]() -&gt; ??? { ... }?<=
/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 sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div></cod=
e></div><br> </div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e683e594-bfd2-45f5-9a67-4b16bc5ec576%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e683e594-bfd2-45f5-9a67-4b16bc5ec576=
%40isocpp.org</a>.<br />

------=_Part_371_1102299708.1481843102473--

------=_Part_370_1929266798.1481843102472--

.


Author: "T. C." <rs2740@gmail.com>
Date: Thu, 15 Dec 2016 15:05:57 -0800 (PST)
Raw View
------=_Part_339_915653161.1481843157486
Content-Type: multipart/alternative;
 boundary="----=_Part_340_1127047889.1481843157487"

------=_Part_340_1127047889.1481843157487
Content-Type: text/plain; charset=UTF-8



On Thursday, December 15, 2016 at 12:10:56 PM UTC-5, Nicol Bolas wrote:
>
>
>
> On Thursday, December 15, 2016 at 12:00:35 PM UTC-5, Vittorio Romeo wrote:
>>
>> I would like to write a proposal, but I just realized that it would be a
>> breaking change:
>> http://melpon.org/wandbox/permlink/g9eAszk1SoGPA1Lf
>>
>>
>> struct Foo { };
>>
>> int main()
>> {
>>     Foo x;
>>     auto l = [x = 10]() -> decltype(x) { return 10; };
>> }
>>
>> If  the proposal is accepted, this code will behave differently!
>> This still feels very counter-intuitive though... I'm inclined to think
>> it's worth bringing this to the attention of the committee anyway.
>>
>>
> Wait a minute. This *wouldn't* have been a breaking change until C++14.
> Back then, if you declared a capture, then there *must* have been a
> variable outside the lambda with that exact name and type. So in that case,
> `[x]() -> decltype(x) {...}` would be fine, since `lambda::x` and `x` have
> the same type.
>
> It was C++14's generalized lambda capture that made it *possible* for
> `lambda::x` and `x` to have different types. So the fact that it represents
> a breaking change may not be that important.
>
> I agree that you should try to move forward on it. If the committee wants
> to reject it due to being a breaking change, so be it. But you should note
> that it is only breaking when using generalized capture.
>

There can be a type mismatch even in C++11. For example, a reference
captured by copy.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8dd57cbd-5dc0-4d16-8532-d3c72aecead5%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Thursday, December 15, 2016 at 12:10:56 PM UTC-=
5, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><br><br>On Thursday, December 15, 2016 at 12:00:35 PM UTC-5, Vitto=
rio Romeo 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"><p=
 style=3D"color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif,&=
quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&quo=
t;Segoe UI Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols;font-size:16=
px">I would like to write a proposal, but I just realized that it would be =
a breaking change:<br><a href=3D"http://melpon.org/wandbox/permlink/g9eAszk=
1SoGPA1Lf" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#=
39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fperml=
ink%2Fg9eAszk1SoGPA1Lf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEXRbzdXhldon=
pALH6E9xwzcko6ig&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.=
google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2Fg9eAszk1=
SoGPA1Lf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEXRbzdXhldonpALH6E9xwzcko6=
ig&#39;;return true;">http://melpon.org/wandbox/<wbr>permlink/g9eAszk1SoGPA=
1Lf</a></p><p style=3D"color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica=
,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoCo=
lorEmoji,&quot;Segoe UI Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols=
;font-size:16px"><br></p><p style=3D"color:rgb(0,0,0);font-family:Calibri,A=
rial,Helvetica,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoj=
i&quot;,NotoColorEmoji,&quot;Segoe UI Symbol&quot;,&quot;Android Emoji&quot=
;,EmojiSymbols;font-size:16px"></p><div><span style=3D"font-family:Consolas=
,monospace">struct Foo { };</span></div><div><br></div><div><span style=3D"=
font-family:Consolas,monospace">int main()</span></div><div><span style=3D"=
font-family:Consolas,monospace">{</span></div><div><span style=3D"font-fami=
ly:Consolas,monospace">=C2=A0 =C2=A0 Foo x;</span></div><div><span style=3D=
"font-family:Consolas,monospace">=C2=A0 =C2=A0 auto l =3D [x =3D 10]() -&gt=
; decltype(x) { return 10; };</span></div><div><span style=3D"font-family:C=
onsolas,monospace">} =C2=A0</span></div><div></div><br><p></p><p style=3D"c=
olor:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif,&quot;Apple =
Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&quot;Segoe UI =
Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols;font-size:16px">If =C2=
=A0the proposal is accepted, this code will behave differently!<br>This sti=
ll feels very counter-intuitive though...=C2=A0I&#39;m inclined to think it=
&#39;s worth=C2=A0bringing this to the attention of the committee anyway.</=
p><br></div></blockquote><div><br>Wait a minute. This <i>wouldn&#39;t</i> h=
ave been a breaking change until C++14. Back then, if you declared a captur=
e, then there <i>must</i> have been a variable outside the lambda with that=
 exact name and type. So in that case, `[x]() -&gt; decltype(x) {...}` woul=
d be fine, since `lambda::x` and `x` have the same type.<br><br>It was C++1=
4&#39;s generalized lambda capture that made it <i>possible</i> for `lambda=
::x` and `x` to have different types. So the fact that it represents a brea=
king change may not be that important.<br><br>I agree that you should try t=
o move forward on it. If the committee wants to reject it due to being a br=
eaking change, so be it. But you should note that it is only breaking when =
using generalized capture.<br></div></div></blockquote><div><br></div><div>=
There can be a type mismatch even in C++11. For example, a reference captur=
ed by copy.=C2=A0</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8dd57cbd-5dc0-4d16-8532-d3c72aecead5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8dd57cbd-5dc0-4d16-8532-d3c72aecead5=
%40isocpp.org</a>.<br />

------=_Part_340_1127047889.1481843157487--

------=_Part_339_915653161.1481843157486--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Thu, 15 Dec 2016 17:22:39 -0800 (PST)
Raw View
------=_Part_2_29372470.1481851359615
Content-Type: multipart/alternative;
 boundary="----=_Part_3_1686758882.1481851359617"

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

On Thursday, December 15, 2016 at 3:05:02 PM UTC-8, T. C. wrote:
>
> On Thursday, December 15, 2016 at 5:33:13 PM UTC-5, Vittorio Romeo wrote:
>>
>> I wrote a primitive draft of the proposal/defect report.=20
>> http://vittorioromeo.info/Misc/lambda_issue_draft.html
>>
>
>>    - What is the correct notation to cite a paragraph from the standard?=
=20
>>    I used '$x.y.z.w' as a placeholder, couldn't find an "official way".
>>
>> FWIW, I have always used =C2=A7x.y.z [stable.name] /w to indicate clause=
 w of=20
section x.y.z with the given stable name. I'm sure it doesn't matter much=
=20
as long as it's clear to the intended audience.


A couple points that I think the paper should address:
>
> 2. What about consistency with simple captures and with ordinary classes?
>
> void f() {=20
>     int i;=20
>
>     // for comparison:
>     struct lambda {
>         int i;
>         auto operator()(decltype((i))) const {} // This is (int&)
>         auto operator()() const -> decltype((i)) {} // This returns const=
=20
> int&
>     };
>
>     [i](decltype((i))){ }; // this is [i](int&){} currently
>     [i]() -> decltype((i)) { return /* ... */ }; // this is [i]() -> int&=
=20
> { ... } currently
>

This is a VERY good point!  I think that the solution is simple but=20
unfortunate, and it all stems from the simple but unfortunate decision in=
=20
C++11 to make lambdas' operator() methods "one level more const" than the=
=20
syntax implies.

    int i;
    auto cf =3D [i]() { return &i; };  // the return type here is (const in=
t=20
*), not (int *)
    auto mf =3D [i]() mutable { return &i; };  // the return type here is=
=20
(int *)

IMHO decltype-of-the-returned-expression should Just Work, which means you=
=20
MUST break C++11 compatibility if you want this feature:

    int i;
    auto cf =3D [i]() -> decltype(&i) { return &i; };  // the return type=
=20
here is (int *) in C++11, but IMHO it should be (const int *) after this=20
patch
    auto mf =3D [i]() mutable -> decltype(&i) { return &i; };  // the retur=
n=20
type here is (int *)

This will make it align nicely with the struct-and-member-function version:

struct S {
    int i;
    auto cf() const -> decltype(&i) { return &i; };  // the return type=20
here is (const int *)
    auto mf() -> decltype(&i) { return &i; };  // the return type here is=
=20
(int *)
};

I would also want the paper to specifically confront the issue of

    int i;
    auto f =3D [i=3D0L](char i) -> decltype(i) { return 0; }
    // decltype(f(0)) =3D=3D ???

Right now, GCC and Clang disagree on the meaning=20
<http://melpon.org/wandbox/permlink/Euvw0dWDVX9HyIEG> of [i](int i) {=20
return i; } =E2=80=94 GCC makes the member variable silently shadow the par=
ameter,=20
while Clang makes the parameter silently shadow the member variable.=20
Neither one is friendly behavior, and I believe GCC's behavior is just flat=
=20
wrong, but I have not checked the Standard.  I have confirmed that in a=20
normal member function, for the purposes of trailing decltypes, parameters=
=20
do shadow member variables=20
<http://melpon.org/wandbox/permlink/WQjQ7Sh2sLtkDTsw>.

Finally, as another corner case separate from T.C.'s cases, I would like to=
=20
see explicit discussion of whether a trailing decltype(i) can be affected=
=20
by a default capture e.g. [=3D] or [&]. Are the names of the default-captur=
ed=20
variables in scope during the parsing of the trailing return type?  I=20
suspect there's an easy and unsurprising answer, I just haven't thought=20
much about it and I think someone should.

HTH,
=E2=80=93Arthur

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/6a156e3d-77c5-4b98-aa9d-529eb7621e2b%40isocpp.or=
g.

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

<div dir=3D"ltr">On Thursday, December 15, 2016 at 3:05:02 PM UTC-8, T. C. =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thur=
sday, December 15, 2016 at 5:33:13 PM UTC-5, Vittorio Romeo wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">I wrote a primitive draft o=
f the proposal/defect report.=C2=A0<br><a href=3D"http://vittorioromeo.info=
/Misc/lambda_issue_draft.html" rel=3D"nofollow" target=3D"_blank" onmousedo=
wn=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fvittorio=
romeo.info%2FMisc%2Flambda_issue_draft.html\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNFpniO-MxF01fSQOsIgvIMuGcx1OQ&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fvittorioromeo.info%2F=
Misc%2Flambda_issue_draft.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFpni=
O-MxF01fSQOsIgvIMuGcx1OQ&#39;;return true;">http://vittorioromeo.info/<wbr>=
Misc/lambda_issue_draft.html</a></div></blockquote><div dir=3D"ltr"><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex"><ul><li>What is the correct nota=
tion to cite a paragraph from the standard? I used &#39;$x.y.z.w&#39; as a =
placeholder, couldn&#39;t find an &quot;official way&quot;.</li></ul></bloc=
kquote></div></div></blockquote><div>FWIW, I have always used=C2=A0<font fa=
ce=3D"courier new, monospace">=C2=A7x.y.z [stable.name] /w</font> to indica=
te clause w of section x.y.z with the given stable name. I&#39;m sure it do=
esn&#39;t matter much as long as it&#39;s clear to the intended audience.</=
div><div><br></div><div><br></div><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"><div>A couple points that I think the paper should a=
ddress:<br></div><br><div>2. What about consistency with simple captures an=
d with ordinary classes?</div><br><div style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wo=
rd-wrap:break-word"><code><div><span style=3D"color:#008">void</span><span =
style=3D"color:#000"> f</span><span style=3D"color:#660">()</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D=
"color:#000"> <br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> i</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#000"> <br><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#800">// for comparison:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color:#008">struct</span><span style=3D"color:#000">=
 </span><span style=3D"color:#008">lambda</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">int</span><sp=
an style=3D"color:#000"> i</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor:#008">auto</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">operator</span><span style=3D"color:#660">()(</span><span style=3D=
"color:#008">decltype</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:#008">const</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">{}</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// This is (int&amp;)</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">operator</span><span style=3D"color:#660">()()</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">const</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">-&gt;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">decltype</span><span =
style=3D"color:#660">((</span><span style=3D"color:#000">i</span><span styl=
e=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"col=
or:#800">// This returns const int&amp;</span><span style=3D"color:#000"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:#660">};</span><span style=3D"c=
olor:#000"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#660">[</span>=
<span style=3D"color:#000">i</span><span style=3D"color:#660">](</span><spa=
n style=3D"color:#008">decltype</span><span style=3D"color:#660">((</span><=
span style=3D"color:#000">i</span><span style=3D"color:#660">))){</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">};</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#800">// this is [i](int&a=
mp;){} currently</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </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 st=
yle=3D"color:#660">-&gt;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">decltype</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"> </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:#800">/* ... */</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">};</span><span style=3D"=
color:#000"> </span><span style=3D"color:#800">// this is [i]() -&gt; int&a=
mp; { ... } currently</span></div></code></div></div></blockquote><div><br>=
</div><div>This is a VERY good point! =C2=A0I think that the solution is si=
mple but unfortunate, and it all stems from the simple but unfortunate deci=
sion in C++11 to make lambdas&#39; operator() methods &quot;one level more =
const&quot; than the syntax implies.</div><div><br></div><div class=3D"pret=
typrint" style=3D"background-color: rgb(250, 250, 250); border: 1px solid r=
gb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> cf </spa=
n><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: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">i</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">]()</span><span style=3D"color: #000;" class=3D"s=
tyled-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">return</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">i</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"styl=
ed-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-=
by-prettify">// the return type here is (const int *), not (int *)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> mf </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=
: #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: #008;" class=3D"styled-by-pretti=
fy">mutable</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 sty=
le=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">&amp;</span><span style=3D"color: #00=
0;" 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"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"> =
=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// t=
he return type here is (int *)</span></div></code></div><div><div><br></div=
></div><div>IMHO decltype-of-the-returned-expression should Just Work, whic=
h means you MUST break C++11 compatibility if you want this feature:</div><=
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 class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #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"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> cf </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: #660;" class=3D"styled-by-pretti=
fy">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">i</sp=
an><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">-&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">decltype</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(&amp;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">i</span><span style=3D"color: #660;" class=3D"st=
yled-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"> </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">&amp;</span><span style=3D"colo=
r: #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-b=
y-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// the return type here is (int *) in C++11, but IMHO it should be (const =
int *) after this patch</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> mf </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</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">i</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">]()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">mutable</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">decltype</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><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: #0=
08;" 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">&amp;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">i</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: #660;" class=3D"styled-by-prettify">};</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">// the return type her=
e is (int *)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span></div></code></div><div><br></div><div>This will make it align=
 nicely with the struct-and-member-function version:</div><div><br></div><d=
iv class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bor=
der: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">struct</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-prett=
ify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> cf</span=
><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: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">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">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">i</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">};</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// the return typ=
e here is (const int *)</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> mf</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">-&gt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</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">{</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"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">i</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">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// the return type here is (int *)</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><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></div></code></div><div><br>I w=
ould also want the paper to specifically confront the issue of</div><div><b=
r></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 =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</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"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f </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: #660;" class=3D"styled-by-prettify">[</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">i</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0L</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">](</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">char</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> i</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">-=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">decltype</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">i</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"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">// decltype(f(0)) =3D=3D ???</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div>=
</code></div><div><br>Right now, <a href=3D"http://melpon.org/wandbox/perml=
ink/Euvw0dWDVX9HyIEG">GCC and Clang disagree on the meaning</a> of [i](int =
i) { return i; } =E2=80=94 GCC makes the member variable silently shadow th=
e parameter, while Clang makes the parameter silently shadow the member var=
iable. Neither one is friendly behavior, and I believe GCC&#39;s behavior i=
s just flat wrong, but I have not checked the Standard. =C2=A0I have confir=
med that in a normal member function, for the purposes of trailing decltype=
s, <a href=3D"http://melpon.org/wandbox/permlink/WQjQ7Sh2sLtkDTsw">paramete=
rs do shadow member variables</a>.</div><div><br></div><div>Finally, as ano=
ther corner case separate from T.C.&#39;s cases, I would like to see explic=
it discussion of whether a trailing <font face=3D"courier new, monospace">d=
ecltype(i)</font> can be affected by a default capture e.g. <font face=3D"c=
ourier new, monospace">[=3D]</font> or <font face=3D"courier new, monospace=
">[&amp;]</font>. Are the names of the default-captured variables in scope =
during the parsing of the trailing return type? =C2=A0I suspect there&#39;s=
 an easy and unsurprising answer, I just haven&#39;t thought much about it =
and I think someone should.</div><div><br></div><div>HTH,</div><div>=E2=80=
=93Arthur</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6a156e3d-77c5-4b98-aa9d-529eb7621e2b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6a156e3d-77c5-4b98-aa9d-529eb7621e2b=
%40isocpp.org</a>.<br />

------=_Part_3_1686758882.1481851359617--

------=_Part_2_29372470.1481851359615--

.


Author: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Date: Sat, 17 Dec 2016 07:14:30 -0800 (PST)
Raw View
------=_Part_779_216450449.1481987670360
Content-Type: multipart/alternative;
 boundary="----=_Part_780_1476758788.1481987670362"

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

Thank you very much for the feedback.

Here's a new draft:
https://vittorioromeo.info/Misc/lambda_issue_draft_2.html

I've looked into most of the issues/inconsistencies you suggested, and I=20
came to the conclusion that also simple-captures need to be "visible" in=20
the lambda-declarator.
I'm not sure if the proposed wording is correct (and I'm not sure how I=20
should address captures by reference, as they're not covered by =C2=A75.1.5=
/17=20
<https://timsong-cpp.github.io/cppwp/expr.prim.lambda#17>).

Some questions/feedback requests:
* Any idea for a title that clearly conveys the intent of making both=20
simple-captures and init-captures usable in the lambda-declarator in order=
=20
to achieve consistency with classes?
* Are the proposed changes to the standard reasonable? Would the addition=
=20
of a new paragraph make it clearer that all types of captures should be=20
accessible in the lambda-declarator for consistency with classes?
* The last example posted by Arthur
    int i;
    auto f =3D [i=3D0L](char i) -> decltype(i) { return 0; }
    // decltype(f(0)) =3D=3D ???
is something that the paper should address, after the change in scope. I am=
=20
not sure where to start here though, as I'm confident that multiple rules=
=20
from different parts of the standard come into play here.=20
Intuitively I think that the return type should evaluate to `char` (as the=
=20
parameter `i` is closer to the trailing return type). What do you think? =
=20


On Thursday, 15 December 2016 13:27:06 UTC, Vittorio Romeo wrote:
>
> int main(){
>     auto l =3D [x =3D 10]() -> decltype(x) {};}
>
>
>
>
>    -=20
>   =20
>    *clang++ 4.0* rejects this code=20
>    <http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe> with the=20
>    following error:
>    -=20
>   =20
>    error: use of undeclared identifier 'x'
>            auto l =3D [x =3D 10]() -> decltype(x) {};
>                                            ^
>   =20
>    -=20
>   =20
>    *g++ 7* rejects this code=20
>    <http://melpon.org/wandbox/permlink/LXamt4MieU6n77Xs> with the=20
>    following error:
>   =20
>    In function 'int main()':
>    error: 'x' was not declared in this scope
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>    error: 'x' was not declared in this scopeIn lambda function:
>    warning: no return statement in function returning non-void [-Wreturn-=
type]
>      auto l =3D [x =3D 10]() -> decltype(x) {};
>                                      ^
>   =20
>   =20
>   =20
> I posted this today on StackOverflow thinking it was a compiler bug:
> http://stackoverflow.com/questions/41162200/
>
> But it's not - the standard says that the scope of `x` is limited to the=
=20
> body of the lambda. This answer has the details:=20
> http://stackoverflow.com/a/41162972/598696
> (quoted below)
>
> ---
>
> *TL;DR*: Compilers behave as expected.
>
> The standard defines lambda semantics as follows [expr.prim.lambda,=20
> section 1]:
>
> lambda-expression:
>
>    lambda-introducer lambda-declarator_opt compound-statement
>
> Here *compound-statement* is just the body of lambda between {}, because=
=20
> everything else is included in *lambda-declarator*:
>
> lambda-declarator:
>
>    ( parameter-declaration-clause ) decl-specifier-seq_opt
>        exception-specification_opt attribute-specifier-seq_opt trailing-r=
eturn-type_opt
>
> Also, in section 12 of the same chapter, it's said that
>
> An init-capture behaves as if it declares and explicitly captures a=20
> variable of the form =E2=80=9Cauto init-capture ;=E2=80=9D whose declarat=
ive region is the=20
> lambda-expression=E2=80=99s compound-statement, except that:
>
> (12.1) =E2=80=94 if the capture is by copy (see below), the non-static da=
ta member=20
> declared for the capture and the variable are treated as two different wa=
ys=20
> of referring to the same object, which has the lifetime of the non-static=
=20
> data member, and no additional copy and destruction is performed, and
>
> (12.2) =E2=80=94 if the capture is by reference, the variable=E2=80=99s l=
ifetime ends when=20
> the closure object=E2=80=99s lifetime ends.
>
> So, in your first example, variable x scope is the lambda body only, not=
=20
> including the decltypeexpression. In the second example, obviously, x sco=
pe=20
> is the function main.
>
> ---
>
> Do you think that writing a proposal to relax these rules and to=20
> explicitly allow generalized captures to be used inside the trailing retu=
rn=20
> type would be worthwhile?
>
> One possible use case is when the generalized captures are initialized=20
> with complex expressions. I encountered this while experimenting today (
> http://melpon.org/wandbox/permlink/aVasfHaK6boC6NZt).
> In general, it would be beneficial to have this feature whenever the=20
> generalized capture is used as part of the return expression in the lambd=
a=20
> body.
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/cba1a1fa-d3c8-43e0-a1b5-f69fb285a680%40isocpp.or=
g.

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

<div dir=3D"ltr">Thank you very much for the feedback.<br><br>Here&#39;s a =
new draft:<br><a href=3D"https://vittorioromeo.info/Misc/lambda_issue_draft=
_2.html">https://vittorioromeo.info/Misc/lambda_issue_draft_2.html</a><div>=
<br></div><div>I&#39;ve looked into most of the issues/inconsistencies you =
suggested, and I came to the conclusion that also simple-captures need to b=
e &quot;visible&quot; in the lambda-declarator.<br>I&#39;m not sure if the =
proposed wording is correct (and I&#39;m not sure how I should address capt=
ures by reference, as they&#39;re not covered by=C2=A0<a href=3D"https://ti=
msong-cpp.github.io/cppwp/expr.prim.lambda#17" style=3D"font-family: &quot;=
Times New Roman&quot;; font-size: medium;">=C2=A75.1.5/17</a>).<br><br>Some=
 questions/feedback requests:</div><div>* Any idea for a title that clearly=
 conveys the intent of making both simple-captures and init-captures usable=
 in the lambda-declarator in order to achieve consistency with classes?<br>=
* Are the proposed changes to the standard reasonable? Would the addition o=
f a new paragraph make it clearer that all types of captures should be acce=
ssible in the lambda-declarator for consistency with classes?<br>* The last=
 example posted by Arthur<br><span style=3D"font-family: monospace; backgro=
und-color: rgb(250, 250, 250); color: rgb(0, 0, 0);">=C2=A0 =C2=A0=C2=A0</s=
pan><span style=3D"font-family: monospace; background-color: rgb(250, 250, =
250); color: rgb(0, 0, 136);">int</span><span style=3D"font-family: monospa=
ce; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);">=C2=A0i</sp=
an><span style=3D"font-family: monospace; background-color: rgb(250, 250, 2=
50); color: rgb(102, 102, 0);">;</span><span style=3D"font-family: monospac=
e; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);"><br>=C2=A0 =
=C2=A0=C2=A0</span><span style=3D"font-family: monospace; background-color:=
 rgb(250, 250, 250); color: rgb(0, 0, 136);">auto</span><span style=3D"font=
-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0, =
0);">=C2=A0f=C2=A0</span><span style=3D"font-family: monospace; background-=
color: rgb(250, 250, 250); color: rgb(102, 102, 0);">=3D</span><span style=
=3D"font-family: monospace; background-color: rgb(250, 250, 250); color: rg=
b(0, 0, 0);">=C2=A0</span><span style=3D"font-family: monospace; background=
-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">[</span><span style=
=3D"font-family: monospace; background-color: rgb(250, 250, 250); color: rg=
b(0, 0, 0);">i</span><span style=3D"font-family: monospace; background-colo=
r: rgb(250, 250, 250); color: rgb(102, 102, 0);">=3D</span><span style=3D"f=
ont-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0, =
102, 102);">0L</span><span style=3D"font-family: monospace; background-colo=
r: rgb(250, 250, 250); color: rgb(102, 102, 0);">](</span><span style=3D"fo=
nt-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0=
, 136);">char</span><span style=3D"font-family: monospace; background-color=
: rgb(250, 250, 250); color: rgb(0, 0, 0);">=C2=A0i</span><span style=3D"fo=
nt-family: monospace; background-color: rgb(250, 250, 250); color: rgb(102,=
 102, 0);">)</span><span style=3D"font-family: monospace; background-color:=
 rgb(250, 250, 250); color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"font=
-family: monospace; background-color: rgb(250, 250, 250); color: rgb(102, 1=
02, 0);">-&gt;</span><span style=3D"font-family: monospace; background-colo=
r: rgb(250, 250, 250); color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"fo=
nt-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0=
, 136);">decltype</span><span style=3D"font-family: monospace; background-c=
olor: rgb(250, 250, 250); color: rgb(102, 102, 0);">(</span><span style=3D"=
font-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0,=
 0, 0);">i</span><span style=3D"font-family: monospace; background-color: r=
gb(250, 250, 250); color: rgb(102, 102, 0);">)</span><span style=3D"font-fa=
mily: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);=
">=C2=A0</span><span style=3D"font-family: monospace; background-color: rgb=
(250, 250, 250); color: rgb(102, 102, 0);">{</span><span style=3D"font-fami=
ly: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);">=
=C2=A0</span><span style=3D"font-family: monospace; background-color: rgb(2=
50, 250, 250); color: rgb(0, 0, 136);">return</span><span style=3D"font-fam=
ily: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);"=
>=C2=A0</span><span style=3D"font-family: monospace; background-color: rgb(=
250, 250, 250); color: rgb(0, 102, 102);">0</span><span style=3D"font-famil=
y: monospace; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0)=
;">;</span><span style=3D"font-family: monospace; background-color: rgb(250=
, 250, 250); color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"font-family:=
 monospace; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0);"=
>}</span><span style=3D"font-family: monospace; background-color: rgb(250, =
250, 250); color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0=C2=A0</span><span style=
=3D"font-family: monospace; background-color: rgb(250, 250, 250); color: rg=
b(136, 0, 0);">// decltype(f(0)) =3D=3D ???</span><br>is something that the=
 paper should address, after the change in scope. I am not sure where to st=
art here though, as I&#39;m confident that multiple rules from different pa=
rts of the standard come into play here. <br>Intuitively I think that the r=
eturn type should evaluate to `char` (as the parameter `i` is closer to the=
 trailing return type). What do you think? =C2=A0<br><br><br>On Thursday, 1=
5 December 2016 13:27:06 UTC, Vittorio Romeo  wrote:<blockquote class=3D"gm=
ail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc soli=
d;padding-left: 1ex;"><div dir=3D"ltr"><pre class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot;Lucida Consol=
e&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bits=
tream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif;whi=
te-space:inherit"><span style=3D"color:rgb(43,145,175)">int</span><span sty=
le=3D"color:rgb(48,51,54)"> main</span><span style=3D"color:rgb(48,51,54)">=
()</span><span style=3D"color:rgb(48,51,54)">
</span><span style=3D"color:rgb(48,51,54)">{</span><span style=3D"color:rgb=
(48,51,54)">
    </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"c=
olor:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span=
><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51=
,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"c=
olor:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><=
span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51=
,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"=
color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </spa=
n><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:=
rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </=
span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb=
(48,51,54)">
</span><span style=3D"color:rgb(48,51,54)">}
</span></code></pre><br><br><ul style=3D"margin:0px 0px 1em 30px;padding:0p=
x;border:0px;font-size:15px;font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;color:rgb(36,39,41)"><li style=3D"margin:0px 0px 0.5em;p=
adding:0px;border:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=
=3D"http://melpon.org/wandbox/permlink/zsFICgiaMhCrIIwe" rel=3D"nofollow" s=
tyle=3D"color:rgb(0,89,153);font-family:Arial,&quot;Helvetica Neue&quot;,He=
lvetica,sans-serif;font-size:15px" target=3D"_blank" onmousedown=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%=
2Fpermlink%2FzsFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWA=
WY4JcXh_a1opBWZW0-WwRMw&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2Fz=
sFICgiaMhCrIIwe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9SWAWY4JcXh_a1opBW=
ZW0-WwRMw&#39;;return true;"><strong style=3D"color:rgb(0,89,153);font-fami=
ly:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15px">cl=
ang++ 4.0</strong><font color=3D"#005999" style=3D"color:rgb(0,89,153);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;font-size:15p=
x"><span>=C2=A0rejects this code</span></font></a><font color=3D"#242729" f=
ace=3D"Arial, Helvetica Neue, Helvetica, sans-serif"><span style=3D"font-si=
ze:15px">=C2=A0with the following error:</span></font><br></p></li><li styl=
e=3D"margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word"><pre=
 style=3D"margin-top:0.5em;margin-bottom:1em;padding:5px;font-size:13px;wid=
th:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,&q=
uot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono=
&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospa=
ce,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wr=
ap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot;Lucida Co=
nsole&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;=
Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif=
;white-space:inherit"><span style=3D"color:rgb(48,51,54)">error</span><span=
 style=3D"color:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">=
 use of undeclared identifier </span><span style=3D"color:rgb(125,39,39)">&=
#39;x&#39;</span><span style=3D"color:rgb(48,51,54)">
        </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=
=3D"color:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D<=
/span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(=
48,51,54)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=
=3D"color:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </s=
pan><span style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(=
48,51,54)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span styl=
e=3D"color:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> =
</span><span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"c=
olor:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><sp=
an style=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)=
"> </span><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"colo=
r:rgb(48,51,54)">
                                        </span><span style=3D"color:rgb(48,=
51,54)">^</span></code></pre></li><li style=3D"margin:0px;padding:0px;borde=
r:0px;word-wrap:break-word"><p style=3D"clear:both"><a href=3D"http://melpo=
n.org/wandbox/permlink/LXamt4MieU6n77Xs" rel=3D"nofollow" style=3D"color:rg=
b(0,89,153)" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.g=
oogle.com/url?q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4Mie=
U6n77Xs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFB=
w&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?=
q\x3dhttp%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FLXamt4MieU6n77Xs\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHSPSY4b2BOHlywp5QOvR96HtQFBw&#39;;return =
true;"><strong>g++ 7</strong>=C2=A0rejects this code</a>=C2=A0with the foll=
owing error:</p><pre style=3D"margin-top:0.5em;margin-bottom:1em;padding:5p=
x;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Cons=
olas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&q=
uot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Couri=
er New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:r=
gb(57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Mo=
naco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sa=
ns Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,=
monospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(43,145,1=
75)">In</span><span style=3D"color:rgb(48,51,54)"> function </span><span st=
yle=3D"color:rgb(125,39,39)">&#39;int main()&#39;</span><span style=3D"colo=
r:rgb(48,51,54)">:</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span><span style=3D"color:rgb(48,51,54)">
error</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"colo=
r:rgb(48,51,54)"> </span><span style=3D"color:rgb(125,39,39)">&#39;x&#39;</=
span><span style=3D"color:rgb(48,51,54)"> was not declared in </span><span =
style=3D"color:rgb(16,16,148)">this</span><span style=3D"color:rgb(48,51,54=
)"> scope
</span><span style=3D"color:rgb(43,145,175)">In</span><span style=3D"color:=
rgb(48,51,54)"> lambda function</span><span style=3D"color:rgb(48,51,54)">:=
</span><span style=3D"color:rgb(48,51,54)">
warning</span><span style=3D"color:rgb(48,51,54)">:</span><span style=3D"co=
lor:rgb(48,51,54)"> no </span><span style=3D"color:rgb(16,16,148)">return</=
span><span style=3D"color:rgb(48,51,54)"> statement in function returning n=
on</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(16,16,148)">void</span><span style=3D"color:rgb(48,51,54)"> </span><span=
 style=3D"color:rgb(48,51,54)">[-</span><span style=3D"color:rgb(43,145,175=
)">Wreturn</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D=
"color:rgb(48,51,54)">type</span><span style=3D"color:rgb(48,51,54)">]</spa=
n><span style=3D"color:rgb(48,51,54)">
  </span><span style=3D"color:rgb(16,16,148)">auto</span><span style=3D"col=
or:rgb(48,51,54)"> l </span><span style=3D"color:rgb(48,51,54)">=3D</span><=
span style=3D"color:rgb(48,51,54)"> </span><span style=3D"color:rgb(48,51,5=
4)">[</span><span style=3D"color:rgb(48,51,54)">x </span><span style=3D"col=
or:rgb(48,51,54)">=3D</span><span style=3D"color:rgb(48,51,54)"> </span><sp=
an style=3D"color:rgb(125,39,39)">10</span><span style=3D"color:rgb(48,51,5=
4)">]()</span><span style=3D"color:rgb(48,51,54)"> </span><span style=3D"co=
lor:rgb(48,51,54)">-&gt;</span><span style=3D"color:rgb(48,51,54)"> </span>=
<span style=3D"color:rgb(16,16,148)">decltype</span><span style=3D"color:rg=
b(48,51,54)">(</span><span style=3D"color:rgb(48,51,54)">x</span><span styl=
e=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> </sp=
an><span style=3D"color:rgb(48,51,54)">{};</span><span style=3D"color:rgb(4=
8,51,54)">
                                  </span><span style=3D"color:rgb(48,51,54)=
">^</span></code></pre><br></li></ul><font color=3D"#303336" face=3D"Consol=
as, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitst=
ream Vera Sans Mono, Courier New, monospace, sans-serif"><span style=3D"whi=
te-space:pre">I posted this today on StackOverflow thinking it was a compil=
er bug:</span></font><div><font color=3D"#303336" face=3D"Consolas, Menlo, =
Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera S=
ans Mono, Courier New, monospace, sans-serif"><span style=3D"white-space:pr=
e"><a href=3D"http://stackoverflow.com/questions/41162200/" target=3D"_blan=
k" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/u=
rl?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true=
;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F=
stackoverflow.com%2Fquestions%2F41162200%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNHh5TH7No6BzVZwtlQGB-vFYN7FSw&#39;;return true;">http://stackoverfl=
ow.com/<wbr>questions/41162200/</a></span><br></font></div><div><font color=
=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mo=
no, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, san=
s-serif"><span style=3D"white-space:pre"><br></span></font></div><div><font=
 color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberat=
ion Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospac=
e, sans-serif"><span style=3D"white-space:pre">But it&#39;s not - the stand=
ard says that the scope of `x` is limited to the body of the lambda. This a=
nswer has the details:</span>
</font></div><div><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, =
Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono=
, Courier New, monospace, sans-serif"><span style=3D"white-space:pre"><a hr=
ef=3D"http://stackoverflow.com/a/41162972/598696" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fstackoverflow.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d=
1\x26usg\x3dAFQjCNEkofXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverf=
low.com%2Fa%2F41162972%2F598696\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEko=
fXkcuUbDPfQ57qIz4z2p7fgKQ&#39;;return true;">http://stackoverflow.com/a/<wb=
r>41162972/598696</a></span><br></font></div><div><font color=3D"#303336" f=
ace=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu San=
s Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif"><span=
 style=3D"white-space:pre">(quoted below)</span></font></div><div><font col=
or=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation =
Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, s=
ans-serif"><span style=3D"white-space:pre"><br></span></font></div><div><fo=
nt color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liber=
ation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monosp=
ace, sans-serif"><span style=3D"white-space:pre">---</span></font></div><di=
v><font color=3D"#303336" face=3D"Consolas, Menlo, Monaco, Lucida Console, =
Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, m=
onospace, sans-serif"><span style=3D"white-space:pre"><br></span></font></d=
iv><div><p style=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(3=
6,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"=
><strong>TL;DR</strong>: Compilers behave as expected.</p><p style=3D"margi=
n-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Aria=
l,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">The standard defines lam=
bda semantics as follows [expr.prim.lambda, section 1]:</p><blockquote styl=
e=3D"margin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-t=
op-style:initial;border-right-style:initial;border-bottom-style:initial;bor=
der-left-style:solid;border-top-color:initial;border-right-color:initial;bo=
rder-bottom-color:initial;border-left-color:rgb(255,235,142);font-size:15px=
;quotes:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-fam=
ily:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"marg=
in-bottom:1em;clear:both">lambda-expression:</p><pre style=3D"padding:5px;f=
ont-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consola=
s,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot=
;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier =
New&quot;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(=
57,51,24);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monac=
o,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans =
Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mon=
ospace,sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">=
   lambda</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"=
color:rgb(48,51,54)">introducer lambda</span><span style=3D"color:rgb(48,51=
,54)">-</span><span style=3D"color:rgb(48,51,54)">declarator_opt compound</=
span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(4=
8,51,54)">statement</span></code></pre></blockquote><p style=3D"margin-bott=
om:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quo=
t;Helvetica Neue&quot;,Helvetica,sans-serif">Here=C2=A0<em>compound-stateme=
nt</em>=C2=A0is just the body of lambda between {}, because everything else=
 is included in=C2=A0<em>lambda-declarator</em>:</p><blockquote style=3D"ma=
rgin:0px 0px 10px;padding:10px;border-width:0px 0px 0px 2px;border-top-styl=
e:initial;border-right-style:initial;border-bottom-style:initial;border-lef=
t-style:solid;border-top-color:initial;border-right-color:initial;border-bo=
ttom-color:initial;border-left-color:rgb(255,235,142);font-size:15px;quotes=
:none;background-color:rgb(255,248,220);color:rgb(36,39,41);font-family:Ari=
al,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><p style=3D"margin-bott=
om:1em;clear:both">lambda-declarator:</p><pre style=3D"padding:5px;font-siz=
e:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,2=
4);word-wrap:normal"><code style=3D"font-family:Consolas,Menlo,Monaco,&quot=
;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&qu=
ot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace,=
sans-serif;white-space:inherit"><span style=3D"color:rgb(48,51,54)">   </sp=
an><span style=3D"color:rgb(48,51,54)">(</span><span style=3D"color:rgb(48,=
51,54)"> parameter</span><span style=3D"color:rgb(48,51,54)">-</span><span =
style=3D"color:rgb(48,51,54)">declaration</span><span style=3D"color:rgb(48=
,51,54)">-</span><span style=3D"color:rgb(48,51,54)">clause </span><span st=
yle=3D"color:rgb(48,51,54)">)</span><span style=3D"color:rgb(48,51,54)"> de=
cl</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:r=
gb(48,51,54)">specifier</span><span style=3D"color:rgb(48,51,54)">-</span><=
span style=3D"color:rgb(48,51,54)">seq_opt
       exception</span><span style=3D"color:rgb(48,51,54)">-</span><span st=
yle=3D"color:rgb(48,51,54)">specification_opt attribute</span><span style=
=3D"color:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">specif=
ier</span><span style=3D"color:rgb(48,51,54)">-</span><span style=3D"color:=
rgb(48,51,54)">seq_opt trailing</span><span style=3D"color:rgb(48,51,54)">-=
</span><span style=3D"color:rgb(16,16,148)">return</span><span style=3D"col=
or:rgb(48,51,54)">-</span><span style=3D"color:rgb(48,51,54)">type_opt</spa=
n></code></pre></blockquote><p style=3D"margin-bottom:1em;font-size:15px;cl=
ear:both;color:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,H=
elvetica,sans-serif">Also, in section 12 of the same chapter, it&#39;s said=
 that</p><blockquote style=3D"margin:0px 0px 10px;padding:10px;border-width=
:0px 0px 0px 2px;border-top-style:initial;border-right-style:initial;border=
-bottom-style:initial;border-left-style:solid;border-top-color:initial;bord=
er-right-color:initial;border-bottom-color:initial;border-left-color:rgb(25=
5,235,142);font-size:15px;quotes:none;background-color:rgb(255,248,220);col=
or:rgb(36,39,41);font-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,san=
s-serif"><p style=3D"margin-bottom:1em;clear:both">An init-capture behaves =
as if it declares and explicitly captures a variable of the form =E2=80=9Ca=
uto init-capture ;=E2=80=9D whose declarative region is the lambda-expressi=
on=E2=80=99s compound-statement, except that:</p><p style=3D"margin-bottom:=
1em;clear:both">(12.1) =E2=80=94 if the capture is by copy (see below), the=
 non-static data member declared for the capture and the variable are treat=
ed as two different ways of referring to the same object, which has the lif=
etime of the non-static data member, and no additional copy and destruction=
 is performed, and</p><p style=3D"clear:both">(12.2) =E2=80=94 if the captu=
re is by reference, the variable=E2=80=99s lifetime ends when the closure o=
bject=E2=80=99s lifetime ends.</p></blockquote><p style=3D"margin-bottom:1e=
m;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial,&quot;Hel=
vetica Neue&quot;,Helvetica,sans-serif">So, in your first example, variable=
=C2=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Me=
nlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;Dej=
aVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&=
quot;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pr=
e-wrap">x</code>=C2=A0scope is the lambda body only, not including the=C2=
=A0<code style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo=
,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu=
 Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quo=
t;,monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-w=
rap">decltype</code>expression. In the second example, obviously,=C2=A0<cod=
e style=3D"padding:1px 5px;font-size:13px;font-family:Consolas,Menlo,Monaco=
,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans M=
ono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&quot;,mono=
space,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">x<=
/code>=C2=A0scope is the function=C2=A0<code style=3D"padding:1px 5px;font-=
size:13px;font-family:Consolas,Menlo,Monaco,&quot;Lucida Console&quot;,&quo=
t;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera S=
ans Mono&quot;,&quot;Courier New&quot;,monospace,sans-serif;background-colo=
r:rgb(239,240,241);white-space:pre-wrap">main</code>.</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">---</p><p style=3D"margin=
-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font-family:Arial=
,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">Do you think that writing=
 a proposal to relax these rules and to explicitly allow generalized captur=
es to be used inside the trailing return type would be worthwhile?</p><p st=
yle=3D"margin-bottom:1em;font-size:15px;clear:both;color:rgb(36,39,41);font=
-family:Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">One possible=
 use case is when the generalized captures are initialized with complex exp=
ressions. I encountered this while experimenting today (<a href=3D"http://m=
elpon.org/wandbox/permlink/aVasfHaK6boC6NZt" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A=
%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz=
\x3d1\x26usg\x3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmelpon.o=
rg%2Fwandbox%2Fpermlink%2FaVasfHaK6boC6NZt\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNEN9UL7N_EUam7yz8sx7tVoHRW3xA&#39;;return true;">http://melpon.org/w=
andbox/<wbr>permlink/aVasfHaK6boC6NZt</a>).<br>In general, it would be bene=
ficial to have this feature whenever the generalized capture is used as par=
t of the return expression in the lambda body.</p></div></div></blockquote>=
</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/cba1a1fa-d3c8-43e0-a1b5-f69fb285a680%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cba1a1fa-d3c8-43e0-a1b5-f69fb285a680=
%40isocpp.org</a>.<br />

------=_Part_780_1476758788.1481987670362--

------=_Part_779_216450449.1481987670360--

.


Author: "D. B." <db0451@gmail.com>
Date: Sat, 17 Dec 2016 15:26:21 +0000
Raw View
--047d7b86e2f80e722a0543dc4f70
Content-Type: text/plain; charset=UTF-8

On Sat, Dec 17, 2016 at 3:14 PM, Vittorio Romeo <
vittorio.romeo.vee@gmail.com> wrote:

>
> * The last example posted by Arthur
>     int i;
>     auto f = [i=0L](char i) -> decltype(i) { return 0; }
>     // decltype(f(0)) == ???
> is something that the paper should address, after the change in scope. I
> am not sure where to start here though, as I'm confident that multiple
> rules from different parts of the standard come into play here.
> Intuitively I think that the return type should evaluate to `char` (as the
> parameter `i` is closer to the trailing return type). What do you think?
>


I agree with Arthur and you on this, particularly because in addition to
being geographically closer, having the parameter shadow the member
variable is correct in terms of consistency with 'real' class methods.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFTaWLRhxJkoDk9Aaar7xD_-%2BEOqkCwhYK6iz4ebd9HVQ%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
at, Dec 17, 2016 at 3:14 PM, Vittorio Romeo <span dir=3D"ltr">&lt;<a href=
=3D"mailto:vittorio.romeo.vee@gmail.com" target=3D"_blank">vittorio.romeo.v=
ee@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><br><div>* The last example posted by Arthur<span class=3D""><br=
><span style=3D"font-family:monospace;background-color:rgb(250,250,250);col=
or:rgb(0,0,0)">=C2=A0 =C2=A0=C2=A0</span><span style=3D"font-family:monospa=
ce;background-color:rgb(250,250,250);color:rgb(0,0,136)">int</span><span st=
yle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,=
0,0)">=C2=A0i</span><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(102,102,0)">;</span><span style=3D"font-family:mo=
nospace;background-color:rgb(250,250,250);color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(2=
50,250,250);color:rgb(0,0,136)">auto</span><span style=3D"font-family:monos=
pace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0f=C2=A0</spa=
n><span style=3D"font-family:monospace;background-color:rgb(250,250,250);co=
lor:rgb(102,102,0)">=3D</span><span style=3D"font-family:monospace;backgrou=
nd-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"fon=
t-family:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">=
[</span><span style=3D"font-family:monospace;background-color:rgb(250,250,2=
50);color:rgb(0,0,0)">i</span><span style=3D"font-family:monospace;backgrou=
nd-color:rgb(250,250,250);color:rgb(102,102,0)">=3D</span><span style=3D"fo=
nt-family:monospace;background-color:rgb(250,250,250);color:rgb(0,102,102)"=
>0L</span><span style=3D"font-family:monospace;background-color:rgb(250,250=
,250);color:rgb(102,102,0)">](</span><span style=3D"font-family:monospace;b=
ackground-color:rgb(250,250,250);color:rgb(0,0,136)">char</span><span style=
=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0=
)">=C2=A0i</span><span style=3D"font-family:monospace;background-color:rgb(=
250,250,250);color:rgb(102,102,0)">)</span><span style=3D"font-family:monos=
pace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span=
 style=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb=
(102,102,0)">-&gt;</span><span style=3D"font-family:monospace;background-co=
lor:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-fam=
ily:monospace;background-color:rgb(250,250,250);color:rgb(0,0,136)">d<wbr>e=
cltype</span><span style=3D"font-family:monospace;background-color:rgb(250,=
250,250);color:rgb(102,102,0)">(</span><span style=3D"font-family:monospace=
;background-color:rgb(250,250,250);color:rgb(0,0,0)">i</span><span style=3D=
"font-family:monospace;background-color:rgb(250,250,250);color:rgb(102,102,=
0)">)</span><span style=3D"font-family:monospace;background-color:rgb(250,2=
50,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monospace=
;background-color:rgb(250,250,250);color:rgb(102,102,0)">{</span><span styl=
e=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,=
0)">=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(=
250,250,250);color:rgb(0,0,136)">return</span><span style=3D"font-family:mo=
nospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><s=
pan style=3D"font-family:monospace;background-color:rgb(250,250,250);color:=
rgb(0,102,102)">0</span><span style=3D"font-family:monospace;background-col=
or:rgb(250,250,250);color:rgb(102,102,0)">;</span><span style=3D"font-famil=
y:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</spa=
n><span style=3D"font-family:monospace;background-color:rgb(250,250,250);co=
lor:rgb(102,102,0)">}</span><span style=3D"font-family:monospace;background=
-color:rgb(250,250,250);color:rgb(0,0,0)"><br>=C2=A0 =C2=A0=C2=A0</span><sp=
an style=3D"font-family:monospace;background-color:rgb(250,250,250);color:r=
gb(136,0,0)">// decltype(f(0)) =3D=3D ???</span><br></span>is something tha=
t the paper should address, after the change in scope. I am not sure where =
to start here though, as I&#39;m confident that multiple rules from differe=
nt parts of the standard come into play here. <br>Intuitively I think that =
the return type should evaluate to `char` (as the parameter `i` is closer t=
o the trailing return type). What do you think?=C2=A0 <span class=3D""></sp=
an></div></div></blockquote><div><br><br></div><div>I agree with Arthur and=
 you on this, particularly because in addition to being geographically clos=
er, having the parameter shadow the member variable is correct in terms of =
consistency with &#39;real&#39; class methods.<br><br></div></div></div></d=
iv>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhFTaWLRhxJkoDk9Aaar7xD_-%2BEOqk=
CwhYK6iz4ebd9HVQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFTaWLRhx=
JkoDk9Aaar7xD_-%2BEOqkCwhYK6iz4ebd9HVQ%40mail.gmail.com</a>.<br />

--047d7b86e2f80e722a0543dc4f70--

.


Author: "T. C." <rs2740@gmail.com>
Date: Mon, 19 Dec 2016 12:21:24 -0800 (PST)
Raw View
------=_Part_1216_1208111683.1482178884753
Content-Type: multipart/alternative;
 boundary="----=_Part_1217_2041919753.1482178884754"

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



On Saturday, December 17, 2016 at 10:14:30 AM UTC-5, Vittorio Romeo wrote:
>
> Thank you very much for the feedback.
>
> Here's a new draft:
> https://vittorioromeo.info/Misc/lambda_issue_draft_2.html
>
> I've looked into most of the issues/inconsistencies you suggested, and I=
=20
> came to the conclusion that also simple-captures need to be "visible" in=
=20
> the lambda-declarator.
> I'm not sure if the proposed wording is correct (and I'm not sure how I=
=20
> should address captures by reference, as they're not covered by =C2=A75.1=
..5/17=20
> <https://timsong-cpp.github.io/cppwp/expr.prim.lambda#17>).
>
> Some questions/feedback requests:
> * Any idea for a title that clearly conveys the intent of making both=20
> simple-captures and init-captures usable in the lambda-declarator in orde=
r=20
> to achieve consistency with classes?
> * Are the proposed changes to the standard reasonable? Would the addition=
=20
> of a new paragraph make it clearer that all types of captures should be=
=20
> accessible in the lambda-declarator for consistency with classes?
> * The last example posted by Arthur
>     int i;
>     auto f =3D [i=3D0L](char i) -> decltype(i) { return 0; }
>     // decltype(f(0)) =3D=3D ???
> is something that the paper should address, after the change in scope. I=
=20
> am not sure where to start here though, as I'm confident that multiple=20
> rules from different parts of the standard come into play here.=20
> Intuitively I think that the return type should evaluate to `char` (as th=
e=20
> parameter `i` is closer to the trailing return type). What do you think? =
=20
>
>
>
More cases to address - interaction with default captures and with=20
references captured-by-copy:

const int& x =3D 1;
[x](decltype(x)) {} // this is (const int&) currently. (const int) under=20
your rules?
[=3D]{ decltype(x) y =3D 1; } // this is (const int&) currently again, ???=
=20
under your rules


The p17 change isn't on point: decltype isn't an odr-use (indeed I wonder=
=20
if it's even possible to odr-use *anything* in a lambda-declarator). The=20
note in the paragraph also needs changing.

In general, I'd suggest laying out the various examples first and saving=20
the wording until the end. The examples convey your intended changes far=20
better than the wording.

Also, I'd suggest using https://timsong-cpp.github.io/cppwp/n4618/ rather=
=20
than tip-of-trunk, esp. as the project editor seems to be about to do some=
=20
editorial restructuring in this subclause.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/78e69be6-4dfd-4949-85d9-145097ea2580%40isocpp.or=
g.

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

<div dir=3D"ltr"><br><br>On Saturday, December 17, 2016 at 10:14:30 AM UTC-=
5, Vittorio Romeo wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr">Thank you very much for the feedback.<br><br>Here&#39;s a new dr=
aft:<br><a href=3D"https://vittorioromeo.info/Misc/lambda_issue_draft_2.htm=
l" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https=
://www.google.com/url?q\x3dhttps%3A%2F%2Fvittorioromeo.info%2FMisc%2Flambda=
_issue_draft_2.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpcFeCSj4HGd134=
d11PtVE-6jc8A&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.go=
ogle.com/url?q\x3dhttps%3A%2F%2Fvittorioromeo.info%2FMisc%2Flambda_issue_dr=
aft_2.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpcFeCSj4HGd134d11PtVE-6=
jc8A&#39;;return true;">https://vittorioromeo.info/<wbr>Misc/lambda_issue_d=
raft_2.html</a><div><br></div><div>I&#39;ve looked into most of the issues/=
inconsistencies you suggested, and I came to the conclusion that also simpl=
e-captures need to be &quot;visible&quot; in the lambda-declarator.<br>I&#3=
9;m not sure if the proposed wording is correct (and I&#39;m not sure how I=
 should address captures by reference, as they&#39;re not covered by=C2=A0<=
a href=3D"https://timsong-cpp.github.io/cppwp/expr.prim.lambda#17" style=3D=
"font-family:&quot;Times New Roman&quot;;font-size:medium" target=3D"_blank=
" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.google.com/u=
rl?q\x3dhttps%3A%2F%2Ftimsong-cpp.github.io%2Fcppwp%2Fexpr.prim.lambda%2317=
\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJUuB_fhKVVtSY5aQc6Fddmz3qXQ&#39;;=
return true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dh=
ttps%3A%2F%2Ftimsong-cpp.github.io%2Fcppwp%2Fexpr.prim.lambda%2317\x26sa\x3=
dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJUuB_fhKVVtSY5aQc6Fddmz3qXQ&#39;;return tr=
ue;">=C2=A75.1.5/17</a>).<br><br>Some questions/feedback requests:</div><di=
v>* Any idea for a title that clearly conveys the intent of making both sim=
ple-captures and init-captures usable in the lambda-declarator in order to =
achieve consistency with classes?<br>* Are the proposed changes to the stan=
dard reasonable? Would the addition of a new paragraph make it clearer that=
 all types of captures should be accessible in the lambda-declarator for co=
nsistency with classes?<br>* The last example posted by Arthur<br><span sty=
le=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0=
,0)">=C2=A0 =C2=A0=C2=A0</span><span style=3D"font-family:monospace;backgro=
und-color:rgb(250,250,250);color:rgb(0,0,136)">int</span><span style=3D"fon=
t-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=
=A0i</span><span style=3D"font-family:monospace;background-color:rgb(250,25=
0,250);color:rgb(102,102,0)">;</span><span style=3D"font-family:monospace;b=
ackground-color:rgb(250,250,250);color:rgb(0,0,0)"><br>=C2=A0 =C2=A0=C2=A0<=
/span><span style=3D"font-family:monospace;background-color:rgb(250,250,250=
);color:rgb(0,0,136)">auto</span><span style=3D"font-family:monospace;backg=
round-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0f=C2=A0</span><span st=
yle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(10=
2,102,0)">=3D</span><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:m=
onospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">[</span><s=
pan style=3D"font-family:monospace;background-color:rgb(250,250,250);color:=
rgb(0,0,0)">i</span><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(102,102,0)">=3D</span><span style=3D"font-family:=
monospace;background-color:rgb(250,250,250);color:rgb(0,102,102)">0L</span>=
<span style=3D"font-family:monospace;background-color:rgb(250,250,250);colo=
r:rgb(102,102,0)">](</span><span style=3D"font-family:monospace;background-=
color:rgb(250,250,250);color:rgb(0,0,136)">char</span><span style=3D"font-f=
amily:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0i=
</span><span style=3D"font-family:monospace;background-color:rgb(250,250,25=
0);color:rgb(102,102,0)">)</span><span style=3D"font-family:monospace;backg=
round-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"=
font-family:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0=
)">-&gt;</span><span style=3D"font-family:monospace;background-color:rgb(25=
0,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monosp=
ace;background-color:rgb(250,250,250);color:rgb(0,0,136)">d<wbr>ecltype</sp=
an><span style=3D"font-family:monospace;background-color:rgb(250,250,250);c=
olor:rgb(102,102,0)">(</span><span style=3D"font-family:monospace;backgroun=
d-color:rgb(250,250,250);color:rgb(0,0,0)">i</span><span style=3D"font-fami=
ly:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">)</spa=
n><span style=3D"font-family:monospace;background-color:rgb(250,250,250);co=
lor:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monospace;backgroun=
d-color:rgb(250,250,250);color:rgb(102,102,0)">{</span><span style=3D"font-=
family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0=
</span><span style=3D"font-family:monospace;background-color:rgb(250,250,25=
0);color:rgb(0,0,136)">return</span><span style=3D"font-family:monospace;ba=
ckground-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=
=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,102=
,102)">0</span><span style=3D"font-family:monospace;background-color:rgb(25=
0,250,250);color:rgb(102,102,0)">;</span><span style=3D"font-family:monospa=
ce;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span s=
tyle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(1=
02,102,0)">}</span><span style=3D"font-family:monospace;background-color:rg=
b(250,250,250);color:rgb(0,0,0)"><br>=C2=A0 =C2=A0=C2=A0</span><span style=
=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(136,0=
,0)">// decltype(f(0)) =3D=3D ???</span><br>is something that the paper sho=
uld address, after the change in scope. I am not sure where to start here t=
hough, as I&#39;m confident that multiple rules from different parts of the=
 standard come into play here. <br>Intuitively I think that the return type=
 should evaluate to `char` (as the parameter `i` is closer to the trailing =
return type). What do you think? =C2=A0<br><br><br></div></div></blockquote=
><div><br></div><div>More cases to address - interaction with default captu=
res and with references captured-by-copy:</div><br><div class=3D"prettyprin=
t" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 18=
7, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"><c=
ode class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> x </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: #066;" class=3D"styled-by-prettify">1</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><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">](</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">))</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </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">// this is (const int&amp;) currently=
.. (const int) under your rules?</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[=3D]{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">decltype</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">x</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> y </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">1</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: #660;" class=3D"styled-by-prettify">}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">// this is (const in=
t&amp;) currently again, ??? under your rules</span></div></code></div><div=
><br></div><div><br></div>The p17 change isn&#39;t on point: decltype=C2=A0=
isn&#39;t an odr-use (indeed I wonder if it&#39;s even possible to odr-use =
*anything* in a lambda-declarator). The note in the paragraph also needs ch=
anging.<div><br></div><div>In general, I&#39;d suggest laying out the vario=
us examples first and saving the wording until=C2=A0the end. The examples c=
onvey your intended changes far better than the wording.</div><div><br></di=
v><div>Also, I&#39;d suggest using https://timsong-cpp.github.io/cppwp/n461=
8/ rather than tip-of-trunk, esp. as the project editor seems to be about t=
o do some editorial restructuring in this subclause.<br><div><div><br></div=
></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/78e69be6-4dfd-4949-85d9-145097ea2580%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/78e69be6-4dfd-4949-85d9-145097ea2580=
%40isocpp.org</a>.<br />

------=_Part_1217_2041919753.1482178884754--

------=_Part_1216_1208111683.1482178884753--

.


Author: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Date: Mon, 19 Dec 2016 13:33:34 -0800 (PST)
Raw View
------=_Part_1208_504138886.1482183214527
Content-Type: multipart/alternative;
 boundary="----=_Part_1209_1248416349.1482183214528"

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

After carefully reading p17 again, I realized my mistake in the proposed=20
wording. I'm also starting to get disheartened, as it seems that the note=
=20
is very deliberate.

Every *id-expression=20
> <https://timsong-cpp.github.io/cppwp/expr.prim.id#nt:id-expression>* with=
in=20
> the *compound-statement=20
> <https://timsong-cpp.github.io/cppwp/stmt.block#nt:compound-statement>* o=
f=20
> a *lambda-expression=20
> <https://timsong-cpp.github.io/cppwp/expr.prim.lambda#nt:lambda-expressio=
n>* that=20
> is an odr-use ([basic.def.odr]=20
> <https://timsong-cpp.github.io/cppwp/basic.def.odr>) of an entity=20
> captured by copy is transformed into an access to the corresponding unnam=
ed=20
> data member of the closure type. [ *Note:* An *id-expression=20
> <https://timsong-cpp.github.io/cppwp/expr.prim.id#nt:id-expression>* that=
=20
> is not an odr-use refers to the original entity, never to a member of the=
=20
> closure type. Furthermore, such an *id-expression=20
> <https://timsong-cpp.github.io/cppwp/expr.prim.id#nt:id-expression>* does=
=20
> not cause the implicit capture of the entity. * =E2=80=94 end note* ]=20


I'm also getting confused, because I assumed that the snippet below was=20
correctly commented...

// (without the proposed wording)
int x =3D 0;auto l2_const =3D [x]()=20
    // `int&`, as it refers to the "outer" `x`
    -> decltype((x)) =20
{
    // `const int&`, as it refers to the captured `x`, which is=20
    // a member of the lambda (which has a `const`-qualified call
    // operator).
    static_assert(std::is_same<decltype((x)), const int&>{});
};
static_assert(std::is_same<decltype(l2_const()), int&>{});

=20
....but according to the note the decltype((x)) inside l2_const's=20
compound-statement should refer to the outer `x`, not to the captured `x`.
What's actually going on here?=20

The result of=20

static_assert(std::is_same<decltype((x)), const int&>{});

depends on whether or not the lambda is mutable, so it cannot possibly=20
refer to the outer `x`.=20
Is `x` not an "id-expression" here for some reason I am missing?


I said that I was getting disheartened because achieving consistency=20
between lambda and classes results in a lot of breaking changes. I would be=
=20
surprised if there isn't any code out there in the real world that uses=20
`decltype` of a simple-capture in either the lambda-declarator or the=20
lambda's compound-expression: making the behavior consistent with classes=
=20
would change the meaning of all that code.

Do you think it makes sense to keep going in this direction (i.e. total=20
consistency between lambdas with captures and classes)?
On the other hand, the alternative option is focusing on making=20
init-captures accessible in the lambda-declarator, which would practically=
=20
introduce a "special case" for init-captures. It would lead to even more=20
inconsistency because:
* Non-odr uses of simple-captures in the lambda-declarator would refer to=
=20
the "outer" object, not the capture itself.
* Non-odr uses of init-captures in the lambda-declarator would refer to the=
=20
capture itself.

Maybe what I really want is an alternative to the `this` keyword that=20
actually refers to the lambda itself...
[x](decltype(x)) {} // refers to outer x
[x](decltype(lambda->x)) {} // refers to captured x


On Monday, 19 December 2016 20:21:24 UTC, T. C. wrote:
>
>
>
> On Saturday, December 17, 2016 at 10:14:30 AM UTC-5, Vittorio Romeo wrote=
:
>>
>> Thank you very much for the feedback.
>>
>> Here's a new draft:
>> https://vittorioromeo.info/Misc/lambda_issue_draft_2.html
>>
>> I've looked into most of the issues/inconsistencies you suggested, and I=
=20
>> came to the conclusion that also simple-captures need to be "visible" in=
=20
>> the lambda-declarator.
>> I'm not sure if the proposed wording is correct (and I'm not sure how I=
=20
>> should address captures by reference, as they're not covered by =C2=A75.=
1.5/17=20
>> <https://timsong-cpp.github.io/cppwp/expr.prim.lambda#17>).
>>
>> Some questions/feedback requests:
>> * Any idea for a title that clearly conveys the intent of making both=20
>> simple-captures and init-captures usable in the lambda-declarator in ord=
er=20
>> to achieve consistency with classes?
>> * Are the proposed changes to the standard reasonable? Would the additio=
n=20
>> of a new paragraph make it clearer that all types of captures should be=
=20
>> accessible in the lambda-declarator for consistency with classes?
>> * The last example posted by Arthur
>>     int i;
>>     auto f =3D [i=3D0L](char i) -> decltype(i) { return 0; }
>>     // decltype(f(0)) =3D=3D ???
>> is something that the paper should address, after the change in scope. I=
=20
>> am not sure where to start here though, as I'm confident that multiple=
=20
>> rules from different parts of the standard come into play here.=20
>> Intuitively I think that the return type should evaluate to `char` (as=
=20
>> the parameter `i` is closer to the trailing return type). What do you=20
>> think? =20
>>
>>
>>
> More cases to address - interaction with default captures and with=20
> references captured-by-copy:
>
> const int& x =3D 1;
> [x](decltype(x)) {} // this is (const int&) currently. (const int) under=
=20
> your rules?
> [=3D]{ decltype(x) y =3D 1; } // this is (const int&) currently again, ??=
?=20
> under your rules
>
>
> The p17 change isn't on point: decltype isn't an odr-use (indeed I wonder=
=20
> if it's even possible to odr-use *anything* in a lambda-declarator). The=
=20
> note in the paragraph also needs changing.
>
> In general, I'd suggest laying out the various examples first and saving=
=20
> the wording until the end. The examples convey your intended changes far=
=20
> better than the wording.
>
> Also, I'd suggest using https://timsong-cpp.github.io/cppwp/n4618/ rather=
=20
> than tip-of-trunk, esp. as the project editor seems to be about to do som=
e=20
> editorial restructuring in this subclause.
>
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/cfe4e68c-9fc1-44fa-9b09-011b3bd15c2c%40isocpp.or=
g.

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

<div dir=3D"ltr">After carefully reading p17 again, I realized my mistake i=
n the proposed wording. I&#39;m also starting to get disheartened, as it se=
ems that the note is very deliberate.<br><br><blockquote class=3D"gmail_quo=
te" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204=
, 204); padding-left: 1ex;"><font size=3D"2"><span style=3D"color: rgb(0, 0=
, 0); font-family: &quot;Times New Roman&quot;; text-align: justify; backgr=
ound-color: rgb(201, 251, 201);">Every=C2=A0</span><i style=3D"color: rgb(0=
, 0, 0); font-family: &quot;Times New Roman&quot;; text-align: justify; bac=
kground-color: rgb(201, 251, 201);"><a href=3D"https://timsong-cpp.github.i=
o/cppwp/expr.prim.id#nt:id-expression">id-expression</a></i><span style=3D"=
color: rgb(0, 0, 0); font-family: &quot;Times New Roman&quot;; text-align: =
justify; background-color: rgb(201, 251, 201);">=C2=A0within the=C2=A0</spa=
n><i style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New Roman&quot;=
; text-align: justify; background-color: rgb(201, 251, 201);"><a href=3D"ht=
tps://timsong-cpp.github.io/cppwp/stmt.block#nt:compound-statement">compoun=
d-statement</a></i><span style=3D"color: rgb(0, 0, 0); font-family: &quot;T=
imes New Roman&quot;; text-align: justify; background-color: rgb(201, 251, =
201);">=C2=A0of a=C2=A0</span><i style=3D"color: rgb(0, 0, 0); font-family:=
 &quot;Times New Roman&quot;; text-align: justify; background-color: rgb(20=
1, 251, 201);"><a href=3D"https://timsong-cpp.github.io/cppwp/expr.prim.lam=
bda#nt:lambda-expression">lambda-expression</a></i><span style=3D"color: rg=
b(0, 0, 0); font-family: &quot;Times New Roman&quot;; text-align: justify; =
background-color: rgb(201, 251, 201);">=C2=A0that is an odr-use (</span><a =
href=3D"https://timsong-cpp.github.io/cppwp/basic.def.odr" style=3D"font-fa=
mily: &quot;Times New Roman&quot;; text-align: justify; background-color: r=
gb(201, 251, 201);">[basic.def.odr]</a><span style=3D"color: rgb(0, 0, 0); =
font-family: &quot;Times New Roman&quot;; text-align: justify; background-c=
olor: rgb(201, 251, 201);">) of an entity captured by copy is transformed i=
nto an access to the corresponding unnamed data member of the closure type.=
 [=C2=A0</span><i style=3D"color: rgb(0, 0, 0); font-family: &quot;Times Ne=
w Roman&quot;; text-align: justify; background-color: rgb(201, 251, 201);">=
Note:</i><span style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New R=
oman&quot;; text-align: justify; background-color: rgb(201, 251, 201);">=C2=
=A0An=C2=A0</span><i style=3D"color: rgb(0, 0, 0); font-family: &quot;Times=
 New Roman&quot;; text-align: justify; background-color: rgb(201, 251, 201)=
;"><a href=3D"https://timsong-cpp.github.io/cppwp/expr.prim.id#nt:id-expres=
sion">id-expression</a></i><span style=3D"color: rgb(0, 0, 0); font-family:=
 &quot;Times New Roman&quot;; text-align: justify; background-color: rgb(20=
1, 251, 201);">=C2=A0that is not an odr-use refers to the original entity, =
never to a member of the closure type. Furthermore, such an=C2=A0</span><i =
style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New Roman&quot;; tex=
t-align: justify; background-color: rgb(201, 251, 201);"><a href=3D"https:/=
/timsong-cpp.github.io/cppwp/expr.prim.id#nt:id-expression">id-expression</=
a></i><span style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New Roma=
n&quot;; text-align: justify; background-color: rgb(201, 251, 201);">=C2=A0=
does not cause the implicit capture of the entity.=C2=A0</span><i style=3D"=
color: rgb(0, 0, 0); font-family: &quot;Times New Roman&quot;; text-align: =
justify; background-color: rgb(201, 251, 201);">=C2=A0=E2=80=94=C2=A0end no=
te</i><span style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New Roma=
n&quot;; text-align: justify; background-color: rgb(201, 251, 201);">=C2=A0=
]=C2=A0</span></font></blockquote><div><br></div><div>I&#39;m also getting =
confused, because I assumed that the snippet below was correctly commented.=
...<br><br><div class=3D"sourceCode" style=3D"overflow-x: auto; color: rgb(6=
8, 68, 68); font-family: georgia, palatino, &quot;palatino linotype&quot;, =
times, &quot;times new roman&quot;, serif;"><pre class=3D"sourceCode cpp" s=
tyle=3D"color: rgb(0, 0, 0); font-family: monospace, monospace; white-space=
: pre-wrap; word-wrap: break-word; border-width: 1px; border-style: solid; =
border-color: rgb(68, 68, 68); padding: 12px; border-radius: 6px;"><code cl=
ass=3D"sourceCode cpp" style=3D"white-space: pre; font-family: monospace, m=
onospace;"><font size=3D"2"><span class=3D"co" style=3D"color: rgb(96, 160,=
 176); font-style: italic;">// (without the proposed wording)</span>

<span class=3D"dt" style=3D"color: rgb(144, 32, 0);">int</span> x =3D <span=
 class=3D"dv" style=3D"color: rgb(64, 160, 112);">0</span>;
<span class=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">aut=
o</span> l2_const =3D [x]()=20
    <span class=3D"co" style=3D"color: rgb(96, 160, 176); font-style: itali=
c;">// `int&amp;`, as it refers to the &quot;outer&quot; `x`</span>
    -&gt; <span class=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: =
bold;">decltype</span>((x)) =20
{
    <span class=3D"co" style=3D"color: rgb(96, 160, 176); font-style: itali=
c;">// `const int&amp;`, as it refers to the captured `x`, which is </span>
    <span class=3D"co" style=3D"color: rgb(96, 160, 176); font-style: itali=
c;">// a member of the lambda (which has a `const`-qualified call</span>
    <span class=3D"co" style=3D"color: rgb(96, 160, 176); font-style: itali=
c;">// operator).</span>
    <span class=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;"=
>static_assert</span>(<span class=3D"bu">std::</span>is_same&lt;<span class=
=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">decltype</span=
>((x)), <span class=3D"at" style=3D"color: rgb(125, 144, 41);">const</span>=
 <span class=3D"dt" style=3D"color: rgb(144, 32, 0);">int</span>&amp;&gt;{}=
);
};

<span class=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">sta=
tic_assert</span>(<span class=3D"bu">std::</span>is_same&lt;<span class=3D"=
kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">decltype</span>(l2=
_const()), <span class=3D"dt" style=3D"color: rgb(144, 32, 0);">int</span>&=
amp;&gt;{});</font></code></pre></div><div class=3D"sourceCode" style=3D"ov=
erflow-x: auto; color: rgb(68, 68, 68); font-family: georgia, palatino, &qu=
ot;palatino linotype&quot;, times, &quot;times new roman&quot;, serif; font=
-size: 16px;"></div>=C2=A0</div><div>...but according to the note the=C2=A0=
<span class=3D"kw" style=3D"font-size: small; font-family: monospace, monos=
pace; white-space: pre; color: rgb(0, 112, 32); font-weight: bold;">decltyp=
e</span><span style=3D"font-size: small; font-family: monospace, monospace;=
 white-space: pre; color: rgb(0, 0, 0);">((x))</span>=C2=A0inside l2_const&=
#39;s compound-statement should refer to the outer `x`, not to the captured=
 `x`.<br>What&#39;s actually going on here?=C2=A0<br><br>The result of=C2=
=A0</div><div><pre class=3D"sourceCode cpp" style=3D"padding: 12px; border-=
width: 1px; border-style: solid; border-color: rgb(68, 68, 68); color: rgb(=
0, 0, 0); font-family: monospace, monospace; white-space: pre-wrap; word-wr=
ap: break-word; border-radius: 6px;"><code class=3D"sourceCode cpp" style=
=3D"white-space: pre; font-family: monospace, monospace;"><font size=3D"2">=
<span class=3D"kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">sta=
tic_assert</span>(<span class=3D"bu">std::</span>is_same&lt;<span class=3D"=
kw" style=3D"color: rgb(0, 112, 32); font-weight: bold;">decltype</span>((x=
)), <span class=3D"at" style=3D"color: rgb(125, 144, 41);">const</span> <sp=
an class=3D"dt" style=3D"color: rgb(144, 32, 0);">int</span>&amp;&gt;{});</=
font></code></pre></div>depends on whether or not the lambda is mutable, so=
 it cannot possibly refer to the outer `x`.=C2=A0<br>Is `x` not an &quot;id=
-expression&quot; here for some reason I am missing?<div><br></div><div><br=
>I said that I was getting disheartened because achieving consistency betwe=
en lambda and classes results in a lot of breaking changes. I would be surp=
rised if there isn&#39;t any code out there in the real world that uses `de=
cltype` of a simple-capture in either the lambda-declarator or the lambda&#=
39;s compound-expression: making the behavior consistent with classes would=
 change the meaning of all that code.</div><div><br></div><div>Do you think=
 it makes sense to keep going in this direction (i.e. total consistency bet=
ween lambdas with captures and classes)?<br>On the other hand, the alternat=
ive option is focusing on making init-captures accessible in the lambda-dec=
larator, which would practically introduce a &quot;special case&quot; for i=
nit-captures. It would lead to even more inconsistency because:<br>* Non-od=
r uses of simple-captures in the lambda-declarator would refer to the &quot=
;outer&quot; object, not the capture itself.<br>* Non-odr uses of init-capt=
ures in the lambda-declarator would refer to the capture itself.<br><br></d=
iv><div>Maybe what I really want is an alternative to the `this` keyword th=
at actually refers to the lambda itself...<br><span style=3D"font-family: m=
onospace; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">[=
</span><span style=3D"font-family: monospace; background-color: rgb(250, 25=
0, 250); color: rgb(0, 0, 0);">x</span><span style=3D"font-family: monospac=
e; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">](</span=
><span style=3D"font-family: monospace; background-color: rgb(250, 250, 250=
); color: rgb(0, 0, 136);">decltype</span><span style=3D"font-family: monos=
pace; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">(</sp=
an><span style=3D"font-family: monospace; background-color: rgb(250, 250, 2=
50); color: rgb(0, 0, 0);">x</span><span style=3D"font-family: monospace; b=
ackground-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">))</span><sp=
an style=3D"font-family: monospace; background-color: rgb(250, 250, 250); c=
olor: rgb(0, 0, 0);">=C2=A0</span><span style=3D"font-family: monospace; ba=
ckground-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">{} // refers =
to outer x</span><br><div><span style=3D"font-family: monospace; background=
-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">[</span><span style=
=3D"font-family: monospace; background-color: rgb(250, 250, 250); color: rg=
b(0, 0, 0);">x</span><span style=3D"font-family: monospace; background-colo=
r: rgb(250, 250, 250); color: rgb(102, 102, 0);">](</span><span style=3D"fo=
nt-family: monospace; background-color: rgb(250, 250, 250); color: rgb(0, 0=
, 136);">decltype</span><span style=3D"font-family: monospace; background-c=
olor: rgb(250, 250, 250); color: rgb(102, 102, 0);">(lambda-&gt;</span><spa=
n style=3D"font-family: monospace; background-color: rgb(250, 250, 250); co=
lor: rgb(0, 0, 0);">x</span><span style=3D"font-family: monospace; backgrou=
nd-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">))</span><span styl=
e=3D"font-family: monospace; background-color: rgb(250, 250, 250); color: r=
gb(0, 0, 0);">=C2=A0</span><span style=3D"font-family: monospace; backgroun=
d-color: rgb(250, 250, 250); color: rgb(102, 102, 0);">{} // refers to capt=
ured x</span></div><div><font color=3D"#666600" face=3D"monospace"><br><br>=
</font>On Monday, 19 December 2016 20:21:24 UTC, T. C.  wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On Saturday, Decem=
ber 17, 2016 at 10:14:30 AM UTC-5, Vittorio Romeo wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">Thank you very much for the feedbac=
k.<br><br>Here&#39;s a new draft:<br><a href=3D"https://vittorioromeo.info/=
Misc/lambda_issue_draft_2.html" rel=3D"nofollow" target=3D"_blank" onmoused=
own=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fvitto=
rioromeo.info%2FMisc%2Flambda_issue_draft_2.html\x26sa\x3dD\x26sntz\x3d1\x2=
6usg\x3dAFQjCNEpcFeCSj4HGd134d11PtVE-6jc8A&#39;;return true;" onclick=3D"th=
is.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fvittorioromeo.=
info%2FMisc%2Flambda_issue_draft_2.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dA=
FQjCNEpcFeCSj4HGd134d11PtVE-6jc8A&#39;;return true;">https://vittorioromeo.=
info/<wbr>Misc/lambda_issue_draft_2.html</a><div><br></div><div>I&#39;ve lo=
oked into most of the issues/inconsistencies you suggested, and I came to t=
he conclusion that also simple-captures need to be &quot;visible&quot; in t=
he lambda-declarator.<br>I&#39;m not sure if the proposed wording is correc=
t (and I&#39;m not sure how I should address captures by reference, as they=
&#39;re not covered by=C2=A0<a href=3D"https://timsong-cpp.github.io/cppwp/=
expr.prim.lambda#17" style=3D"font-family:&quot;Times New Roman&quot;;font-=
size:medium" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D=
&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftimsong-cpp.github.io%2F=
cppwp%2Fexpr.prim.lambda%2317\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJUuB=
_fhKVVtSY5aQc6Fddmz3qXQ&#39;;return true;" onclick=3D"this.href=3D&#39;http=
s://www.google.com/url?q\x3dhttps%3A%2F%2Ftimsong-cpp.github.io%2Fcppwp%2Fe=
xpr.prim.lambda%2317\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJUuB_fhKVVtSY=
5aQc6Fddmz3qXQ&#39;;return true;">=C2=A75.1.5/17</a>).<br><br>Some question=
s/feedback requests:</div><div>* Any idea for a title that clearly conveys =
the intent of making both simple-captures and init-captures usable in the l=
ambda-declarator in order to achieve consistency with classes?<br>* Are the=
 proposed changes to the standard reasonable? Would the addition of a new p=
aragraph make it clearer that all types of captures should be accessible in=
 the lambda-declarator for consistency with classes?<br>* The last example =
posted by Arthur<br><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(0,0,0)">=C2=A0 =C2=A0=C2=A0</span><span style=3D"=
font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,136)"=
>int</span><span style=3D"font-family:monospace;background-color:rgb(250,25=
0,250);color:rgb(0,0,0)">=C2=A0i</span><span style=3D"font-family:monospace=
;background-color:rgb(250,250,250);color:rgb(102,102,0)">;</span><span styl=
e=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,=
0)"><br>=C2=A0 =C2=A0=C2=A0</span><span style=3D"font-family:monospace;back=
ground-color:rgb(250,250,250);color:rgb(0,0,136)">auto</span><span style=3D=
"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=
=C2=A0f=C2=A0</span><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(102,102,0)">=3D</span><span style=3D"font-family:=
monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span>=
<span style=3D"font-family:monospace;background-color:rgb(250,250,250);colo=
r:rgb(102,102,0)">[</span><span style=3D"font-family:monospace;background-c=
olor:rgb(250,250,250);color:rgb(0,0,0)">i</span><span style=3D"font-family:=
monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">=3D</span=
><span style=3D"font-family:monospace;background-color:rgb(250,250,250);col=
or:rgb(0,102,102)">0L</span><span style=3D"font-family:monospace;background=
-color:rgb(250,250,250);color:rgb(102,102,0)">](</span><span style=3D"font-=
family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,136)">char=
</span><span style=3D"font-family:monospace;background-color:rgb(250,250,25=
0);color:rgb(0,0,0)">=C2=A0i</span><span style=3D"font-family:monospace;bac=
kground-color:rgb(250,250,250);color:rgb(102,102,0)">)</span><span style=3D=
"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=
=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(250,=
250,250);color:rgb(102,102,0)">-&gt;</span><span style=3D"font-family:monos=
pace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span=
 style=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb=
(0,0,136)">d<wbr>ecltype</span><span style=3D"font-family:monospace;backgro=
und-color:rgb(250,250,250);color:rgb(102,102,0)">(</span><span style=3D"fon=
t-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">i</s=
pan><span style=3D"font-family:monospace;background-color:rgb(250,250,250);=
color:rgb(102,102,0)">)</span><span style=3D"font-family:monospace;backgrou=
nd-color:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"fon=
t-family:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">=
{</span><span style=3D"font-family:monospace;background-color:rgb(250,250,2=
50);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monospace;bac=
kground-color:rgb(250,250,250);color:rgb(0,0,136)">return</span><span style=
=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0=
)">=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(2=
50,250,250);color:rgb(0,102,102)">0</span><span style=3D"font-family:monosp=
ace;background-color:rgb(250,250,250);color:rgb(102,102,0)">;</span><span s=
tyle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0=
,0,0)">=C2=A0</span><span style=3D"font-family:monospace;background-color:r=
gb(250,250,250);color:rgb(102,102,0)">}</span><span style=3D"font-family:mo=
nospace;background-color:rgb(250,250,250);color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(2=
50,250,250);color:rgb(136,0,0)">// decltype(f(0)) =3D=3D ???</span><br>is s=
omething that the paper should address, after the change in scope. I am not=
 sure where to start here though, as I&#39;m confident that multiple rules =
from different parts of the standard come into play here. <br>Intuitively I=
 think that the return type should evaluate to `char` (as the parameter `i`=
 is closer to the trailing return type). What do you think? =C2=A0<br><br><=
br></div></div></blockquote><div><br></div><div>More cases to address - int=
eraction with default captures and with references captured-by-copy:</div><=
br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187=
,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><div>=
<span style=3D"color:#008">const</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">int</span><span style=3D"color:#660">&amp;</span>=
<span style=3D"color:#000"> x </span><span style=3D"color:#660">=3D</span><=
span style=3D"color:#000"> </span><span style=3D"color:#066">1</span><span =
style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">[</span><span style=3D"color:#000">x</span><span style=
=3D"color:#660">](</span><span style=3D"color:#008">decltype</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#000">x</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"colo=
r:#800">// this is (const int&amp;) currently. (const int) under your rules=
?</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">[=
=3D]{</span><span style=3D"color:#000"> </span><span style=3D"color:#008">d=
ecltype</span><span style=3D"color:#660">(</span><span style=3D"color:#000"=
>x</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> y <=
/span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#066">1</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#800">// this is (const in=
t&amp;) currently again, ??? under your rules</span></div></code></div><div=
><br></div><div><br></div>The p17 change isn&#39;t on point: decltype=C2=A0=
isn&#39;t an odr-use (indeed I wonder if it&#39;s even possible to odr-use =
*anything* in a lambda-declarator). The note in the paragraph also needs ch=
anging.<div><br></div><div>In general, I&#39;d suggest laying out the vario=
us examples first and saving the wording until=C2=A0the end. The examples c=
onvey your intended changes far better than the wording.</div><div><br></di=
v><div>Also, I&#39;d suggest using <a href=3D"https://timsong-cpp.github.io=
/cppwp/n4618/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftimsong-cpp.github.io=
%2Fcppwp%2Fn4618%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE37a1PyRQxyvFeT=
pKD7Fwh4WFu5Q&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.go=
ogle.com/url?q\x3dhttps%3A%2F%2Ftimsong-cpp.github.io%2Fcppwp%2Fn4618%2F\x2=
6sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE37a1PyRQxyvFeTpKD7Fwh4WFu5Q&#39;;ret=
urn true;">https://timsong-cpp.github.io/<wbr>cppwp/n4618/</a> rather than =
tip-of-trunk, esp. as the project editor seems to be about to do some edito=
rial restructuring in this subclause.<br><div><div><br></div></div></div></=
div></blockquote></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/cfe4e68c-9fc1-44fa-9b09-011b3bd15c2c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cfe4e68c-9fc1-44fa-9b09-011b3bd15c2c=
%40isocpp.org</a>.<br />

------=_Part_1209_1248416349.1482183214528--

------=_Part_1208_504138886.1482183214527--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 19 Dec 2016 13:44:40 -0800 (PST)
Raw View
------=_Part_57_645242221.1482183880253
Content-Type: multipart/alternative;
 boundary="----=_Part_58_1895501511.1482183880253"

------=_Part_58_1895501511.1482183880253
Content-Type: text/plain; charset=UTF-8

On Monday, December 19, 2016 at 4:33:34 PM UTC-5, Vittorio Romeo wrote:
>
> Maybe what I really want is an alternative to the `this` keyword that
> actually refers to the lambda itself...
> [x](decltype(x)) {} // refers to outer x
> [x](decltype(lambda->x)) {} // refers to captured x
>

Some might say that it is something lambdas kinda need: a way to refer to
the lambda from within itself. Solve that problem, and you'll probably
solve yours too.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1b7e965c-4c05-4e71-a280-d127c0c5dadd%40isocpp.org.

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

<div dir=3D"ltr">On Monday, December 19, 2016 at 4:33:34 PM UTC-5, Vittorio=
 Romeo wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div></div><div>Maybe what I really want is an alternative to the `this` ke=
yword that actually refers to the lambda itself...<br><span style=3D"font-f=
amily:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">[</=
span><span style=3D"font-family:monospace;background-color:rgb(250,250,250)=
;color:rgb(0,0,0)">x</span><span style=3D"font-family:monospace;background-=
color:rgb(250,250,250);color:rgb(102,102,0)">](</span><span style=3D"font-f=
amily:monospace;background-color:rgb(250,250,250);color:rgb(0,0,136)">declt=
ype</span><span style=3D"font-family:monospace;background-color:rgb(250,250=
,250);color:rgb(102,102,0)">(</span><span style=3D"font-family:monospace;ba=
ckground-color:rgb(250,250,250);color:rgb(0,0,0)">x</span><span style=3D"fo=
nt-family:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)"=
>))</span><span style=3D"font-family:monospace;background-color:rgb(250,250=
,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monospace;b=
ackground-color:rgb(250,250,250);color:rgb(102,102,0)">{} // refers to oute=
r x</span><br><div><span style=3D"font-family:monospace;background-color:rg=
b(250,250,250);color:rgb(102,102,0)">[</span><span style=3D"font-family:mon=
ospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">x</span><span st=
yle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(10=
2,102,0)">](</span><span style=3D"font-family:monospace;background-color:rg=
b(250,250,250);color:rgb(0,0,136)">decltype</span><span style=3D"font-famil=
y:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">(lambda=
-&gt;</span><span style=3D"font-family:monospace;background-color:rgb(250,2=
50,250);color:rgb(0,0,0)">x</span><span style=3D"font-family:monospace;back=
ground-color:rgb(250,250,250);color:rgb(102,102,0)">))</span><span style=3D=
"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">=
=C2=A0</span><span style=3D"font-family:monospace;background-color:rgb(250,=
250,250);color:rgb(102,102,0)">{} // refers to captured x</span></div></div=
></div></blockquote><div><br>Some might say that it is something lambdas ki=
nda need: a way to refer to the lambda from within itself. Solve that probl=
em, and you&#39;ll probably solve yours too.</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1b7e965c-4c05-4e71-a280-d127c0c5dadd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1b7e965c-4c05-4e71-a280-d127c0c5dadd=
%40isocpp.org</a>.<br />

------=_Part_58_1895501511.1482183880253--

------=_Part_57_645242221.1482183880253--

.


Author: "T. C." <rs2740@gmail.com>
Date: Mon, 19 Dec 2016 14:32:17 -0800 (PST)
Raw View
------=_Part_1273_1934345736.1482186737480
Content-Type: multipart/alternative;
 boundary="----=_Part_1274_1964153039.1482186737480"

------=_Part_1274_1964153039.1482186737480
Content-Type: text/plain; charset=UTF-8

On Monday, December 19, 2016 at 4:33:34 PM UTC-5, Vittorio Romeo wrote:
>
> ...but according to the note the decltype((x)) inside l2_const's
> compound-statement should refer to the outer `x`, not to the captured `x`.
> What's actually going on here?
>
>
p20 and its special treatment for decltype((x)).


> I said that I was getting disheartened because achieving consistency
> between lambda and classes results in a lot of breaking changes. I would be
> surprised if there isn't any code out there in the real world that uses
> `decltype` of a simple-capture in either the lambda-declarator or the
> lambda's compound-expression: making the behavior consistent with classes
> would change the meaning of all that code.
>
> Do you think it makes sense to keep going in this direction (i.e. total
> consistency between lambdas with captures and classes)?
> On the other hand, the alternative option is focusing on making
> init-captures accessible in the lambda-declarator, which would practically
> introduce a "special case" for init-captures. It would lead to even more
> inconsistency because:
> * Non-odr uses of simple-captures in the lambda-declarator would refer to
> the "outer" object, not the capture itself.
> * Non-odr uses of init-captures in the lambda-declarator would refer to
> the capture itself.
>
> Maybe what I really want is an alternative to the `this` keyword that
> actually refers to the lambda itself...
> [x](decltype(x)) {} // refers to outer x
> [x](decltype(lambda->x)) {} // refers to captured x
>

`this`  is only available after the cv-qualifier-seq (or its lambda
equivalent), but perhaps that's enough for this.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ec154f31-d0a7-4e4d-910b-87986be2d720%40isocpp.org.

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

<div dir=3D"ltr">On Monday, December 19, 2016 at 4:33:34 PM UTC-5, Vittorio=
 Romeo wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div>...but according to the note the=C2=A0<span style=3D"font-size:small;f=
ont-family:monospace,monospace;white-space:pre;color:rgb(0,112,32);font-wei=
ght:bold">decltype</span><span style=3D"font-size:small;font-family:monospa=
ce,monospace;white-space:pre;color:rgb(0,0,0)">((x))</span>=C2=A0inside l2_=
const&#39;s compound-statement should refer to the outer `x`, not to the ca=
ptured `x`.<br>What&#39;s actually going on here?=C2=A0<br><br></div></div>=
</blockquote><div><br></div><div>p20 and its special treatment for decltype=
((x)).</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr"><div><br>I said that I was getting disheartened because achie=
ving consistency between lambda and classes results in a lot of breaking ch=
anges. I would be surprised if there isn&#39;t any code out there in the re=
al world that uses `decltype` of a simple-capture in either the lambda-decl=
arator or the lambda&#39;s compound-expression: making the behavior consist=
ent with classes would change the meaning of all that code.</div><div><br><=
/div><div>Do you think it makes sense to keep going in this direction (i.e.=
 total consistency between lambdas with captures and classes)?<br>On the ot=
her hand, the alternative option is focusing on making init-captures access=
ible in the lambda-declarator, which would practically introduce a &quot;sp=
ecial case&quot; for init-captures. It would lead to even more inconsistenc=
y because:<br>* Non-odr uses of simple-captures in the lambda-declarator wo=
uld refer to the &quot;outer&quot; object, not the capture itself.<br>* Non=
-odr uses of init-captures in the lambda-declarator would refer to the capt=
ure itself.<br><br></div><div>Maybe what I really want is an alternative to=
 the `this` keyword that actually refers to the lambda itself...<br><span s=
tyle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(1=
02,102,0)">[</span><span style=3D"font-family:monospace;background-color:rg=
b(250,250,250);color:rgb(0,0,0)">x</span><span style=3D"font-family:monospa=
ce;background-color:rgb(250,250,250);color:rgb(102,102,0)">](</span><span s=
tyle=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(0=
,0,136)">decltype</span><span style=3D"font-family:monospace;background-col=
or:rgb(250,250,250);color:rgb(102,102,0)">(</span><span style=3D"font-famil=
y:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">x</span><sp=
an style=3D"font-family:monospace;background-color:rgb(250,250,250);color:r=
gb(102,102,0)">))</span><span style=3D"font-family:monospace;background-col=
or:rgb(250,250,250);color:rgb(0,0,0)">=C2=A0</span><span style=3D"font-fami=
ly:monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">{} // =
refers to outer x</span><br><div><span style=3D"font-family:monospace;backg=
round-color:rgb(250,250,250);color:rgb(102,102,0)">[</span><span style=3D"f=
ont-family:monospace;background-color:rgb(250,250,250);color:rgb(0,0,0)">x<=
/span><span style=3D"font-family:monospace;background-color:rgb(250,250,250=
);color:rgb(102,102,0)">](</span><span style=3D"font-family:monospace;backg=
round-color:rgb(250,250,250);color:rgb(0,0,136)">decltype</span><span style=
=3D"font-family:monospace;background-color:rgb(250,250,250);color:rgb(102,1=
02,0)">(lambda-&gt;</span><span style=3D"font-family:monospace;background-c=
olor:rgb(250,250,250);color:rgb(0,0,0)">x</span><span style=3D"font-family:=
monospace;background-color:rgb(250,250,250);color:rgb(102,102,0)">))</span>=
<span style=3D"font-family:monospace;background-color:rgb(250,250,250);colo=
r:rgb(0,0,0)">=C2=A0</span><span style=3D"font-family:monospace;background-=
color:rgb(250,250,250);color:rgb(102,102,0)">{} // refers to captured x</sp=
an></div></div></div></blockquote><div><br></div><div>`this` =C2=A0is only =
available after the cv-qualifier-seq=C2=A0(or its lambda equivalent), but p=
erhaps that&#39;s enough for this.</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ec154f31-d0a7-4e4d-910b-87986be2d720%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ec154f31-d0a7-4e4d-910b-87986be2d720=
%40isocpp.org</a>.<br />

------=_Part_1274_1964153039.1482186737480--

------=_Part_1273_1934345736.1482186737480--

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Tue, 20 Dec 2016 12:59:55 -0500
Raw View
--94eb2c09c51ece33fc05441acdc0
Content-Type: text/plain; charset=UTF-8

On Mon, Dec 19, 2016 at 4:33 PM, Vittorio Romeo <
vittorio.romeo.vee@gmail.com> wrote:

> Maybe what I really want is an alternative to the `this` keyword that
> actually refers to the lambda itself...
>

This has come up before and I agree that it would be useful. There was a
proposal by Yegor Derevenets to add Y Combinator to the standard library (
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html ) and
one of the reasons that it was not voted in was because having a way in the
core language to name a lambda would solve the problem put forth in the
motivation. Richard Smith had recommended such a solution in the thread
where the author introduced the draft:
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/7p7J1C5jFzk
.. I don't know if Richard is still considering writing such a proposal, but
that he too considers this as a reasonable facility is a pretty good sign.
If you plan to write a paper on this, I'd probably make sure he is not
already doing so. He also might have some advice regarding the details
since he seems to have already given it some thought.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEkEH8%3DnRNno2SYsnDquvYH4zkEVcZCYGWf4CDYu1E8JNg%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Dec 19, 2016 at 4:33 PM, Vittorio Romeo <span dir=3D"ltr">&lt;<a href=
=3D"mailto:vittorio.romeo.vee@gmail.com" target=3D"_blank">vittorio.romeo.v=
ee@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex"><div dir=3D"ltr"><div>Maybe what I really want is an alternati=
ve to the `this` keyword that actually refers to the lambda itself...<br></=
div></div></blockquote><div><br></div><div>This has come up before and I ag=
ree that it would be useful. There was a proposal by Yegor Derevenets to ad=
d Y Combinator to the standard library (=C2=A0<a href=3D"http://www.open-st=
d.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html">http://www.open-std.org=
/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html</a> ) and one of the reasons =
that it was not voted in was because having a way in the core language to n=
ame a lambda would solve the problem put forth in the motivation. Richard S=
mith had recommended such a solution in the thread where the author introdu=
ced the draft:=C2=A0<a href=3D"https://groups.google.com/a/isocpp.org/forum=
/#!topic/std-proposals/7p7J1C5jFzk">https://groups.google.com/a/isocpp.org/=
forum/#!topic/std-proposals/7p7J1C5jFzk</a> . I don&#39;t know if Richard i=
s still considering writing such a proposal, but that he too considers this=
 as a reasonable facility is a pretty good sign. If you plan to write a pap=
er on this, I&#39;d probably make sure he is not already doing so. He also =
might have some advice regarding the details since he seems to have already=
 given it some thought.</div></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CANh8DEkEH8%3DnRNno2SYsnDquvYH4zkEVcZ=
CYGWf4CDYu1E8JNg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEkEH8%3Dn=
RNno2SYsnDquvYH4zkEVcZCYGWf4CDYu1E8JNg%40mail.gmail.com</a>.<br />

--94eb2c09c51ece33fc05441acdc0--

.