Topic: C++ Delegate
Author: "Mike.L.H" <michael.liberty.hsieh@gmail.com>
Date: Thu, 18 Dec 2014 01:19:12 -0800 (PST)
Raw View
------=_Part_5605_1664786522.1418894352227
Content-Type: multipart/alternative;
boundary="----=_Part_5606_502638491.1418894352227"
------=_Part_5606_502638491.1418894352227
Content-Type: text/plain; charset=UTF-8
I must say that C++ member function pointers are almost useless. What I
want is a lightweight member function pointer just like the C function
pointer.
The Delegate type can be viewed as if it is an instantiation of the class
template defined by the pseudo code below:
template<typename TReturn, typename...TArgs>
class Delegate{
private:
void* vp;
TReturn (*mfp)(void*, TArgs...);
public:
TReturn operator()(TArgs...args){
return mfp(args...);
}
...
};
We can create a Delegate from an instance of some class by the following
syntax:
auto delegate = &obj.fun(parameter-type-list-opt);
or
auto delegate = &p->mf(parameter-type-list-opt);
Because we already have an object, virtual function call resolution should
be finished before the left hand side of the statement complete and the
*mfp* should always store the address the "real" function that will be call
on *obj* or *p*.
--
---
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_5606_502638491.1418894352227
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><font face=3D"verdana, sans-serif" size=3D"4">I must =
say that C++ member function pointers are almost useless. What I want is a =
lightweight member function pointer just like the C function pointer. =
</font></div><div><font face=3D"verdana, sans-serif" size=3D"4"><br></font>=
</div><div><font face=3D"verdana, sans-serif" size=3D"4">The Delegate type =
can be viewed as if it is an instantiation of the class template defined by=
the pseudo code below:</font></div><div><font size=3D"4"><br></font></div>=
<div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); w=
ord-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><font size=3D"4"><span style=3D=
"color: #008;" class=3D"styled-by-prettify">template</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" clas=
s=3D"styled-by-prettify">TReturn</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">typename</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">...</span><span style=3D"color: #606;" class=3D"styled-by-prettify">TAr=
gs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Delegate</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">private</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> vp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">TRe=
turn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">mfp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">*,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">TArgs</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">...);</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
public</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; </span><span style=3D"color: #606;" class=3D"styled-by-prettify">TRetu=
rn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">()(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">TArgs</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify">args</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">){</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> mfp</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">args</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">};</span></font></div></code></div><div><font size=3D"4"><br><=
/font></div><div><font size=3D"4"><br></font></div><div><font face=3D"verda=
na, sans-serif" size=3D"4">We can create a Delegate from an instance of som=
e class by the following syntax:</font></div><div><font size=3D"4"><br></fo=
nt></div><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187=
, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><font size=3D"4">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">delegate</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">obj</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">fun</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">parameter</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">list</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">opt</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">);</span></font></div></code></div></div><div><font face=
=3D"verdana, sans-serif" size=3D"4">or</font></div><div><div class=3D"prett=
yprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><font size=3D"4"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">delegate</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">=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">p</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">-></span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">mf</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">parameter</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">type</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">list</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">opt</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span></font></di=
v></code></div></div><div><font size=3D"4"><br></font></div><div><font face=
=3D"verdana, sans-serif" size=3D"4">Because we already have an object, virt=
ual function call resolution should be finished before the left hand side o=
f the statement complete and the <b>mfp</b> should always store the ad=
dress the "real" function that will be call on <b>obj</b> or <b>p</b>.</fon=
t></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_5606_502638491.1418894352227--
------=_Part_5605_1664786522.1418894352227--
.
Author: "Mike.L.H" <michael.liberty.hsieh@gmail.com>
Date: Thu, 18 Dec 2014 01:23:38 -0800 (PST)
Raw View
------=_Part_5008_1788903438.1418894618224
Content-Type: multipart/alternative;
boundary="----=_Part_5009_1329024466.1418894618224"
------=_Part_5009_1329024466.1418894618224
Content-Type: text/plain; charset=UTF-8
I must say that C++ member function pointers are almost useless. What I
want is a lightweight member function pointer just like the C function
pointer.
The Delegate type can be viewed as if it is an instantiation of the class
template defined by the pseudo code below:
template<typename TReturn, typename...TArgs>
class Delegate{
private:
void* vp;
TReturn (*mfp)(void*, TArgs...);
public:
TReturn operator()(TArgs...args){
return mfp(vp, args...);
}
...
};
We can create a Delegate from an instance of some class by the following
syntax:
auto delegate = &obj.fun(parameter-type-list-opt);
or
auto delegate = &p->mf(parameter-type-list-opt);
Because we already have an object, virtual function call resolution should
be finished before the left hand side of the statement complete and the
*mfp* should always store the address the "real" function that will be call
on *obj* or *p*.
--
---
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_5009_1329024466.1418894618224
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><font face=3D"verdana, sans-serif" size=3D"4">I must =
say that C++ member function pointers are almost useless. What I want is a =
lightweight member function pointer just like the C function pointer. =
</font></div><div><font face=3D"verdana, sans-serif" size=3D"4"><br></font>=
</div><div><font face=3D"verdana, sans-serif" size=3D"4">The Delegate type =
can be viewed as if it is an instantiation of the class template defined by=
the pseudo code below:</font></div><div><font size=3D"4"><br></font></div>=
<div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code><font size=3D"4"><span style=
=3D"color: rgb(0, 0, 136);">template</span><span style=3D"color: rgb(102, 1=
02, 0);"><</span><span style=3D"color: rgb(0, 0, 136);">typename</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
102, 0, 102);">TReturn</span><span style=3D"color: rgb(102, 102, 0);">,</sp=
an><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: =
rgb(0, 0, 136);">typename</span><span style=3D"color: rgb(102, 102, 0);">..=
..</span><span style=3D"color: rgb(102, 0, 102);">TArgs</span><span style=3D=
"color: rgb(102, 102, 0);">></span><span style=3D"color: rgb(0, 0, 0);">=
<br></span><span style=3D"color: rgb(0, 0, 136);">class</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 10=
2);">Delegate</span><span style=3D"color: rgb(102, 102, 0);">{</span><span =
style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0, 1=
36);">private</span><span style=3D"color: rgb(102, 102, 0);">:</span><span =
style=3D"color: rgb(0, 0, 0);"><br> </span><span style=3D=
"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(102, 102, 0);=
">*</span><span style=3D"color: rgb(0, 0, 0);"> vp</span><span style=
=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);">=
<br> </span><span style=3D"color: rgb(102, 0, 102);">TRet=
urn</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"=
color: rgb(102, 102, 0);">(*</span><span style=3D"color: rgb(0, 0, 0);">mfp=
</span><span style=3D"color: rgb(102, 102, 0);">)(</span><span style=3D"col=
or: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(102, 102, 0);">*,=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 0, 102);">TArgs</span><span style=3D"color: rgb(102, 102, 0);"=
>...);</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D=
"color: rgb(0, 0, 136);">public</span><span style=3D"color: rgb(102, 102, 0=
);">:</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 0, 102);">TReturn</span><span style=3D"c=
olor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">op=
erator</span><span style=3D"color: rgb(102, 102, 0);">()(</span><span style=
=3D"color: rgb(102, 0, 102);">TArgs</span><span style=3D"color: rgb(102, 10=
2, 0);">...</span><span style=3D"color: rgb(0, 0, 0);">args</span><span sty=
le=3D"color: rgb(102, 102, 0);">){</span><span style=3D"color: rgb(0, 0, 0)=
;"><br> </span><span style=3D"color: rgb(0,=
0, 136);">return</span><span style=3D"color: rgb(0, 0, 0);"> mfp</spa=
n><span style=3D"color: rgb(102, 102, 0);">(vp, </span><span style=3D"=
color: rgb(0, 0, 0);">args</span><span style=3D"color: rgb(102, 102, 0);">.=
...);</span><span style=3D"color: rgb(0, 0, 0);"><br> </sp=
an><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: r=
gb(0, 0, 0);"><br> </span><span style=3D"color: rgb(102, =
102, 0);">...</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span s=
tyle=3D"color: rgb(102, 102, 0);">};</span></font></code></div><div><font s=
ize=3D"4"><br></font></div><div><font size=3D"4"><br></font></div><div><fon=
t face=3D"verdana, sans-serif" size=3D"4">We can create a Delegate from an =
instance of some class by the following syntax:</font></div><div><font size=
=3D"4"><br></font></div><div><div style=3D"border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code><=
font size=3D"4"><span style=3D"color: rgb(0, 0, 0);"> </s=
pan><span style=3D"color: rgb(0, 0, 136);">auto</span><span style=3D"color:=
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">delegat=
e</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);">&nbs=
p;</span><span style=3D"color: rgb(102, 102, 0);">&</span><span style=
=3D"color: rgb(0, 0, 0);">obj</span><span style=3D"color: rgb(102, 102, 0);=
">.</span><span style=3D"color: rgb(0, 0, 0);">fun</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">paramet=
er</span><span style=3D"color: rgb(102, 102, 0);">-</span><span style=3D"co=
lor: rgb(0, 0, 0);">type</span><span style=3D"color: rgb(102, 102, 0);">-</=
span><span style=3D"color: rgb(0, 0, 0);">list</span><span style=3D"color: =
rgb(102, 102, 0);">-</span><span style=3D"color: rgb(0, 0, 0);">o<wbr>pt</s=
pan><span style=3D"color: rgb(102, 102, 0);">);</span></font></code></div><=
/div><div><font face=3D"verdana, sans-serif" size=3D"4">or</font></div><div=
><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word;=
background-color: rgb(250, 250, 250);"><code><font size=3D"4"><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(0, 0, 136);">auto</span><span style=3D"color: rgb(0, 0, 0);"> </spa=
n><span style=3D"color: rgb(0, 0, 136);">delegate</span><span style=3D"colo=
r: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=3D=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);">&</span><span style=3D"color: rgb(0, 0, 0);">p</=
span><span style=3D"color: rgb(102, 102, 0);">-></span><span style=3D"co=
lor: rgb(0, 0, 0);">mf</span><span style=3D"color: rgb(102, 102, 0);">(</sp=
an><span style=3D"color: rgb(0, 0, 0);">parameter</span><span style=3D"colo=
r: rgb(102, 102, 0);">-</span><span style=3D"color: rgb(0, 0, 0);">type</sp=
an><span style=3D"color: rgb(102, 102, 0);">-</span><span style=3D"color: r=
gb(0, 0, 0);">list</span><span style=3D"color: rgb(102, 102, 0);">-</span><=
span style=3D"color: rgb(0, 0, 0);">opt</span><span style=3D"color: rgb(102=
, 102, 0);"><wbr>);</span></font></code></div></div><div><font size=3D"4"><=
br></font></div><div><font face=3D"verdana, sans-serif" size=3D"4">Because =
we already have an object, virtual function call resolution should be finis=
hed before the left hand side of the statement complete and the <b>mfp=
</b> should always store the address the "real" function that will be =
call on <b>obj</b> or <b>p</b>.</font></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_5009_1329024466.1418894618224--
------=_Part_5008_1788903438.1418894618224--
.
Author: Sean Hunt <scshunt@csclub.uwaterloo.ca>
Date: Thu, 18 Dec 2014 14:35:47 -0800 (PST)
Raw View
------=_Part_144_949688054.1418942147512
Content-Type: multipart/alternative;
boundary="----=_Part_145_1308659074.1418942147512"
------=_Part_145_1308659074.1418942147512
Content-Type: text/plain; charset=UTF-8
On Thursday, December 18, 2014 4:23:38 AM UTC-5, Mike.L.H wrote:
> I must say that C++ member function pointers are almost useless. What I
> want is a lightweight member function pointer just like the C function
> pointer.
>
What would this do that std::function does not already do better?
Sean
--
---
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_145_1308659074.1418942147512
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, December 18, 2014 4:23:38 AM UTC-5, Mike.L.H =
wrote:<br><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"><di=
v><font face=3D"verdana, sans-serif" size=3D"4">I must say that C++ member =
function pointers are almost useless. What I want is a lightweight member f=
unction pointer just like the C function pointer. </font></div></div><=
/blockquote><div><br></div><div>What would this do that std::function does =
not already do better?</div><div><br></div><div>Sean </div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_145_1308659074.1418942147512--
------=_Part_144_949688054.1418942147512--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 19 Dec 2014 00:51:52 +0000
Raw View
Oh? I am working on a project where PMFs are the ideal solution.
On 12/18/14, Sean Hunt <scshunt@csclub.uwaterloo.ca> wrote:
> On Thursday, December 18, 2014 4:23:38 AM UTC-5, Mike.L.H wrote:
>
>> I must say that C++ member function pointers are almost useless. What I
>> want is a lightweight member function pointer just like the C function
>> pointer.
>>
>
> What would this do that std::function does not already do better?
>
> Sean
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: "Mike.L.H" <michael.liberty.hsieh@gmail.com>
Date: Fri, 19 Dec 2014 22:27:54 -0800 (PST)
Raw View
------=_Part_1284_495500946.1419056874761
Content-Type: multipart/alternative;
boundary="----=_Part_1285_2090300003.1419056874761"
------=_Part_1285_2090300003.1419056874761
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
std::function comes with a price that is far more expensive than Delegate.=
=20
And you can't compare std::function for equality.
=E5=9C=A8 2014=E5=B9=B412=E6=9C=8819=E6=97=A5=E6=98=9F=E6=9C=9F=E4=BA=94UTC=
+8=E4=B8=8A=E5=8D=886=E6=97=B635=E5=88=8647=E7=A7=92=EF=BC=8CSean Hunt=E5=
=86=99=E9=81=93=EF=BC=9A
>
> On Thursday, December 18, 2014 4:23:38 AM UTC-5, Mike.L.H wrote:
>
>> I must say that C++ member function pointers are almost useless. What I=
=20
>> want is a lightweight member function pointer just like the C function=
=20
>> pointer.=20
>>
>
> What would this do that std::function does not already do better?
>
> Sean=20
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1285_2090300003.1419056874761
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">std::function comes with a price that is far more expensiv=
e than Delegate. And you can't compare std::function for equality.<br><br>=
=E5=9C=A8 2014=E5=B9=B412=E6=9C=8819=E6=97=A5=E6=98=9F=E6=9C=9F=E4=BA=94UTC=
+8=E4=B8=8A=E5=8D=886=E6=97=B635=E5=88=8647=E7=A7=92=EF=BC=8CSean Hunt=E5=
=86=99=E9=81=93=EF=BC=9A<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 Thursday, December 18, 2014 4:23:38 AM UTC-5, Mike.L.H wrote:=
<br><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"><div><font fac=
e=3D"verdana, sans-serif" size=3D"4">I must say that C++ member function po=
inters are almost useless. What I want is a lightweight member function poi=
nter just like the C function pointer. </font></div></div></blockquote=
><div><br></div><div>What would this do that std::function does not already=
do better?</div><div><br></div><div>Sean </div></div></blockquote></d=
iv>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1285_2090300003.1419056874761--
------=_Part_1284_495500946.1419056874761--
.
Author: "Mike.L.H" <michael.liberty.hsieh@gmail.com>
Date: Fri, 19 Dec 2014 22:40:46 -0800 (PST)
Raw View
------=_Part_1343_2048423155.1419057646191
Content-Type: multipart/alternative;
boundary="----=_Part_1344_1537621028.1419057646191"
------=_Part_1344_1537621028.1419057646191
Content-Type: text/plain; charset=UTF-8
I come up with the syntax for the declaration of delegate(by using this
keyword):
return-type (*mfp)(this, parameter-list);
The this keyword here indicates that the this pointer is packed with the
function pointer. And the "real" function pointer here should be of type:
return-type (*fp)(void*, parameter-list);
It's totally typesafe here cause the first argument is already packed with
it.
And perhaps "C++ Delegate" should have a new name (probably "plain old
member function pointer") so that it won't mix with C# when googling.
--
---
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_1344_1537621028.1419057646191
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><font size=3D"4" face=3D"verdana, sans-serif">I come up wi=
th the syntax for the declaration of delegate(by using <font color=3D"#0000=
ff">this</font> keyword):</font><div><font size=3D"4" face=3D"verdana, sans=
-serif"></font><div class=3D"prettyprint" style=3D"border: 1px solid rgb(18=
7, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"=
><code class=3D"prettyprint"><div class=3D"subprettyprint"><font size=3D"4"=
face=3D"verdana, sans-serif"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">return</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
type </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(*</s=
pan><font color=3D"#000088"><span style=3D"color: #000;" class=3D"styled-by=
-prettify">mfp</span></font><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> parameter</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">list</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span></font></div></cod=
e></div><font size=3D"4" face=3D"verdana, sans-serif">The <span style=3D"ba=
ckground-color: rgb(255, 255, 255);"><font color=3D"#0000ff">this </font></=
span>keyword here indicates that the <font color=3D"#0000ff">this </font>po=
inter is packed with the function pointer. And the "real" function pointer =
here should be of type:</font></div><div><font size=3D"4" face=3D"verdana, =
sans-serif"><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, =
187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><c=
ode class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">type </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">fp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">)(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> parameter</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">list</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">);</span></div></code></div>It's=
totally typesafe here cause the first argument is already packed with it.<=
/font></div><div><font size=3D"4" face=3D"verdana, sans-serif"><br></font><=
/div><div><font size=3D"4" face=3D"verdana, sans-serif">And perhaps "C++ De=
legate" should have a new name (probably "plain old member function pointer=
") so that it won't mix with C# when googling.</font></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1344_1537621028.1419057646191--
------=_Part_1343_2048423155.1419057646191--
.
Author: "Mike.L.H" <michael.liberty.hsieh@gmail.com>
Date: Sat, 20 Dec 2014 21:57:16 -0800 (PST)
Raw View
------=_Part_851_977880014.1419141436306
Content-Type: multipart/alternative;
boundary="----=_Part_852_537044807.1419141436306"
------=_Part_852_537044807.1419141436306
Content-Type: text/plain; charset=UTF-8
All these can be easily implemented as a library instead of a core language
feature if we can get the address of a the member function. So the proposal
should be named as "member function address". I don't think something like
that will be accepted by the standard committee. It's useless for me to
continue.
--
---
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_852_537044807.1419141436306
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><font face=3D"verdana, sans-serif">All these can be easily=
implemented as a library instead of a core language feature if we can get =
the address of a the member function. So the proposal should be named as "m=
ember function address". I don't think something like that will be accepted=
by the standard committee. It's useless for me to continue.</font></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_852_537044807.1419141436306--
------=_Part_851_977880014.1419141436306--
.