Topic: convert lambda to member function pointer
Author: Nick <nicolas.jinchereau@gmail.com>
Date: Mon, 17 Feb 2014 21:08:05 -0800 (PST)
Raw View
------=_Part_1442_9680833.1392700085260
Content-Type: text/plain; charset=UTF-8
If a lambda expression with an empty capture list can be converted to a
regular function pointer, could a lambda expression which only captures [
this] be converted to a member function pointer for the enclosing class,
such that the following code would be legal?
struct foo {
int i;
void bar() {
void(foo::*pfn)() = [this](){ cout << i << endl; };
}
};
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1442_9680833.1392700085260
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>If a lambda expression with an empty capture list can=
be converted to a regular function pointer, could a lambda expression whic=
h only captures [<font color=3D"#0000ff">this</font>] be converted to a mem=
ber function pointer for the enclosing class, such that the following code =
would be legal?</div><div><br></div><div class=3D"prettyprint" style=3D"bac=
kground-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); wo=
rd-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=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"><br><br> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> bar</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">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">foo</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>pfn</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)()</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">this</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">](){</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> i </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> endl</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: #660;" class=3D"styled-by-prettify">};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span></div></code></div><br><d=
iv><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1442_9680833.1392700085260--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 18 Feb 2014 13:14:04 +0800
Raw View
--Apple-Mail=_83D38B7C-F223-438C-A50A-F523F43011EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On Feb 18, 2014, at 1:08 PM, Nick <nicolas.jinchereau@gmail.com> wrote:
> If a lambda expression with an empty capture list can be converted to a r=
egular function pointer, could a lambda expression which only captures [thi=
s] be converted to a member function pointer for the enclosing class, such =
that the following code would be legal?
No; a PTMF does not store the value of this, which you need.
Since the binding of this is intrinsic to the construction of a lambda, you=
can't factor out the storage of this to get a PTMF interface plus a separa=
te object pointer, either.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_83D38B7C-F223-438C-A50A-F523F43011EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 1=
8, 2014, at 1:08 PM, Nick <<a href=3D"mailto:nicolas.jinchereau@gmail.co=
m">nicolas.jinchereau@gmail.com</a>> wrote:</div><br class=3D"Apple-inte=
rchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div>If a lambd=
a expression with an empty capture list can be converted to a regular funct=
ion pointer, could a lambda expression which only captures [<font color=3D"=
#0000ff">this</font>] be converted to a member function pointer for the enc=
losing class, such that the following code would be legal?</div></div></blo=
ckquote><div><br></div><div>No; a PTMF does not store the value of this, wh=
ich you need.</div><div><br></div><div>Since the binding of <font face=3D"C=
ourier">this</font> is intrinsic to the construction of a lambda, you can&r=
squo;t factor out the storage of <font face=3D"Courier">this</font> to get =
a PTMF interface plus a separate object pointer, either.</div><div><br></di=
v></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_83D38B7C-F223-438C-A50A-F523F43011EA--
.
Author: Brent Friedman <fourthgeek@gmail.com>
Date: Mon, 17 Feb 2014 23:28:26 -0600
Raw View
--047d7b343236a4535804f2a78a4a
Content-Type: text/plain; charset=ISO-8859-1
That won't do you any good. Member function pointers don't remember the
object that they are to be called on. You are capturing the exact object
instance that you want the function called on (this), but member function
pointers do no such thing. In your example, you might do (this->*pfn)() or
(that->*pfn)().
I think what you would want is [](foo* f){...} to be convertible to a
member function pointer.
And if you can do that, then you should also be able to convert free
functions to a member function pointer as well. void (foo*) to
void(foo::*)()
And convert void (foo*, int) into a void(foo::*)(int)
On Mon, Feb 17, 2014 at 11:08 PM, Nick <nicolas.jinchereau@gmail.com> wrote:
> If a lambda expression with an empty capture list can be converted to a
> regular function pointer, could a lambda expression which only captures [
> this] be converted to a member function pointer for the enclosing class,
> such that the following code would be legal?
>
> struct foo {
> int i;
>
> void bar() {
> void(foo::*pfn)() = [this](){ cout << i << endl; };
> }
> };
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b343236a4535804f2a78a4a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That won't do you any good. Member function pointers d=
on't remember the object that they are to be called on. You are capturi=
ng the exact object instance that you want the function called on (this), b=
ut member function pointers do no such thing. In your example, you might do=
(this->*pfn)() or (that->*pfn)().<div>
<br></div><div>I think what you would want is [](foo* f){...} to be convert=
ible to a member function pointer.</div><div><br></div><div>And if you can =
do that, then you should also be able to convert free functions to a member=
function pointer as well. void (foo*) to void(foo::*)()</div>
<div><br></div><div>And convert void (foo*, int) into a void(foo::*)(int)</=
div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On =
Mon, Feb 17, 2014 at 11:08 PM, Nick <span dir=3D"ltr"><<a href=3D"mailto=
:nicolas.jinchereau@gmail.com" target=3D"_blank">nicolas.jinchereau@gmail.c=
om</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>If a lambda expression=
with an empty capture list can be converted to a regular function pointer,=
could a lambda expression which only captures [<font color=3D"#0000ff">thi=
s</font>] be converted to a member function pointer for the enclosing class=
, such that the following code would be legal?</div>
<div><br></div><div style=3D"background-color:rgb(250,250,250);border:1px s=
olid rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"color=
:#008">struct</span><span style> foo </span><span style=3D"color:#660">{</s=
pan><span style><br>
=A0 =A0 </span><span style=3D"color:#008">int</span><span style> i</span><s=
pan style=3D"color:#660">;</span><span style><br><br>=A0 =A0 </span><span s=
tyle=3D"color:#008">void</span><span style> bar</span><span style=3D"color:=
#660">()</span><span style> </span><span style=3D"color:#660">{</span><span=
style><br>
=A0 =A0 =A0 =A0 </span><span style=3D"color:#008">void</span><span style=3D=
"color:#660">(</span><span style>foo</span><span style=3D"color:#660">::*</=
span><span style>pfn</span><span style=3D"color:#660">)()</span><span style=
> </span><span style=3D"color:#660">=3D</span><span style> </span><span sty=
le=3D"color:#660">[</span><span style=3D"color:#008">this</span><span style=
=3D"color:#660">](){</span><span style> cout </span><span style=3D"color:#6=
60"><<</span><span style> i </span><span style=3D"color:#660"><<=
;</span><span style> endl</span><span style=3D"color:#660">;</span><span st=
yle> </span><span style=3D"color:#660">};</span><span style><br>
=A0 =A0 </span><span style=3D"color:#660">}</span><span style><br></span><s=
pan style=3D"color:#660">};</span></div></code></div><span class=3D"HOEnZb"=
><font color=3D"#888888"><br><div><br></div></font></span></div><span class=
=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b343236a4535804f2a78a4a--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Mon, 17 Feb 2014 21:31:29 -0800
Raw View
--f46d04479f93ec088504f2a7974b
Content-Type: text/plain; charset=UTF-8
Can't you already do that with mem_fn or bind?
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
On Mon, Feb 17, 2014 at 9:28 PM, Brent Friedman <fourthgeek@gmail.com>wrote:
> That won't do you any good. Member function pointers don't remember the
> object that they are to be called on. You are capturing the exact object
> instance that you want the function called on (this), but member function
> pointers do no such thing. In your example, you might do (this->*pfn)() or
> (that->*pfn)().
>
> I think what you would want is [](foo* f){...} to be convertible to a
> member function pointer.
>
> And if you can do that, then you should also be able to convert free
> functions to a member function pointer as well. void (foo*) to
> void(foo::*)()
>
> And convert void (foo*, int) into a void(foo::*)(int)
>
>
> On Mon, Feb 17, 2014 at 11:08 PM, Nick <nicolas.jinchereau@gmail.com>wrote:
>
>> If a lambda expression with an empty capture list can be converted to a
>> regular function pointer, could a lambda expression which only captures [
>> this] be converted to a member function pointer for the enclosing class,
>> such that the following code would be legal?
>>
>> struct foo {
>> int i;
>>
>> void bar() {
>> void(foo::*pfn)() = [this](){ cout << i << endl; };
>> }
>> };
>>
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--f46d04479f93ec088504f2a7974b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Can't you already do that with mem_fn or bind?</div><d=
iv class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><div>Billy=
O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/" target=
=3D"_blank">https://github.com/BillyONeal/</a></div>
<div><a href=3D"http://stackoverflow.com/users/82320/billy-oneal" target=3D=
"_blank">http://stackoverflow.com/users/82320/billy-oneal</a></div></div></=
div>
<br><br><div class=3D"gmail_quote">On Mon, Feb 17, 2014 at 9:28 PM, Brent F=
riedman <span dir=3D"ltr"><<a href=3D"mailto:fourthgeek@gmail.com" targe=
t=3D"_blank">fourthgeek@gmail.com</a>></span> wrote:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex">
<div dir=3D"ltr">That won't do you any good. Member function pointers d=
on't remember the object that they are to be called on. You are capturi=
ng the exact object instance that you want the function called on (this), b=
ut member function pointers do no such thing. In your example, you might do=
(this->*pfn)() or (that->*pfn)().<div>
<br></div><div>I think what you would want is [](foo* f){...} to be convert=
ible to a member function pointer.</div><div><br></div><div>And if you can =
do that, then you should also be able to convert free functions to a member=
function pointer as well. void (foo*) to void(foo::*)()</div>
<div><br></div><div>And convert void (foo*, int) into a void(foo::*)(int)</=
div></div><div class=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_extra=
"><br><br><div class=3D"gmail_quote">On Mon, Feb 17, 2014 at 11:08 PM, Nick=
<span dir=3D"ltr"><<a href=3D"mailto:nicolas.jinchereau@gmail.com" targ=
et=3D"_blank">nicolas.jinchereau@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>If a lambda expression=
with an empty capture list can be converted to a regular function pointer,=
could a lambda expression which only captures [<font color=3D"#0000ff">thi=
s</font>] be converted to a member function pointer for the enclosing class=
, such that the following code would be legal?</div>
<div><br></div><div style=3D"background-color:rgb(250,250,250);border:1px s=
olid rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"color=
:#008">struct</span><span> foo </span><span style=3D"color:#660">{</span><s=
pan><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#008">int</span><span> i</span><s=
pan style=3D"color:#660">;</span><span><br><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color:#008">void</span><span> bar</span><span style=3D"color:#660">=
()</span><span> </span><span style=3D"color:#660">{</span><span><br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">void</span><s=
pan style=3D"color:#660">(</span><span>foo</span><span style=3D"color:#660"=
>::*</span><span>pfn</span><span style=3D"color:#660">)()</span><span> </sp=
an><span style=3D"color:#660">=3D</span><span> </span><span style=3D"color:=
#660">[</span><span style=3D"color:#008">this</span><span style=3D"color:#6=
60">](){</span><span> cout </span><span style=3D"color:#660"><<</span=
><span> i </span><span style=3D"color:#660"><<</span><span> endl</spa=
n><span style=3D"color:#660">;</span><span> </span><span style=3D"color:#66=
0">};</span><span><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><span><br></span><s=
pan style=3D"color:#660">};</span></div></code></div><span><font color=3D"#=
888888"><br><div><br></div></font></span></div><span><font color=3D"#888888=
">
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--f46d04479f93ec088504f2a7974b--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 18 Feb 2014 13:48:06 +0800
Raw View
--Apple-Mail=_16B19842-E4DB-458D-86CD-02CBC1EC710E
Content-Type: text/plain; charset=ISO-8859-1
On Feb 18, 2014, at 1:31 PM, Billy O'Neal <billy.oneal@gmail.com> wrote:
> Can't you already do that with mem_fn or bind?
They go the other way, from PTMF to non-PTMF. But PTMFs are allowed to accept the this argument with different ABI than other functions, and have a special lazy virtual binding semantic, so you can't really just hack regular functions to fit.
In general you should only use a PTMF if you're sure that's what you want in the first place. Solution to OP here is probably that he should scrub them from his interfaces in favor of unary std::function.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--Apple-Mail=_16B19842-E4DB-458D-86CD-02CBC1EC710E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 1=
8, 2014, at 1:31 PM, Billy O'Neal <<a href=3D"mailto:billy.oneal@gmail.c=
om">billy.oneal@gmail.com</a>> wrote:</div><br class=3D"Apple-interchang=
e-newline"><blockquote type=3D"cite"><div dir=3D"ltr">Can't you already do =
that with mem_fn or bind?</div></blockquote><div><br></div><div>They go the=
other way, from PTMF to non-PTMF. But PTMFs are allowed to accept the this=
argument with different ABI than other functions, and have a special lazy =
virtual binding semantic, so you can’t really just hack regular funct=
ions to fit.</div></div><br><div>In general you should only use a PTMF if y=
ou’re sure that’s what you want in the first place. Solution to=
OP here is probably that he should scrub them from his interfaces in favor=
of unary <font face=3D"Courier">std::function</font>.</div><div><br></div>=
</body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_16B19842-E4DB-458D-86CD-02CBC1EC710E--
.
Author: "=?utf-8?B?YmlsbHkub25lYWxAZ21haWwuY29t?=" <billy.oneal@gmail.com>
Date: Mon, 17 Feb 2014 22:01:19 -0800
Raw View
------=_Part_0_1392703279686
Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
Oh, derp :)
Sent from a touchscreen. Please excuse the brevity and tpyos.
----- Reply message -----
From: "David Krauss" <potswa@gmail.com>
To: <std-proposals@isocpp.org>
Subject: [std-proposals] convert lambda to member function pointer
Date: Mon, Feb 17, 2014 9:48 PM
On Feb 18, 2014, at 1:31 PM, Billy O'Neal <billy.oneal@gmail.com> wrote:
Can't you already do that with mem_fn or bind?
They go the other way, from PTMF to non-PTMF. But PTMFs are allowed to accept the this argument with different ABI than other functions, and have a special lazy virtual binding semantic, so you can’t really just hack regular functions to fit.
In general you should only use a PTMF if you’re sure that’s what you want in the first place. Solution to OP here is probably that he should scrub them from his interfaces in favor of unary std::function.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_0_1392703279686
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><div style=3D"font-siz=
e: 12pt; font-family: Calibri,sans-serif;"><div>Oh, derp :)</div><div><br><=
/div><div>Sent from a touchscreen. Please excuse the brevity and tpyos.</di=
v><br><div id=3D"htc_header">----- Reply message -----<br>From: "David=
Krauss" <potswa@gmail.com><br>To: <std-proposals@isocpp.org&=
gt;<br>Subject: [std-proposals] convert lambda to member function pointer<b=
r>Date: Mon, Feb 17, 2014 9:48 PM</div></div><br><br><div><div>On Feb 18, 2=
014, at 1:31 PM, Billy O'Neal <<a href=3D"mailto:billy.oneal@gmail.com">=
billy.oneal@gmail.com</a>> wrote:</div><br class=3D"Apple-interchange-ne=
wline"><blockquote type=3D"cite"><div dir=3D"ltr">Can't you already do that=
with mem_fn or bind?</div></blockquote><div><br></div><div>They go the oth=
er way, from PTMF to non-PTMF. But PTMFs are allowed to accept the this arg=
ument with different ABI than other functions, and have a special lazy virt=
ual binding semantic, so you can’t really just hack regular functions=
to fit.</div></div><br><div>In general you should only use a PTMF if you&r=
squo;re sure that’s what you want in the first place. Solution to OP =
here is probably that he should scrub them from his interfaces in favor of =
unary <font face=3D"Courier">std::function</font>.</div><div><br></div></bo=
dy></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_0_1392703279686--
.
Author: Nick <nicolas.jinchereau@gmail.com>
Date: Tue, 18 Feb 2014 07:30:26 -0800 (PST)
Raw View
------=_Part_11_690124.1392737426033
Content-Type: text/plain; charset=UTF-8
Thanks for the responses. After a second look, I seem to have been mistaken
in thinking that the following code was a special case:
void(*fn)() = [](){ cout << "hello world" << endl; };
I thought that the construction of the lambda/function object would have
been elided in this case, but after reviewing the disassembly, it seems
that the above is done by calling a conversion operator.
Under the above premise, I assumed that only capturing [this] would ensure
that the code inside the lambda would also be legal as a member function,
and could be special cased.
I didn't intend for [this] to actually be captured, but only for it to tell
the compiler that the code inside the lambda should be legal as a member
function.
On Tuesday, 18 February 2014 00:08:05 UTC-5, Nick wrote:
>
> If a lambda expression with an empty capture list can be converted to a
> regular function pointer, could a lambda expression which only captures [
> this] be converted to a member function pointer for the enclosing class,
> such that the following code would be legal?
>
> struct foo {
> int i;
>
> void bar() {
> void(foo::*pfn)() = [this](){ cout << i << endl; };
> }
> };
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_11_690124.1392737426033
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Thanks for the responses. After a second look, I seem=
to have been mistaken in thinking that the following code was a special ca=
se:</div><div><br></div><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"><f=
ont color=3D"#000088"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">void</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">fn</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: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">[](){</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><<</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify">"hello world"</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"> e=
ndl</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></font><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></=
div><br>I thought that the construction of the lambda/function object would=
have been elided in this case, but after reviewing the disassembly, it see=
ms that the above is done by calling a conversion operator.</div><div><br><=
/div><div>Under the above premise, I assumed that only capturing [this] wou=
ld ensure that the code inside the lambda would also be legal as a member f=
unction, and could be special cased.</div><div><br></div><div>I didn't inte=
nd for [this] to actually be captured, but only for it to tell the compiler=
that the code inside the lambda should be legal as a member function.</div=
><div><br></div><div><br></div><div><br>On Tuesday, 18 February 2014 00:08:=
05 UTC-5, Nick 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"><div>If a lambda expression with an empty capture list can be conv=
erted to a regular function pointer, could a lambda expression which only c=
aptures [<font color=3D"#0000ff">this</font>] be converted to a member func=
tion pointer for the enclosing class, such that the following code would be=
legal?</div><div><br></div><div style=3D"background-color:rgb(250,250,250)=
;border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><span s=
tyle=3D"color:#008">struct</span><span style=3D"color:#000"> foo </span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"><br>  =
; </span><span style=3D"color:#008">int</span><span style=3D"color:#000"> i=
</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><b=
r> </span><span style=3D"color:#008">void</span><span style=3D=
"color:#000"> bar</span><span style=3D"color:#660">()</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br> </span><span style=3D"color:#008">vo=
id</span><span style=3D"color:#660">(</span><span style=3D"color:#000">foo<=
/span><span style=3D"color:#660">::*</span><span style=3D"color:#000">pfn</=
span><span style=3D"color:#660">)()</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">[</span><span style=3D"color:#008">this</span><sp=
an style=3D"color:#660">](){</span><span style=3D"color:#000"> cout </span>=
<span style=3D"color:#660"><<</span><span style=3D"color:#000"> i </s=
pan><span style=3D"color:#660"><<</span><span style=3D"color:#000"> e=
ndl</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br>&nb=
sp; </span><span style=3D"color:#660">}</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">};</span></div></code></div><br>=
<div><br></div></div></blockquote></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_11_690124.1392737426033--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Tue, 18 Feb 2014 07:53:31 -0800
Raw View
--001a11c30ce28a13f204f2b048d6
Content-Type: text/plain; charset=UTF-8
void(*fn) {} is not a pointer to member declaration, so you wouldn't want
the compiler to make it a member function anyway.
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
On Tue, Feb 18, 2014 at 7:30 AM, Nick <nicolas.jinchereau@gmail.com> wrote:
> Thanks for the responses. After a second look, I seem to have been
> mistaken in thinking that the following code was a special case:
>
> void(*fn)() = [](){ cout << "hello world" << endl; };
>
> I thought that the construction of the lambda/function object would have
> been elided in this case, but after reviewing the disassembly, it seems
> that the above is done by calling a conversion operator.
>
> Under the above premise, I assumed that only capturing [this] would ensure
> that the code inside the lambda would also be legal as a member function,
> and could be special cased.
>
> I didn't intend for [this] to actually be captured, but only for it to
> tell the compiler that the code inside the lambda should be legal as a
> member function.
>
>
>
> On Tuesday, 18 February 2014 00:08:05 UTC-5, Nick wrote:
>>
>> If a lambda expression with an empty capture list can be converted to a
>> regular function pointer, could a lambda expression which only captures [
>> this] be converted to a member function pointer for the enclosing class,
>> such that the following code would be legal?
>>
>> struct foo {
>> int i;
>>
>> void bar() {
>> void(foo::*pfn)() = [this](){ cout << i << endl; };
>> }
>> };
>>
>>
>> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a11c30ce28a13f204f2b048d6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>void(*fn) {} is not a pointer to member declaration, =
so you wouldn't want the compiler to make it a member function anyway.<=
/div></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"lt=
r"><div>
Billy O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/" ta=
rget=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=3D"htt=
p://stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">http://sta=
ckoverflow.com/users/82320/billy-oneal</a></div>
</div></div>
<br><br><div class=3D"gmail_quote">On Tue, Feb 18, 2014 at 7:30 AM, Nick <s=
pan dir=3D"ltr"><<a href=3D"mailto:nicolas.jinchereau@gmail.com" target=
=3D"_blank">nicolas.jinchereau@gmail.com</a>></span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex">
<div dir=3D"ltr"><div>Thanks for the responses. After a second look, I seem=
to have been mistaken in thinking that the following code was a special ca=
se:</div><div><br></div><div><div style=3D"border:1px solid rgb(187,187,187=
);background-color:rgb(250,250,250)">
<code><div><font color=3D"#000088"><span style=3D"color:rgb(0,0,136)">void<=
/span><span style=3D"color:rgb(102,102,0)">(*</span><span>fn</span><span st=
yle=3D"color:rgb(102,102,0)">)()</span><span> </span><span style=3D"color:r=
gb(102,102,0)">=3D</span><span> </span><span style=3D"color:rgb(102,102,0)"=
>[](){</span><span> cout </span><span style=3D"color:rgb(102,102,0)"><&l=
t;</span><span> </span><span style=3D"color:rgb(0,136,0)">"hello world=
"</span><span> </span><span style=3D"color:rgb(102,102,0)"><<</s=
pan><span> endl</span><span style=3D"color:rgb(102,102,0)">;</span><span> <=
/span><span style=3D"color:rgb(102,102,0)">};</span></font><span><br>
</span></div></code></div><br>I thought that the construction of the lambda=
/function object would have been elided in this case, but after reviewing t=
he disassembly, it seems that the above is done by calling a conversion ope=
rator.</div>
<div><br></div><div>Under the above premise, I assumed that only capturing =
[this] would ensure that the code inside the lambda would also be legal as =
a member function, and could be special cased.</div><div><br></div><div>
I didn't intend for [this] to actually be captured, but only for it to =
tell the compiler that the code inside the lambda should be legal as a memb=
er function.</div><div><div class=3D"h5"><div><br></div><div><br></div><div=
>
<br>On Tuesday, 18 February 2014 00:08:05 UTC-5, Nick wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;bord=
er-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:soli=
d">
<div dir=3D"ltr"><div>If a lambda expression with an empty capture list can=
be converted to a regular function pointer, could a lambda expression whic=
h only captures [<font color=3D"#0000ff">this</font>] be converted to a mem=
ber function pointer for the enclosing class, such that the following code =
would be legal?</div>
<div><br></div><div style=3D"border:1px solid rgb(187,187,187);background-c=
olor:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">struct=
</span><span> foo </span><span style=3D"color:rgb(102,102,0)">{</span><span=
><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">int</span><span> i<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:rgb(0,0,136)">void</span><span> bar</span><=
span style=3D"color:rgb(102,102,0)">()</span><span> </span><span style=3D"c=
olor:rgb(102,102,0)">{</span><span><br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">void<=
/span><span style=3D"color:rgb(102,102,0)">(</span><span>foo</span><span st=
yle=3D"color:rgb(102,102,0)">::*</span><span>pfn</span><span style=3D"color=
:rgb(102,102,0)">)()</span><span> </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span> </span><span style=3D"color:rgb(102,102,0)">[</span><sp=
an style=3D"color:rgb(0,0,136)">this</span><span style=3D"color:rgb(102,102=
,0)">](){</span><span> cout </span><span style=3D"color:rgb(102,102,0)"><=
;<</span><span> i </span><span style=3D"color:rgb(102,102,0)"><<</=
span><span> endl</span><span style=3D"color:rgb(102,102,0)">;</span><span> =
</span><span style=3D"color:rgb(102,102,0)">};</span><span><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br=
></span><span style=3D"color:rgb(102,102,0)">};</span></div></code></div><b=
r><div><br></div></div></blockquote></div></div></div></div><div class=3D"H=
OEnZb"><div class=3D"h5">
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c30ce28a13f204f2b048d6--
.
Author: Nick <nicolas.jinchereau@gmail.com>
Date: Tue, 18 Feb 2014 09:50:26 -0800 (PST)
Raw View
------=_Part_1661_14332902.1392745826518
Content-Type: text/plain; charset=UTF-8
That's not what I meant. Basically, what I am suggesting would be
implemented by adding a conversion operator returning a ptmf when the
capture list contains only [this].
typedef (T::*ptmf_t)() ;
lambda::operator ptmf_t();
On Tuesday, 18 February 2014 10:53:31 UTC-5, Billy O'Neal wrote:
>
> void(*fn) {} is not a pointer to member declaration, so you wouldn't want
> the compiler to make it a member function anyway.
>
> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
>
>
> On Tue, Feb 18, 2014 at 7:30 AM, Nick <nicolas.j...@gmail.com<javascript:>
> > wrote:
>
>> Thanks for the responses. After a second look, I seem to have been
>> mistaken in thinking that the following code was a special case:
>>
>> void(*fn)() = [](){ cout << "hello world" << endl; };
>>
>> I thought that the construction of the lambda/function object would have
>> been elided in this case, but after reviewing the disassembly, it seems
>> that the above is done by calling a conversion operator.
>>
>> Under the above premise, I assumed that only capturing [this] would
>> ensure that the code inside the lambda would also be legal as a member
>> function, and could be special cased.
>>
>> I didn't intend for [this] to actually be captured, but only for it to
>> tell the compiler that the code inside the lambda should be legal as a
>> member function.
>>
>>
>>
>> On Tuesday, 18 February 2014 00:08:05 UTC-5, Nick wrote:
>>>
>>> If a lambda expression with an empty capture list can be converted to a
>>> regular function pointer, could a lambda expression which only captures [
>>> this] be converted to a member function pointer for the enclosing
>>> class, such that the following code would be legal?
>>>
>>> struct foo {
>>> int i;
>>>
>>> void bar() {
>>> void(foo::*pfn)() = [this](){ cout << i << endl; };
>>> }
>>> };
>>>
>>>
>>> --
>>
>> ---
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1661_14332902.1392745826518
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That's not what I meant. Basically, what I am suggesting w=
ould be implemented by adding a conversion operator returning a ptmf when t=
he capture list contains only [<font color=3D"#0000ff">this</font>].<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: #=
008;" class=3D"styled-by-prettify">typedef</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">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::*</span><span class=3D"styled-by-prettify"><font color=3D"#000000">=
ptmf_t</font></span><span class=3D"styled-by-prettify" style=3D"font-family=
: Arial, Helvetica, sans-serif; font-size: 13px; color: rgb(102, 102, 0);">=
)()</span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, H=
elvetica, sans-serif; font-size: 13px; color: rgb(0, 0, 0);"> </span><span =
class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-s=
erif; font-size: 13px; color: rgb(102, 102, 0);">;</span></div><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">lambda</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #008;" class=3D"styled-by-prettify">operator<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ptmf_t</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span></di=
v></code></div><div><br><div><br>On Tuesday, 18 February 2014 10:53:31 UTC-=
5, Billy O'Neal 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"><div>void(*fn) {} is not a pointer to member declaration, so you =
wouldn't want the compiler to make it a member function anyway.</div></div>=
<div><br clear=3D"all"><div><div dir=3D"ltr"><div>
Billy O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/" target=
=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.com/url?q\75http=
s%3A%2F%2Fbitbucket.org%2FBillyONeal%2F\46sa\75D\46sntz\0751\46usg\75AFQjCN=
EUaaIry0cea0l0vX6ztWgwQ7_4Lg';return true;" onclick=3D"this.href=3D'https:/=
/www.google.com/url?q\75https%3A%2F%2Fbitbucket.org%2FBillyONeal%2F\46sa\75=
D\46sntz\0751\46usg\75AFQjCNEUaaIry0cea0l0vX6ztWgwQ7_4Lg';return true;">htt=
ps://github.com/BillyONeal/</a></div><div><a href=3D"http://stackoverflow.c=
om/users/82320/billy-oneal" target=3D"_blank" onmousedown=3D"this.href=3D'h=
ttp://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fusers%2F82320=
%2Fbilly-oneal\46sa\75D\46sntz\0751\46usg\75AFQjCNHY_gA133vyg0yY-U2PNMVA8cC=
SBg';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75ht=
tp%3A%2F%2Fstackoverflow.com%2Fusers%2F82320%2Fbilly-oneal\46sa\75D\46sntz\=
0751\46usg\75AFQjCNHY_gA133vyg0yY-U2PNMVA8cCSBg';return true;">http://stack=
overflow.com/<wbr>users/82320/billy-oneal</a></div>
</div></div>
<br><br><div class=3D"gmail_quote">On Tue, Feb 18, 2014 at 7:30 AM, Nick <s=
pan dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscate=
d-mailto=3D"7-1hYjZ_oMEJ" onmousedown=3D"this.href=3D'javascript:';return t=
rue;" onclick=3D"this.href=3D'javascript:';return true;">nicolas.j...@gmail=
..com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div>Thanks for the responses. After a second look, I seem=
to have been mistaken in thinking that the following code was a special ca=
se:</div><div><br></div><div><div style=3D"border:1px solid rgb(187,187,187=
);background-color:rgb(250,250,250)">
<code><div><font color=3D"#000088"><span style=3D"color:rgb(0,0,136)">void<=
/span><span style=3D"color:rgb(102,102,0)">(*</span><span>fn</span><span st=
yle=3D"color:rgb(102,102,0)">)()</span><span> </span><span style=3D"color:r=
gb(102,102,0)">=3D</span><span> </span><span style=3D"color:rgb(102,102,0)"=
>[](){</span><span> cout </span><span style=3D"color:rgb(102,102,0)"><&l=
t;</span><span> </span><span style=3D"color:rgb(0,136,0)">"hello world"</sp=
an><span> </span><span style=3D"color:rgb(102,102,0)"><<</span><span>=
endl</span><span style=3D"color:rgb(102,102,0)">;</span><span> </span><spa=
n style=3D"color:rgb(102,102,0)">};</span></font><span><br>
</span></div></code></div><br>I thought that the construction of the lambda=
/function object would have been elided in this case, but after reviewing t=
he disassembly, it seems that the above is done by calling a conversion ope=
rator.</div>
<div><br></div><div>Under the above premise, I assumed that only capturing =
[this] would ensure that the code inside the lambda would also be legal as =
a member function, and could be special cased.</div><div><br></div><div>
I didn't intend for [this] to actually be captured, but only for it to tell=
the compiler that the code inside the lambda should be legal as a member f=
unction.</div><div><div><div><br></div><div><br></div><div>
<br>On Tuesday, 18 February 2014 00:08:05 UTC-5, Nick wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;bord=
er-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:soli=
d">
<div dir=3D"ltr"><div>If a lambda expression with an empty capture list can=
be converted to a regular function pointer, could a lambda expression whic=
h only captures [<font color=3D"#0000ff">this</font>] be converted to a mem=
ber function pointer for the enclosing class, such that the following code =
would be legal?</div>
<div><br></div><div style=3D"border:1px solid rgb(187,187,187);background-c=
olor:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">struct=
</span><span> foo </span><span style=3D"color:rgb(102,102,0)">{</span><span=
><br>
</span><span style=3D"color:rgb(0,0,136)">int</span><span> i<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span><br><br> &nb=
sp; </span><span style=3D"color:rgb(0,0,136)">void</span><span> bar</span><=
span style=3D"color:rgb(102,102,0)">()</span><span> </span><span style=3D"c=
olor:rgb(102,102,0)">{</span><span><br>
</span><span style=3D"color:rgb(0,0,136)">void<=
/span><span style=3D"color:rgb(102,102,0)">(</span><span>foo</span><span st=
yle=3D"color:rgb(102,102,0)">::*</span><span>pfn</span><span style=3D"color=
:rgb(102,102,0)">)()</span><span> </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span> </span><span style=3D"color:rgb(102,102,0)">[</span><sp=
an style=3D"color:rgb(0,0,136)">this</span><span style=3D"color:rgb(102,102=
,0)">](){</span><span> cout </span><span style=3D"color:rgb(102,102,0)"><=
;<</span><span> i </span><span style=3D"color:rgb(102,102,0)"><<</=
span><span> endl</span><span style=3D"color:rgb(102,102,0)">;</span><span> =
</span><span style=3D"color:rgb(102,102,0)">};</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span><br=
></span><span style=3D"color:rgb(102,102,0)">};</span></div></code></div><b=
r><div><br></div></div></blockquote></div></div></div></div><div><div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
7-1hYjZ_oMEJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"7-1hYjZ_oMEJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></blockquote></div><br></div>
</blockquote></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1661_14332902.1392745826518--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 18 Feb 2014 11:55:17 -0600
Raw View
--047d7bfceb4a066e5e04f2b1fcc5
Content-Type: text/plain; charset=ISO-8859-1
On 18 February 2014 11:50, Nick <nicolas.jinchereau@gmail.com> wrote:
> That's not what I meant. Basically, what I am suggesting would be
> implemented by adding a conversion operator returning a ptmf when the
> capture list contains only [this].
>
So you want it to convert to something that doesn't actually have a
captured this?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7bfceb4a066e5e04f2b1fcc5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 18 February 2014 11:50, Nick <span dir=3D"ltr"><<a h=
ref=3D"mailto:nicolas.jinchereau@gmail.com" target=3D"_blank">nicolas.jinch=
ereau@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div cl=
ass=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">That's not what I meant=
.. Basically, what I am suggesting would be implemented by adding a conversi=
on operator returning a ptmf when the capture list contains only [<font col=
or=3D"#0000ff">this</font>].</div>
</blockquote><div><br></div><div>So you want it to convert to something tha=
t doesn't actually have a captured this?<br></div></div>-- <br>=A0Nevin=
":-)" Liber=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.c=
om" target=3D"_blank">nevin@eviloverlord.com</a>>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bfceb4a066e5e04f2b1fcc5--
.
Author: Nick <nicolas.jinchereau@gmail.com>
Date: Tue, 18 Feb 2014 10:01:33 -0800 (PST)
Raw View
------=_Part_103_20210793.1392746493461
Content-Type: text/plain; charset=UTF-8
Yes.
On Tuesday, 18 February 2014 12:55:17 UTC-5, Nevin ":-)" Liber wrote:
>
> On 18 February 2014 11:50, Nick <nicolas.j...@gmail.com <javascript:>>wrote:
>
>> That's not what I meant. Basically, what I am suggesting would be
>> implemented by adding a conversion operator returning a ptmf when the
>> capture list contains only [this].
>>
>
> So you want it to convert to something that doesn't actually have a
> captured this?
> --
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com <javascript:>> (847)
> 691-1404
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_103_20210793.1392746493461
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes.<br><br>On Tuesday, 18 February 2014 12:55:17 UTC-5, N=
evin ":-)" Liber 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">On 18 February 2014 11:50, Nick <span dir=3D"ltr"><<a href=3D=
"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"mKRW0SSEEJEJ" onmo=
usedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
javascript:';return true;">nicolas.j...@gmail.com</a>></span> wrote:<br>=
<div><div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">That's not what I meant. Ba=
sically, what I am suggesting would be implemented by adding a conversion o=
perator returning a ptmf when the capture list contains only [<font color=
=3D"#0000ff">this</font>].</div>
</blockquote><div><br></div><div>So you want it to convert to something tha=
t doesn't actually have a captured this?<br></div></div>-- <br> Nevin =
":-)" Liber <mailto:<a href=3D"javascript:" target=3D"_blank" gdf-=
obfuscated-mailto=3D"mKRW0SSEEJEJ" onmousedown=3D"this.href=3D'javascript:'=
;return true;" onclick=3D"this.href=3D'javascript:';return true;">ne...@evi=
loverlord.com</a><wbr>> (847) 691-1404
</div></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_103_20210793.1392746493461--
.
Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Tue, 18 Feb 2014 11:35:21 -0800 (PST)
Raw View
------=_Part_748_15575534.1392752121581
Content-Type: text/plain; charset=UTF-8
On Tuesday, February 18, 2014 10:01:33 AM UTC-8, Nick wrote:
>
> Yes.
>
That would be semantically really confusing and weird.
If you really need support for such a feature, a more logical syntax would
not involve a bogus capture but would either explicitly indicate that the
lambda requires 'this' be provided by the caller, e.g. [](Foo* this){ /*
stuff */ }, or would allow any function with a pointer-to-class as the
first parameter be convertible to member function pointer for that class
type with the signature modified to remove that parameter, e.g. [](Foo*
pFoo, int a, char b)->float{} converts to float(Foo::*)(int,char) and
[](const Foo*){} converts to void(Foo::*)()const.
I'm unconvinced you at all need this instead of just using std::function,
though. Conversion to regular function pointer makes sense for C
compatibility which will never grow support for C++ types, but C++ code can
just use the new stdlib types. Even most legacy C++ code could be
converted more easily than requiring use of this feature given that it'll
be years before any new feature potentially coming out of this discussion
would ever be in a shipping compiler.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_748_15575534.1392752121581
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, February 18, 2014 10:01:33 AM UTC-8, Nick wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Yes.</div><=
/blockquote><div><br></div><div>That would be semantically really confusing=
and weird.</div><div><br></div><div>If you really need support for such a =
feature, a more logical syntax would not involve a bogus capture but would =
either explicitly indicate that the lambda requires 'this' be provided by t=
he caller, e.g. [](Foo* this){ /* stuff */ }, or would allow any function w=
ith a pointer-to-class as the first parameter be convertible to member func=
tion pointer for that class type with the signature modified to remove that=
parameter, e.g. [](Foo* pFoo, int a, char b)->float{} converts to float=
(Foo::*)(int,char) and [](const Foo*){} converts to void(Foo::*)()const.</d=
iv><div><br></div><div>I'm unconvinced you at all need this instead of just=
using std::function, though. Conversion to regular function pointer =
makes sense for C compatibility which will never grow support for C++ types=
, but C++ code can just use the new stdlib types. Even most legacy C+=
+ code could be converted more easily than requiring use of this feature gi=
ven that it'll be years before any new feature potentially coming out of th=
is discussion would ever be in a shipping compiler.</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_748_15575534.1392752121581--
.