Topic: Smaller than tiny proposal: RaiiCaps
Author: Rob Meijer <pibara@gmail.com>
Date: Wed, 27 Mar 2013 23:21:27 +0100
Raw View
--20cf307f35fc85401204d8ef75d7
Content-Type: text/plain; charset=ISO-8859-1
A few months ago I wrote a blog post about a potential singleton
alternative that I dubbed RAII-Caps (capability like references for access
to the constructor of resource management (RAI) classes.
http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/
Although I'm rather embarrassed by the small size of the actual code needed
for this proposal (a few lines only and small lines at that), I believe it
may be an extremely modest useful addition to the standard library.
template <typename T>
class raiicap {
public:
friend int main(int,char **);
private:
raiicap(){}
};
My proposal thus is the addition of this tiny raiicap template to the
standard library.
--
---
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/?hl=en.
--20cf307f35fc85401204d8ef75d7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div style>A few months ago I wrote a blog post about a po=
tential singleton alternative that I dubbed RAII-Caps (capability like refe=
rences for access to the constructor of resource management (RAI) classes.<=
/div>
<div style><br></div><div style><a href=3D"http://minorfs.wordpress.com/201=
3/01/18/raiicap-pattern-injected-singleton-alternative-for-c/">http://minor=
fs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-=
for-c/</a><br>
</div><div><br></div>Although I'm rather=A0embarrassed=A0by the small s=
ize of the actual code needed for this proposal (a few lines only and small=
lines at that), I believe it may be an extremely =A0modest useful addition=
to the standard library.<div>
<br></div><div><div class=3D"" style=3D"font-family:Consolas,'Bitstream=
Vera Sans Mono','Courier New',Courier,monospace;line-height:15=
..390625px;font-size:14px;color:rgb(255,236,208);border:0px!important;margin=
:0px!important;outline:0px!important;padding:0px 1em!important;vertical-ali=
gn:baseline!important;border-top-left-radius:0px!important;border-top-right=
-radius:0px!important;border-bottom-right-radius:0px!important;border-botto=
m-left-radius:0px!important;background-image:none!important;float:none!impo=
rtant;height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;font-weight:bold!important;margin:0px!important;outline:0px!important;pa=
dding:0px!important;vertical-align:baseline!important;font-size:1em!importa=
nt;line-height:1.1em!important;border-top-left-radius:0px!important;border-=
top-right-radius:0px!important;border-bottom-right-radius:0px!important;bor=
der-bottom-left-radius:0px!important;background-image:none!important;float:=
none!important;height:auto!important;overflow:visible!important;width:auto!=
important;direction:ltr!important;display:inline!important;color:rgb(0,102,=
153)!important">template</code> <code class=3D"" style=3D"border:0px!import=
ant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier Ne=
w',Courier,monospace!important;margin:0px!important;outline:0px!importa=
nt;padding:0px!important;vertical-align:baseline!important;font-size:1em!im=
portant;line-height:1.1em!important;border-top-left-radius:0px!important;bo=
rder-top-right-radius:0px!important;border-bottom-right-radius:0px!importan=
t;border-bottom-left-radius:0px!important;background-image:none!important;f=
loat:none!important;height:auto!important;overflow:visible!important;width:=
auto!important;direction:ltr!important;display:inline!important;color:black=
!important"><</code><code class=3D"" style=3D"border:0px!important;font-=
family:Consolas,'Bitstream Vera Sans Mono','Courier New',Co=
urier,monospace!important;font-weight:bold!important;margin:0px!important;o=
utline:0px!important;padding:0px!important;vertical-align:baseline!importan=
t;font-size:1em!important;line-height:1.1em!important;border-top-left-radiu=
s:0px!important;border-top-right-radius:0px!important;border-bottom-right-r=
adius:0px!important;border-bottom-left-radius:0px!important;background-imag=
e:none!important;float:none!important;height:auto!important;overflow:visibl=
e!important;width:auto!important;direction:ltr!important;display:inline!imp=
ortant;color:rgb(0,102,153)!important">typename</code> <code class=3D"" sty=
le=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mo=
no','Courier New',Courier,monospace!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;display:inlin=
e!important;color:black!important">T></code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;font-weight:bold!important;margin:0px!important;outline:0px!important;pa=
dding:0px!important;vertical-align:baseline!important;font-size:1em!importa=
nt;line-height:1.1em!important;border-top-left-radius:0px!important;border-=
top-right-radius:0px!important;border-bottom-right-radius:0px!important;bor=
der-bottom-left-radius:0px!important;background-image:none!important;float:=
none!important;height:auto!important;overflow:visible!important;width:auto!=
important;direction:ltr!important;display:inline!important;color:rgb(0,102,=
153)!important">class</code> <code class=3D"" style=3D"border:0px!important=
;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New&#=
39;,Courier,monospace!important;margin:0px!important;outline:0px!important;=
padding:0px!important;vertical-align:baseline!important;font-size:1em!impor=
tant;line-height:1.1em!important;border-top-left-radius:0px!important;borde=
r-top-right-radius:0px!important;border-bottom-right-radius:0px!important;b=
order-bottom-left-radius:0px!important;background-image:none!important;floa=
t:none!important;height:auto!important;overflow:visible!important;width:aut=
o!important;direction:ltr!important;display:inline!important;color:black!im=
portant">raiicap {</code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important">=A0=A0</code><code class=3D"" style=3D"bor=
der:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono',&=
#39;Courier New',Courier,monospace!important;font-weight:bold!important=
;margin:0px!important;outline:0px!important;padding:0px!important;vertical-=
align:baseline!important;font-size:1em!important;line-height:1.1em!importan=
t;border-top-left-radius:0px!important;border-top-right-radius:0px!importan=
t;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!im=
portant;background-image:none!important;float:none!important;height:auto!im=
portant;overflow:visible!important;width:auto!important;direction:ltr!impor=
tant;display:inline!important;color:rgb(0,102,153)!important">public</code>=
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important;color:black!important">:</code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important">=A0=A0=A0=A0</code><code class=3D"" style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;font-weight:bold!im=
portant;margin:0px!important;outline:0px!important;padding:0px!important;ve=
rtical-align:baseline!important;font-size:1em!important;line-height:1.1em!i=
mportant;border-top-left-radius:0px!important;border-top-right-radius:0px!i=
mportant;border-bottom-right-radius:0px!important;border-bottom-left-radius=
:0px!important;background-image:none!important;float:none!important;height:=
auto!important;overflow:visible!important;width:auto!important;direction:lt=
r!important;display:inline!important;color:rgb(0,102,153)!important">friend=
</code> <code class=3D"" style=3D"border:0px!important;font-family:Consolas=
,'Bitstream Vera Sans Mono','Courier New',Courier,monospace=
!important;font-weight:bold!important;margin:0px!important;outline:0px!impo=
rtant;padding:0px!important;vertical-align:baseline!important;font-size:1em=
!important;line-height:1.1em!important;border-top-left-radius:0px!important=
;border-top-right-radius:0px!important;border-bottom-right-radius:0px!impor=
tant;border-bottom-left-radius:0px!important;background-image:none!importan=
t;float:none!important;height:auto!important;overflow:visible!important;wid=
th:auto!important;direction:ltr!important;display:inline!important;color:gr=
ay!important">int</code> <code class=3D"" style=3D"border:0px!important;fon=
t-family:Consolas,'Bitstream Vera Sans Mono','Courier New',=
Courier,monospace!important;margin:0px!important;outline:0px!important;padd=
ing:0px!important;vertical-align:baseline!important;font-size:1em!important=
;line-height:1.1em!important;border-top-left-radius:0px!important;border-to=
p-right-radius:0px!important;border-bottom-right-radius:0px!important;borde=
r-bottom-left-radius:0px!important;background-image:none!important;float:no=
ne!important;height:auto!important;overflow:visible!important;width:auto!im=
portant;direction:ltr!important;display:inline!important;color:black!import=
ant">main(</code><code class=3D"" style=3D"border:0px!important;font-family=
:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,=
monospace!important;font-weight:bold!important;margin:0px!important;outline=
:0px!important;padding:0px!important;vertical-align:baseline!important;font=
-size:1em!important;line-height:1.1em!important;border-top-left-radius:0px!=
important;border-top-right-radius:0px!important;border-bottom-right-radius:=
0px!important;border-bottom-left-radius:0px!important;background-image:none=
!important;float:none!important;height:auto!important;overflow:visible!impo=
rtant;width:auto!important;direction:ltr!important;display:inline!important=
;color:gray!important">int</code><code class=3D"" style=3D"border:0px!impor=
tant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier N=
ew',Courier,monospace!important;margin:0px!important;outline:0px!import=
ant;padding:0px!important;vertical-align:baseline!important;font-size:1em!i=
mportant;line-height:1.1em!important;border-top-left-radius:0px!important;b=
order-top-right-radius:0px!important;border-bottom-right-radius:0px!importa=
nt;border-bottom-left-radius:0px!important;background-image:none!important;=
float:none!important;height:auto!important;overflow:visible!important;width=
:auto!important;direction:ltr!important;display:inline!important;color:blac=
k!important">,</code><code class=3D"" style=3D"border:0px!important;font-fa=
mily:Consolas,'Bitstream Vera Sans Mono','Courier New',Cour=
ier,monospace!important;font-weight:bold!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;height:auto!important;overflow:visible!=
important;width:auto!important;direction:ltr!important;display:inline!impor=
tant;color:gray!important">char</code> <code class=3D"" style=3D"border:0px=
!important;font-family:Consolas,'Bitstream Vera Sans Mono','Cou=
rier New',Courier,monospace!important;margin:0px!important;outline:0px!=
important;padding:0px!important;vertical-align:baseline!important;font-size=
:1em!important;line-height:1.1em!important;border-top-left-radius:0px!impor=
tant;border-top-right-radius:0px!important;border-bottom-right-radius:0px!i=
mportant;border-bottom-left-radius:0px!important;background-image:none!impo=
rtant;float:none!important;height:auto!important;overflow:visible!important=
;width:auto!important;direction:ltr!important;display:inline!important;colo=
r:black!important">**);</code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important">=A0=A0</code><code class=3D"" style=3D"bor=
der:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono',&=
#39;Courier New',Courier,monospace!important;font-weight:bold!important=
;margin:0px!important;outline:0px!important;padding:0px!important;vertical-=
align:baseline!important;font-size:1em!important;line-height:1.1em!importan=
t;border-top-left-radius:0px!important;border-top-right-radius:0px!importan=
t;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!im=
portant;background-image:none!important;float:none!important;height:auto!im=
portant;overflow:visible!important;width:auto!important;direction:ltr!impor=
tant;display:inline!important;color:rgb(0,102,153)!important">private</code=
><code class=3D"" style=3D"border:0px!important;font-family:Consolas,'B=
itstream Vera Sans Mono','Courier New',Courier,monospace!import=
ant;margin:0px!important;outline:0px!important;padding:0px!important;vertic=
al-align:baseline!important;font-size:1em!important;line-height:1.1em!impor=
tant;border-top-left-radius:0px!important;border-top-right-radius:0px!impor=
tant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px=
!important;background-image:none!important;float:none!important;height:auto=
!important;overflow:visible!important;width:auto!important;direction:ltr!im=
portant;display:inline!important;color:black!important">:</code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important">=A0=A0=A0=A0</code><code class=3D"" style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;margin:0px!importan=
t;outline:0px!important;padding:0px!important;vertical-align:baseline!impor=
tant;font-size:1em!important;line-height:1.1em!important;border-top-left-ra=
dius:0px!important;border-top-right-radius:0px!important;border-bottom-righ=
t-radius:0px!important;border-bottom-left-radius:0px!important;background-i=
mage:none!important;float:none!important;height:auto!important;overflow:vis=
ible!important;width:auto!important;direction:ltr!important;display:inline!=
important;color:black!important">raiicap(){}</code></div>
<div class=3D"" style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-=
size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!important;=
outline:0px!important;padding:0px 1em!important;vertical-align:baseline!imp=
ortant;border-top-left-radius:0px!important;border-top-right-radius:0px!imp=
ortant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0=
px!important;background-image:none!important;float:none!important;height:au=
to!important;overflow:visible!important;width:auto!important;direction:ltr!=
important;white-space:pre!important">
<code class=3D"" style=3D"border:0px!important;font-family:Consolas,'Bi=
tstream Vera Sans Mono','Courier New',Courier,monospace!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;height:auto!=
important;overflow:visible!important;width:auto!important;direction:ltr!imp=
ortant;display:inline!important;color:black!important">};</code></div>
</div><div><br></div><div style>My proposal thus is the addition of this ti=
ny raiicap template to the standard library.</div><div style><br></div><div=
style><br></div><div style>=A0</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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--20cf307f35fc85401204d8ef75d7--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 27 Mar 2013 18:03:43 -0700 (PDT)
Raw View
------=_Part_3143_12834731.1364432623748
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>
> A few months ago I wrote a blog post about a potential singleton
> alternative that I dubbed RAII-Caps (capability like references for access
> to the constructor of resource management (RAI) classes.
>
>
> http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/
>
> Although I'm rather embarrassed by the small size of the actual code
> needed for this proposal (a few lines only and small lines at that), I
> believe it may be an extremely modest useful addition to the standard
> library.
>
> template <typename T>
> class raiicap {
> public:
> friend int main(int,char **);
> private:
> raiicap(){}
> };
>
> My proposal thus is the addition of this tiny raiicap template to the
> standard library.
>
>
So you've developed a class that is only useful via dependency injection,
can only be used within the direct context of `main` (and only one version
of main at that), and in the end, it only provides *half* of the singleton
concept. And it doesn't even really do that, since `main` is perfectly
capable of constructing more than one of them.
There are far better ways to restrict the construction of an object
instance to one or more specific functions than this.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
------=_Part_3143_12834731.1364432623748
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>A few months ago I wrot=
e a blog post about a potential singleton alternative that I dubbed RAII-Ca=
ps (capability like references for access to the constructor of resource ma=
nagement (RAI) classes.</div>
<div><br></div><div><a href=3D"http://minorfs.wordpress.com/2013/01/18/raii=
cap-pattern-injected-singleton-alternative-for-c/" target=3D"_blank">http:/=
/minorfs.wordpress.com/<wbr>2013/01/18/raiicap-pattern-<wbr>injected-single=
ton-<wbr>alternative-for-c/</a><br>
</div><div><br></div>Although I'm rather embarrassed by the small=
size of the actual code needed for this proposal (a few lines only and sma=
ll lines at that), I believe it may be an extremely modest useful add=
ition to the standard library.<div>
<br></div><div><div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;co=
lor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px!=
important;padding:0px 1em!important;vertical-align:baseline!important;borde=
r-top-left-radius:0px!important;border-top-right-radius:0px!important;borde=
r-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important=
;background-image:none!important;float:none!important;min-height:auto!impor=
tant;overflow:visible!important;width:auto!important;direction:ltr!importan=
t;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;font-weight:bold!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;min-height:a=
uto!important;overflow:visible!important;width:auto!important;direction:ltr=
!important;display:inline!important;color:rgb(0,102,153)!important">templat=
e</code> <code style=3D"border:0px!important;font-family:Consolas,'Bitstrea=
m Vera Sans Mono','Courier New',Courier,monospace!important;margin:0px!impo=
rtant;outline:0px!important;padding:0px!important;vertical-align:baseline!i=
mportant;font-size:1em!important;line-height:1.1em!important;border-top-lef=
t-radius:0px!important;border-top-right-radius:0px!important;border-bottom-=
right-radius:0px!important;border-bottom-left-radius:0px!important;backgrou=
nd-image:none!important;float:none!important;min-height:auto!important;over=
flow:visible!important;width:auto!important;direction:ltr!important;display=
:inline!important;color:black!important"><</code><code style=3D"border:0=
px!important;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',=
Courier,monospace!important;font-weight:bold!important;margin:0px!important=
;outline:0px!important;padding:0px!important;vertical-align:baseline!import=
ant;font-size:1em!important;line-height:1.1em!important;border-top-left-rad=
ius:0px!important;border-top-right-radius:0px!important;border-bottom-right=
-radius:0px!important;border-bottom-left-radius:0px!important;background-im=
age:none!important;float:none!important;min-height:auto!important;overflow:=
visible!important;width:auto!important;direction:ltr!important;display:inli=
ne!important;color:rgb(0,102,153)!important">typename</code> <code style=3D=
"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono','Cour=
ier New',Courier,monospace!important;margin:0px!important;outline:0px!impor=
tant;padding:0px!important;vertical-align:baseline!important;font-size:1em!=
important;line-height:1.1em!important;border-top-left-radius:0px!important;=
border-top-right-radius:0px!important;border-bottom-right-radius:0px!import=
ant;border-bottom-left-radius:0px!important;background-image:none!important=
;float:none!important;min-height:auto!important;overflow:visible!important;=
width:auto!important;direction:ltr!important;display:inline!important;color=
:black!important">T></code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;font-weight:bold!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;min-height:a=
uto!important;overflow:visible!important;width:auto!important;direction:ltr=
!important;display:inline!important;color:rgb(0,102,153)!important">class</=
code> <code style=3D"border:0px!important;font-family:Consolas,'Bitstream V=
era Sans Mono','Courier New',Courier,monospace!important;margin:0px!importa=
nt;outline:0px!important;padding:0px!important;vertical-align:baseline!impo=
rtant;font-size:1em!important;line-height:1.1em!important;border-top-left-r=
adius:0px!important;border-top-right-radius:0px!important;border-bottom-rig=
ht-radius:0px!important;border-bottom-left-radius:0px!important;background-=
image:none!important;float:none!important;min-height:auto!important;overflo=
w:visible!important;width:auto!important;direction:ltr!important;display:in=
line!important;color:black!important">raiicap {</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!important;font-famil=
y:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!impor=
tant;font-weight:bold!important;margin:0px!important;outline:0px!important;=
padding:0px!important;vertical-align:baseline!important;font-size:1em!impor=
tant;line-height:1.1em!important;border-top-left-radius:0px!important;borde=
r-top-right-radius:0px!important;border-bottom-right-radius:0px!important;b=
order-bottom-left-radius:0px!important;background-image:none!important;floa=
t:none!important;min-height:auto!important;overflow:visible!important;width=
:auto!important;direction:ltr!important;display:inline!important;color:rgb(=
0,102,153)!important">public</code><code style=3D"border:0px!important;font=
-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace=
!important;margin:0px!important;outline:0px!important;padding:0px!important=
;vertical-align:baseline!important;font-size:1em!important;line-height:1.1e=
m!important;border-top-left-radius:0px!important;border-top-right-radius:0p=
x!important;border-bottom-right-radius:0px!important;border-bottom-left-rad=
ius:0px!important;background-image:none!important;float:none!important;min-=
height:auto!important;overflow:visible!important;width:auto!important;direc=
tion:ltr!important;display:inline!important;color:black!important">:</code>=
</div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!importan=
t;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;font-weight:bold!important;margin:0px!important;outline:0p=
x!important;padding:0px!important;vertical-align:baseline!important;font-si=
ze:1em!important;line-height:1.1em!important;border-top-left-radius:0px!imp=
ortant;border-top-right-radius:0px!important;border-bottom-right-radius:0px=
!important;border-bottom-left-radius:0px!important;background-image:none!im=
portant;float:none!important;min-height:auto!important;overflow:visible!imp=
ortant;width:auto!important;direction:ltr!important;display:inline!importan=
t;color:rgb(0,102,153)!important">friend</code> <code style=3D"border:0px!i=
mportant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Cour=
ier,monospace!important;font-weight:bold!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant;color:gray!important">int</code> <code style=3D"border:0px!importa=
nt;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mo=
nospace!important;margin:0px!important;outline:0px!important;padding:0px!im=
portant;vertical-align:baseline!important;font-size:1em!important;line-heig=
ht:1.1em!important;border-top-left-radius:0px!important;border-top-right-ra=
dius:0px!important;border-bottom-right-radius:0px!important;border-bottom-l=
eft-radius:0px!important;background-image:none!important;float:none!importa=
nt;min-height:auto!important;overflow:visible!important;width:auto!importan=
t;direction:ltr!important;display:inline!important;color:black!important">m=
ain(</code><code style=3D"border:0px!important;font-family:Consolas,'Bitstr=
eam Vera Sans Mono','Courier New',Courier,monospace!important;font-weight:b=
old!important;margin:0px!important;outline:0px!important;padding:0px!import=
ant;vertical-align:baseline!important;font-size:1em!important;line-height:1=
..1em!important;border-top-left-radius:0px!important;border-top-right-radius=
:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-=
radius:0px!important;background-image:none!important;float:none!important;m=
in-height:auto!important;overflow:visible!important;width:auto!important;di=
rection:ltr!important;display:inline!important;color:gray!important">int</c=
ode><code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0px!important=
;outline:0px!important;padding:0px!important;vertical-align:baseline!import=
ant;font-size:1em!important;line-height:1.1em!important;border-top-left-rad=
ius:0px!important;border-top-right-radius:0px!important;border-bottom-right=
-radius:0px!important;border-bottom-left-radius:0px!important;background-im=
age:none!important;float:none!important;min-height:auto!important;overflow:=
visible!important;width:auto!important;direction:ltr!important;display:inli=
ne!important;color:black!important">,</code><code style=3D"border:0px!impor=
tant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,=
monospace!important;font-weight:bold!important;margin:0px!important;outline=
:0px!important;padding:0px!important;vertical-align:baseline!important;font=
-size:1em!important;line-height:1.1em!important;border-top-left-radius:0px!=
important;border-top-right-radius:0px!important;border-bottom-right-radius:=
0px!important;border-bottom-left-radius:0px!important;background-image:none=
!important;float:none!important;min-height:auto!important;overflow:visible!=
important;width:auto!important;direction:ltr!important;display:inline!impor=
tant;color:gray!important">char</code> <code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monos=
pace!important;margin:0px!important;outline:0px!important;padding:0px!impor=
tant;vertical-align:baseline!important;font-size:1em!important;line-height:=
1.1em!important;border-top-left-radius:0px!important;border-top-right-radiu=
s:0px!important;border-bottom-right-radius:0px!important;border-bottom-left=
-radius:0px!important;background-image:none!important;float:none!important;=
min-height:auto!important;overflow:visible!important;width:auto!important;d=
irection:ltr!important;display:inline!important;color:black!important">**);=
</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!important;font-famil=
y:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!impor=
tant;font-weight:bold!important;margin:0px!important;outline:0px!important;=
padding:0px!important;vertical-align:baseline!important;font-size:1em!impor=
tant;line-height:1.1em!important;border-top-left-radius:0px!important;borde=
r-top-right-radius:0px!important;border-bottom-right-radius:0px!important;b=
order-bottom-left-radius:0px!important;background-image:none!important;floa=
t:none!important;min-height:auto!important;overflow:visible!important;width=
:auto!important;direction:ltr!important;display:inline!important;color:rgb(=
0,102,153)!important">private</code><code style=3D"border:0px!important;fon=
t-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospac=
e!important;margin:0px!important;outline:0px!important;padding:0px!importan=
t;vertical-align:baseline!important;font-size:1em!important;line-height:1.1=
em!important;border-top-left-radius:0px!important;border-top-right-radius:0=
px!important;border-bottom-right-radius:0px!important;border-bottom-left-ra=
dius:0px!important;background-image:none!important;float:none!important;min=
-height:auto!important;overflow:visible!important;width:auto!important;dire=
ction:ltr!important;display:inline!important;color:black!important">:</code=
></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!importan=
t;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;margin:0px!important;outline:0px!important;padding:0px!imp=
ortant;vertical-align:baseline!important;font-size:1em!important;line-heigh=
t:1.1em!important;border-top-left-radius:0px!important;border-top-right-rad=
ius:0px!important;border-bottom-right-radius:0px!important;border-bottom-le=
ft-radius:0px!important;background-image:none!important;float:none!importan=
t;min-height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;display:inline!important;color:black!important">ra=
iicap(){}</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant;color:black!important">};</code></div>
</div><div><br></div><div>My proposal thus is the addition of this tiny rai=
icap template to the standard library.<br></div><br></div></blockquote><div=
><br>So you've developed a class that is only useful via dependency injecti=
on, can only be used within the direct context of `main` (and only one vers=
ion of main at that), and in the end, it only provides <i>half</i> of the s=
ingleton concept. And it doesn't even really do that, since `main` is perfe=
ctly capable of constructing more than one of them.<br><br>There are far be=
tter ways to restrict the construction of an object instance to one or more=
specific functions than this.<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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_3143_12834731.1364432623748--
.
Author: Lawrence Crowl <crowl@googlers.com>
Date: Wed, 27 Mar 2013 18:44:00 -0700
Raw View
On 3/27/13, Nicol Bolas <jmckesson@gmail.com> wrote:
> On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>>
>> A few months ago I wrote a blog post about a potential singleton
>> alternative that I dubbed RAII-Caps (capability like references for access
>>
>> to the constructor of resource management (RAI) classes.
>>
>>
>> http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/
>>
>> Although I'm rather embarrassed by the small size of the actual code
>> needed for this proposal (a few lines only and small lines at that), I
>> believe it may be an extremely modest useful addition to the standard
>> library.
>>
>> template <typename T>
>> class raiicap {
>> public:
>> friend int main(int,char **);
>> private:
>> raiicap(){}
>> };
>>
>> My proposal thus is the addition of this tiny raiicap template to the
>> standard library.
>
> So you've developed a class that is only useful via dependency injection,
> can only be used within the direct context of `main` (and only one version
> of main at that), and in the end, it only provides *half* of the singleton
> concept. And it doesn't even really do that, since `main` is perfectly
> capable of constructing more than one of them.
>
> There are far better ways to restrict the construction of an object
> instance to one or more specific functions than this.
Please elaborate.
--
Lawrence Crowl
--
---
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/?hl=en.
.
Author: Rob Meijer <pibara@gmail.com>
Date: Thu, 28 Mar 2013 06:20:13 +0100
Raw View
--485b397dd3ab35583a04d8f54f0f
Content-Type: text/plain; charset=ISO-8859-1
2013/3/28 Nicol Bolas <jmckesson@gmail.com>
> On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>>
>> A few months ago I wrote a blog post about a potential singleton
>> alternative that I dubbed RAII-Caps (capability like references for access
>> to the constructor of resource management (RAI) classes.
>>
>> http://minorfs.wordpress.com/**2013/01/18/raiicap-pattern-**
>> injected-singleton-**alternative-for-c/<http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/>
>>
>> Although I'm rather embarrassed by the small size of the actual code
>> needed for this proposal (a few lines only and small lines at that), I
>> believe it may be an extremely modest useful addition to the standard
>> library.
>>
>> template <typename T>
>> class raiicap {
>> public:
>> friend int main(int,char **);
>> private:
>> raiicap(){}
>> };
>>
>> My proposal thus is the addition of this tiny raiicap template to the
>> standard library.
>>
>>
> So you've developed a class that is only useful via dependency injection,
> can only be used within the direct context of `main` (and only one version
> of main at that), and in the end, it only provides *half* of the
> singleton concept. And it doesn't even really do that, since `main` is
> perfectly capable of constructing more than one of them.
>
>
The concept is that main, using this simple template class can be made the
'initial source of authority' for constructing RAII objects
for scares resources. It can not "only be USED within the direct context of
`main`", it's a token of authority that can only ORIGINATE within the
direct context of `main` from where it can be discretionary delegated to
other parts of the program, for example an object who's responsibility it
is to instantiate only a single instance, or even to instantiate only a
single instance AND provide a global access point to it.
> There are far better ways to restrict the construction of an object
> instance to one or more specific functions than this.
>
Could you elaborate?
>
>
> ---
> 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/?hl=en.
>
>
>
--
---
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/?hl=en.
--485b397dd3ab35583a04d8f54f0f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">2013/3/28 Nicol Bolas <span dir=3D"ltr"><<a href=3D"mailto:jmcke=
sson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>></span><br><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padd=
ing-left:1ex">
<div class=3D""><div class=3D"h5">On Wednesday, March 27, 2013 3:21:27 PM U=
TC-7, pibara wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border=
-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div>A few months ago I wrote a blog post about a potentia=
l singleton alternative that I dubbed RAII-Caps (capability like references=
for access to the constructor of resource management (RAI) classes.</div>
<div><br></div><div><a href=3D"http://minorfs.wordpress.com/2013/01/18/raii=
cap-pattern-injected-singleton-alternative-for-c/" target=3D"_blank">http:/=
/minorfs.wordpress.com/<u></u>2013/01/18/raiicap-pattern-<u></u>injected-si=
ngleton-<u></u>alternative-for-c/</a><br>
</div><div><br></div>Although I'm rather=A0embarrassed=A0by the small s=
ize of the actual code needed for this proposal (a few lines only and small=
lines at that), I believe it may be an extremely =A0modest useful addition=
to the standard library.<div>
<br></div><div><div style=3D"font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace;line-height:15.390625px;f=
ont-size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!import=
ant;outline:0px!important;padding:0px 1em!important;vertical-align:baseline=
!important;border-top-left-radius:0px!important;border-top-right-radius:0px=
!important;border-bottom-right-radius:0px!important;border-bottom-left-radi=
us:0px!important;background-image:none!important;float:none!important;min-h=
eight:auto!important;overflow:visible!important;width:auto!important;direct=
ion:ltr!important;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">template</code> <code style=3D"border:0px!important;font-family:Co=
nsolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;margin:0px!important;outline:0px!important;padding:0px!imp=
ortant;vertical-align:baseline!important;font-size:1em!important;line-heigh=
t:1.1em!important;border-top-left-radius:0px!important;border-top-right-rad=
ius:0px!important;border-bottom-right-radius:0px!important;border-bottom-le=
ft-radius:0px!important;background-image:none!important;float:none!importan=
t;min-height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;display:inline!important;color:black!important">&l=
t;</code><code style=3D"border:0px!important;font-family:Consolas,'Bits=
tream Vera Sans Mono','Courier New',Courier,monospace!important=
;font-weight:bold!important;margin:0px!important;outline:0px!important;padd=
ing:0px!important;vertical-align:baseline!important;font-size:1em!important=
;line-height:1.1em!important;border-top-left-radius:0px!important;border-to=
p-right-radius:0px!important;border-bottom-right-radius:0px!important;borde=
r-bottom-left-radius:0px!important;background-image:none!important;float:no=
ne!important;min-height:auto!important;overflow:visible!important;width:aut=
o!important;direction:ltr!important;display:inline!important;color:rgb(0,10=
2,153)!important">typename</code> <code style=3D"border:0px!important;font-=
family:Consolas,'Bitstream Vera Sans Mono','Courier New',Co=
urier,monospace!important;margin:0px!important;outline:0px!important;paddin=
g:0px!important;vertical-align:baseline!important;font-size:1em!important;l=
ine-height:1.1em!important;border-top-left-radius:0px!important;border-top-=
right-radius:0px!important;border-bottom-right-radius:0px!important;border-=
bottom-left-radius:0px!important;background-image:none!important;float:none=
!important;min-height:auto!important;overflow:visible!important;width:auto!=
important;direction:ltr!important;display:inline!important;color:black!impo=
rtant">T></code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">class</code> <code style=3D"border:0px!important;font-family:Conso=
las,'Bitstream Vera Sans Mono','Courier New',Courier,monosp=
ace!important;margin:0px!important;outline:0px!important;padding:0px!import=
ant;vertical-align:baseline!important;font-size:1em!important;line-height:1=
..1em!important;border-top-left-radius:0px!important;border-top-right-radius=
:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-=
radius:0px!important;background-image:none!important;float:none!important;m=
in-height:auto!important;overflow:visible!important;width:auto!important;di=
rection:ltr!important;display:inline!important;color:black!important">raiic=
ap {</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">public</code><code style=3D=
"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
9;,'Courier New',Courier,monospace!important;margin:0px!important;o=
utline:0px!important;padding:0px!important;vertical-align:baseline!importan=
t;font-size:1em!important;line-height:1.1em!important;border-top-left-radiu=
s:0px!important;border-top-right-radius:0px!important;border-bottom-right-r=
adius:0px!important;border-bottom-left-radius:0px!important;background-imag=
e:none!important;float:none!important;min-height:auto!important;overflow:vi=
sible!important;width:auto!important;direction:ltr!important;display:inline=
!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;font-weight:bold!important;margin:0px!=
important;outline:0px!important;padding:0px!important;vertical-align:baseli=
ne!important;font-size:1em!important;line-height:1.1em!important;border-top=
-left-radius:0px!important;border-top-right-radius:0px!important;border-bot=
tom-right-radius:0px!important;border-bottom-left-radius:0px!important;back=
ground-image:none!important;float:none!important;min-height:auto!important;=
overflow:visible!important;width:auto!important;direction:ltr!important;dis=
play:inline!important;color:rgb(0,102,153)!important">friend</code> <code s=
tyle=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace!important;font-weight:bol=
d!important;margin:0px!important;outline:0px!important;padding:0px!importan=
t;vertical-align:baseline!important;font-size:1em!important;line-height:1.1=
em!important;border-top-left-radius:0px!important;border-top-right-radius:0=
px!important;border-bottom-right-radius:0px!important;border-bottom-left-ra=
dius:0px!important;background-image:none!important;float:none!important;min=
-height:auto!important;overflow:visible!important;width:auto!important;dire=
ction:ltr!important;display:inline!important;color:gray!important">int</cod=
e> <code style=3D"border:0px!important;font-family:Consolas,'Bitstream =
Vera Sans Mono','Courier New',Courier,monospace!important;margi=
n:0px!important;outline:0px!important;padding:0px!important;vertical-align:=
baseline!important;font-size:1em!important;line-height:1.1em!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;display:inline!important;color:black!important">main(</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;font-weight:bold!im=
portant;margin:0px!important;outline:0px!important;padding:0px!important;ve=
rtical-align:baseline!important;font-size:1em!important;line-height:1.1em!i=
mportant;border-top-left-radius:0px!important;border-top-right-radius:0px!i=
mportant;border-bottom-right-radius:0px!important;border-bottom-left-radius=
:0px!important;background-image:none!important;float:none!important;min-hei=
ght:auto!important;overflow:visible!important;width:auto!important;directio=
n:ltr!important;display:inline!important;color:gray!important">int</code><c=
ode style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera =
Sans Mono','Courier New',Courier,monospace!important;margin:0px=
!important;outline:0px!important;padding:0px!important;vertical-align:basel=
ine!important;font-size:1em!important;line-height:1.1em!important;border-to=
p-left-radius:0px!important;border-top-right-radius:0px!important;border-bo=
ttom-right-radius:0px!important;border-bottom-left-radius:0px!important;bac=
kground-image:none!important;float:none!important;min-height:auto!important=
;overflow:visible!important;width:auto!important;direction:ltr!important;di=
splay:inline!important;color:black!important">,</code><code style=3D"border=
:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono','=
;Courier New',Courier,monospace!important;font-weight:bold!important;ma=
rgin:0px!important;outline:0px!important;padding:0px!important;vertical-ali=
gn:baseline!important;font-size:1em!important;line-height:1.1em!important;b=
order-top-left-radius:0px!important;border-top-right-radius:0px!important;b=
order-bottom-right-radius:0px!important;border-bottom-left-radius:0px!impor=
tant;background-image:none!important;float:none!important;min-height:auto!i=
mportant;overflow:visible!important;width:auto!important;direction:ltr!impo=
rtant;display:inline!important;color:gray!important">char</code> <code styl=
e=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mon=
o','Courier New',Courier,monospace!important;margin:0px!importa=
nt;outline:0px!important;padding:0px!important;vertical-align:baseline!impo=
rtant;font-size:1em!important;line-height:1.1em!important;border-top-left-r=
adius:0px!important;border-top-right-radius:0px!important;border-bottom-rig=
ht-radius:0px!important;border-bottom-left-radius:0px!important;background-=
image:none!important;float:none!important;min-height:auto!important;overflo=
w:visible!important;width:auto!important;direction:ltr!important;display:in=
line!important;color:black!important">**);</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">private</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;margin:0px!importan=
t;outline:0px!important;padding:0px!important;vertical-align:baseline!impor=
tant;font-size:1em!important;line-height:1.1em!important;border-top-left-ra=
dius:0px!important;border-top-right-radius:0px!important;border-bottom-righ=
t-radius:0px!important;border-bottom-left-radius:0px!important;background-i=
mage:none!important;float:none!important;min-height:auto!important;overflow=
:visible!important;width:auto!important;direction:ltr!important;display:inl=
ine!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;margin:0px!important;outline:0px!impor=
tant;padding:0px!important;vertical-align:baseline!important;font-size:1em!=
important;line-height:1.1em!important;border-top-left-radius:0px!important;=
border-top-right-radius:0px!important;border-bottom-right-radius:0px!import=
ant;border-bottom-left-radius:0px!important;background-image:none!important=
;float:none!important;min-height:auto!important;overflow:visible!important;=
width:auto!important;direction:ltr!important;display:inline!important;color=
:black!important">raiicap(){}</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important;color:black!important">};</code></div>
</div><div><br></div><div>My proposal thus is the addition of this tiny rai=
icap template to the standard library.<br></div><br></div></blockquote></di=
v></div><div><br>So you've developed a class that is only useful via de=
pendency injection, can only be used within the direct context of `main` (a=
nd only one version of main at that), and in the end, it only provides <i>h=
alf</i> of the singleton concept. And it doesn't even really do that, s=
ince `main` is perfectly capable of constructing more than one of them.<br>
<br></div></blockquote><div><br></div><div style>The concept is that main, =
using this simple template class can be made the 'initial source of aut=
hority' for constructing RAII objects for=A0scares=A0resources. It can =
not "only be USED within the direct context of `main`", it's =
a token of authority that can only ORIGINATE within the direct context of `=
main` from where it can be discretionary delegated to other parts of the pr=
ogram, for example an object who's responsibility it is to instantiate =
only a single instance, or even=A0to instantiate only a single instance AND=
provide a global=A0access=A0point to it.</div>
<div style>=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);b=
order-left-style:solid;padding-left:1ex"><div>There are far better ways to =
restrict the construction of an object instance to one or more specific fun=
ctions than this.</div>
</blockquote><div><br></div><div style>Could you elaborate?</div><div><br><=
/div><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border=
-left-style:solid;padding-left:1ex">
<div><span style=3D"color:rgb(136,136,136)">=A0</span></div><span class=3D"=
"><font color=3D"#888888">
=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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=A0<br>
=A0<br>
</font></span></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--485b397dd3ab35583a04d8f54f0f--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 28 Mar 2013 02:10:04 -0700 (PDT)
Raw View
------=_Part_828_15713586.1364461804558
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:
>
>
>
>
> 2013/3/28 Nicol Bolas <jmck...@gmail.com <javascript:>>
>
>> On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>>>
>>> A few months ago I wrote a blog post about a potential singleton
>>> alternative that I dubbed RAII-Caps (capability like references for access
>>> to the constructor of resource management (RAI) classes.
>>>
>>> http://minorfs.wordpress.com/**2013/01/18/raiicap-pattern-**
>>> injected-singleton-**alternative-for-c/<http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/>
>>>
>>> Although I'm rather embarrassed by the small size of the actual code
>>> needed for this proposal (a few lines only and small lines at that), I
>>> believe it may be an extremely modest useful addition to the standard
>>> library.
>>>
>>> template <typename T>
>>> class raiicap {
>>> public:
>>> friend int main(int,char **);
>>> private:
>>> raiicap(){}
>>> };
>>>
>>> My proposal thus is the addition of this tiny raiicap template to the
>>> standard library.
>>>
>>>
>> So you've developed a class that is only useful via dependency injection,
>> can only be used within the direct context of `main` (and only one version
>> of main at that), and in the end, it only provides *half* of the
>> singleton concept. And it doesn't even really do that, since `main` is
>> perfectly capable of constructing more than one of them.
>>
>>
> The concept is that main, using this simple template class can be made the
> 'initial source of authority' for constructing RAII objects
> for scares resources. It can not "only be USED within the direct context of
> `main`", it's a token of authority that can only ORIGINATE within the
> direct context of `main` from where it can be discretionary delegated to
> other parts of the program, for example an object who's responsibility it
> is to instantiate only a single instance, or even to instantiate only a
> single instance AND provide a global access point to it.
>
When I said that it "can only be used within the direct context of `main`,"
I meant `raiicap`, not the classes that use it. You can't do anything with
`raiicap` outside of `main`. And again, this only works with one version of
`main`.
I understand quite well what you're trying to do. I'm saying that not
everyone *wants* singletons to be allocated by `main`. And what of code
that uses `int main()`, which is just as standard C++ as `int main(int
argc, const char *argv)`? There's also a fair amount of code out there that
doesn't use `main` at all; either they're using `WinMain` or they're being
called by some other library that *itself* uses `main`. You're effectively
saying that none of this code can use your helper class.
If a significant number of C++ users would have to invent their own version
of `raiicap` in order to use the arbitrary, then what good is it? If a user
cannot force `raiicap` to use a specific function, rather than just one
form of `main`, then you've limited the use cases for this tools a lot.
And what of the people who want to split up their `main` functions, perhaps
because they're getting rather big? What if it's more natural to put that
initialization in some other function that's called by `main`?
Main is not the center of everyone's universe. Your tool is too
restrictive. And C++ doesn't offer a way to generalize it to a
user-provided function without employing macros. So I don't think it's a
good tool.
There are far better ways to restrict the construction of an object
>> instance to one or more specific functions than this.
>>
>
> Could you elaborate?
>
The same way you're doing it here, only without an intermediate,
dependency-injected object. Make the class's constructors of interest
private and make the "one or more specific functions" that can allocate
them friends.
That way, it is the writer of the class who gets to decide which functions
get to create it. You're not limited to one specific form of `main`.
--
---
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/?hl=en.
------=_Part_828_15713586.1364461804558
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div><br><br><div class=
=3D"gmail_quote">2013/3/28 Nicol Bolas <span dir=3D"ltr"><<a href=3D"jav=
ascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"0I1Bplq6QucJ">jmck...@=
gmail.com</a>></span><br><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,20=
4);border-left-style:solid;padding-left:1ex">
<div><div>On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-=
width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddin=
g-left:1ex">
<div dir=3D"ltr"><div>A few months ago I wrote a blog post about a potentia=
l singleton alternative that I dubbed RAII-Caps (capability like references=
for access to the constructor of resource management (RAI) classes.</div>
<div><br></div><div><a href=3D"http://minorfs.wordpress.com/2013/01/18/raii=
cap-pattern-injected-singleton-alternative-for-c/" target=3D"_blank">http:/=
/minorfs.wordpress.com/<u></u>2<wbr>013/01/18/raiicap-pattern-<u></u>inje<w=
br>cted-singleton-<u></u>alternative-<wbr>for-c/</a><br>
</div><div><br></div>Although I'm rather embarrassed by the small=
size of the actual code needed for this proposal (a few lines only and sma=
ll lines at that), I believe it may be an extremely modest useful add=
ition to the standard library.<div>
<br></div><div><div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;co=
lor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px!=
important;padding:0px 1em!important;vertical-align:baseline!important;borde=
r-top-left-radius:0px!important;border-top-right-radius:0px!important;borde=
r-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important=
;background-image:none!important;float:none!important;min-height:auto!impor=
tant;overflow:visible!important;width:auto!important;direction:ltr!importan=
t;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;font-weight:bold!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;min-height:a=
uto!important;overflow:visible!important;width:auto!important;direction:ltr=
!important;display:inline!important;color:rgb(0,102,153)!important">templat=
e</code> <code style=3D"border:0px!important;font-family:Consolas,'Bitstrea=
m Vera Sans Mono','Courier New',Courier,monospace!important;margin:0px!impo=
rtant;outline:0px!important;padding:0px!important;vertical-align:baseline!i=
mportant;font-size:1em!important;line-height:1.1em!important;border-top-lef=
t-radius:0px!important;border-top-right-radius:0px!important;border-bottom-=
right-radius:0px!important;border-bottom-left-radius:0px!important;backgrou=
nd-image:none!important;float:none!important;min-height:auto!important;over=
flow:visible!important;width:auto!important;direction:ltr!important;display=
:inline!important;color:black!important"><</code><code style=3D"border:0=
px!important;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',=
Courier,monospace!important;font-weight:bold!important;margin:0px!important=
;outline:0px!important;padding:0px!important;vertical-align:baseline!import=
ant;font-size:1em!important;line-height:1.1em!important;border-top-left-rad=
ius:0px!important;border-top-right-radius:0px!important;border-bottom-right=
-radius:0px!important;border-bottom-left-radius:0px!important;background-im=
age:none!important;float:none!important;min-height:auto!important;overflow:=
visible!important;width:auto!important;direction:ltr!important;display:inli=
ne!important;color:rgb(0,102,153)!important">typename</code> <code style=3D=
"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono','Cour=
ier New',Courier,monospace!important;margin:0px!important;outline:0px!impor=
tant;padding:0px!important;vertical-align:baseline!important;font-size:1em!=
important;line-height:1.1em!important;border-top-left-radius:0px!important;=
border-top-right-radius:0px!important;border-bottom-right-radius:0px!import=
ant;border-bottom-left-radius:0px!important;background-image:none!important=
;float:none!important;min-height:auto!important;overflow:visible!important;=
width:auto!important;direction:ltr!important;display:inline!important;color=
:black!important">T></code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;font-weight:bold!importa=
nt;margin:0px!important;outline:0px!important;padding:0px!important;vertica=
l-align:baseline!important;font-size:1em!important;line-height:1.1em!import=
ant;border-top-left-radius:0px!important;border-top-right-radius:0px!import=
ant;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!=
important;background-image:none!important;float:none!important;min-height:a=
uto!important;overflow:visible!important;width:auto!important;direction:ltr=
!important;display:inline!important;color:rgb(0,102,153)!important">class</=
code> <code style=3D"border:0px!important;font-family:Consolas,'Bitstream V=
era Sans Mono','Courier New',Courier,monospace!important;margin:0px!importa=
nt;outline:0px!important;padding:0px!important;vertical-align:baseline!impo=
rtant;font-size:1em!important;line-height:1.1em!important;border-top-left-r=
adius:0px!important;border-top-right-radius:0px!important;border-bottom-rig=
ht-radius:0px!important;border-bottom-left-radius:0px!important;background-=
image:none!important;float:none!important;min-height:auto!important;overflo=
w:visible!important;width:auto!important;direction:ltr!important;display:in=
line!important;color:black!important">raiicap {</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!important;font-famil=
y:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!impor=
tant;font-weight:bold!important;margin:0px!important;outline:0px!important;=
padding:0px!important;vertical-align:baseline!important;font-size:1em!impor=
tant;line-height:1.1em!important;border-top-left-radius:0px!important;borde=
r-top-right-radius:0px!important;border-bottom-right-radius:0px!important;b=
order-bottom-left-radius:0px!important;background-image:none!important;floa=
t:none!important;min-height:auto!important;overflow:visible!important;width=
:auto!important;direction:ltr!important;display:inline!important;color:rgb(=
0,102,153)!important">public</code><code style=3D"border:0px!important;font=
-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace=
!important;margin:0px!important;outline:0px!important;padding:0px!important=
;vertical-align:baseline!important;font-size:1em!important;line-height:1.1e=
m!important;border-top-left-radius:0px!important;border-top-right-radius:0p=
x!important;border-bottom-right-radius:0px!important;border-bottom-left-rad=
ius:0px!important;background-image:none!important;float:none!important;min-=
height:auto!important;overflow:visible!important;width:auto!important;direc=
tion:ltr!important;display:inline!important;color:black!important">:</code>=
</div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!importan=
t;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;font-weight:bold!important;margin:0px!important;outline:0p=
x!important;padding:0px!important;vertical-align:baseline!important;font-si=
ze:1em!important;line-height:1.1em!important;border-top-left-radius:0px!imp=
ortant;border-top-right-radius:0px!important;border-bottom-right-radius:0px=
!important;border-bottom-left-radius:0px!important;background-image:none!im=
portant;float:none!important;min-height:auto!important;overflow:visible!imp=
ortant;width:auto!important;direction:ltr!important;display:inline!importan=
t;color:rgb(0,102,153)!important">friend</code> <code style=3D"border:0px!i=
mportant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Cour=
ier,monospace!important;font-weight:bold!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant;color:gray!important">int</code> <code style=3D"border:0px!importa=
nt;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mo=
nospace!important;margin:0px!important;outline:0px!important;padding:0px!im=
portant;vertical-align:baseline!important;font-size:1em!important;line-heig=
ht:1.1em!important;border-top-left-radius:0px!important;border-top-right-ra=
dius:0px!important;border-bottom-right-radius:0px!important;border-bottom-l=
eft-radius:0px!important;background-image:none!important;float:none!importa=
nt;min-height:auto!important;overflow:visible!important;width:auto!importan=
t;direction:ltr!important;display:inline!important;color:black!important">m=
ain(</code><code style=3D"border:0px!important;font-family:Consolas,'Bitstr=
eam Vera Sans Mono','Courier New',Courier,monospace!important;font-weight:b=
old!important;margin:0px!important;outline:0px!important;padding:0px!import=
ant;vertical-align:baseline!important;font-size:1em!important;line-height:1=
..1em!important;border-top-left-radius:0px!important;border-top-right-radius=
:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-=
radius:0px!important;background-image:none!important;float:none!important;m=
in-height:auto!important;overflow:visible!important;width:auto!important;di=
rection:ltr!important;display:inline!important;color:gray!important">int</c=
ode><code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0px!important=
;outline:0px!important;padding:0px!important;vertical-align:baseline!import=
ant;font-size:1em!important;line-height:1.1em!important;border-top-left-rad=
ius:0px!important;border-top-right-radius:0px!important;border-bottom-right=
-radius:0px!important;border-bottom-left-radius:0px!important;background-im=
age:none!important;float:none!important;min-height:auto!important;overflow:=
visible!important;width:auto!important;direction:ltr!important;display:inli=
ne!important;color:black!important">,</code><code style=3D"border:0px!impor=
tant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,=
monospace!important;font-weight:bold!important;margin:0px!important;outline=
:0px!important;padding:0px!important;vertical-align:baseline!important;font=
-size:1em!important;line-height:1.1em!important;border-top-left-radius:0px!=
important;border-top-right-radius:0px!important;border-bottom-right-radius:=
0px!important;border-bottom-left-radius:0px!important;background-image:none=
!important;float:none!important;min-height:auto!important;overflow:visible!=
important;width:auto!important;direction:ltr!important;display:inline!impor=
tant;color:gray!important">char</code> <code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monos=
pace!important;margin:0px!important;outline:0px!important;padding:0px!impor=
tant;vertical-align:baseline!important;font-size:1em!important;line-height:=
1.1em!important;border-top-left-radius:0px!important;border-top-right-radiu=
s:0px!important;border-bottom-right-radius:0px!important;border-bottom-left=
-radius:0px!important;background-image:none!important;float:none!important;=
min-height:auto!important;overflow:visible!important;width:auto!important;d=
irection:ltr!important;display:inline!important;color:black!important">**);=
</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!important;font-famil=
y:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!impor=
tant;font-weight:bold!important;margin:0px!important;outline:0px!important;=
padding:0px!important;vertical-align:baseline!important;font-size:1em!impor=
tant;line-height:1.1em!important;border-top-left-radius:0px!important;borde=
r-top-right-radius:0px!important;border-bottom-right-radius:0px!important;b=
order-bottom-left-radius:0px!important;background-image:none!important;floa=
t:none!important;min-height:auto!important;overflow:visible!important;width=
:auto!important;direction:ltr!important;display:inline!important;color:rgb(=
0,102,153)!important">private</code><code style=3D"border:0px!important;fon=
t-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospac=
e!important;margin:0px!important;outline:0px!important;padding:0px!importan=
t;vertical-align:baseline!important;font-size:1em!important;line-height:1.1=
em!important;border-top-left-radius:0px!important;border-top-right-radius:0=
px!important;border-bottom-right-radius:0px!important;border-bottom-left-ra=
dius:0px!important;background-image:none!important;float:none!important;min=
-height:auto!important;overflow:visible!important;width:auto!important;dire=
ction:ltr!important;display:inline!important;color:black!important">:</code=
></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant"> </code><code style=3D"border:0px!importan=
t;font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;margin:0px!important;outline:0px!important;padding:0px!imp=
ortant;vertical-align:baseline!important;font-size:1em!important;line-heigh=
t:1.1em!important;border-top-left-radius:0px!important;border-top-right-rad=
ius:0px!important;border-bottom-right-radius:0px!important;border-bottom-le=
ft-radius:0px!important;background-image:none!important;float:none!importan=
t;min-height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;display:inline!important;color:black!important">ra=
iicap(){}</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','Courier New'=
,Courier,monospace;line-height:15.390625px;font-size:14px;color:rgb(255,236=
,208);border:0px!important;margin:0px!important;outline:0px!important;paddi=
ng:0px 1em!important;vertical-align:baseline!important;border-top-left-radi=
us:0px!important;border-top-right-radius:0px!important;border-bottom-right-=
radius:0px!important;border-bottom-left-radius:0px!important;background-ima=
ge:none!important;float:none!important;min-height:auto!important;overflow:v=
isible!important;width:auto!important;direction:ltr!important;white-space:p=
re!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sa=
ns Mono','Courier New',Courier,monospace!important;margin:0px!important;out=
line:0px!important;padding:0px!important;vertical-align:baseline!important;=
font-size:1em!important;line-height:1.1em!important;border-top-left-radius:=
0px!important;border-top-right-radius:0px!important;border-bottom-right-rad=
ius:0px!important;border-bottom-left-radius:0px!important;background-image:=
none!important;float:none!important;min-height:auto!important;overflow:visi=
ble!important;width:auto!important;direction:ltr!important;display:inline!i=
mportant;color:black!important">};</code></div>
</div><div><br></div><div>My proposal thus is the addition of this tiny rai=
icap template to the standard library.<br></div><br></div></blockquote></di=
v></div><div><br>So you've developed a class that is only useful via depend=
ency injection, can only be used within the direct context of `main` (and o=
nly one version of main at that), and in the end, it only provides <i>half<=
/i> of the singleton concept. And it doesn't even really do that, since `ma=
in` is perfectly capable of constructing more than one of them.<br>
<br></div></blockquote><div><br></div><div>The concept is that main, using =
this simple template class can be made the 'initial source of authority' fo=
r constructing RAII objects for scares resources. It can not "onl=
y be USED within the direct context of `main`", it's a token of authority t=
hat can only ORIGINATE within the direct context of `main` from where it ca=
n be discretionary delegated to other parts of the program, for example an =
object who's responsibility it is to instantiate only a single instance, or=
even to instantiate only a single instance AND provide a global =
access point to it.</div></div></div></div></blockquote><div><br>When =
I said that it "can only be used within the direct context of `main`," I me=
ant `raiicap`, not the classes that use it. You can't do anything with `rai=
icap` outside of `main`. And again, this only works with one version of `ma=
in`.<br><br>I understand quite well what you're trying to do. I'm saying th=
at not everyone <i>wants</i> singletons to be allocated by `main`. And what=
of code that uses `int main()`, which is just as standard C++ as `int main=
(int argc, const char *argv)`? There's also a fair amount of code out there=
that doesn't use `main` at all; either they're using `WinMain` or they're =
being called by some other library that <i>itself</i> uses `main`. You're e=
ffectively saying that none of this code can use your helper class.<br><br>=
If a significant number of C++ users would have to invent their own version=
of `raiicap` in order to use the arbitrary, then what good is it? If a use=
r cannot force `raiicap` to use a specific function, rather than just one f=
orm of `main`, then you've limited the use cases for this tools a lot.<br><=
br>And what of the people who want to split up their `main` functions,=20
perhaps because they're getting rather big? What if it's more natural to
put that initialization in some other function that's called by `main`?<br=
><br>Main is not the center of everyone's universe. Your tool is too restri=
ctive. And C++ doesn't offer a way to generalize it to a user-provided func=
tion without employing macros. So I don't think it's a good tool.<br><br></=
div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div=
class=3D"gmail_quote">
<div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-st=
yle:solid;padding-left:1ex"><div>There are far better ways to restrict the =
construction of an object instance to one or more specific functions than t=
his.</div>
</blockquote><div><br></div><div>Could you elaborate?<br></div></div></div>=
</div></blockquote><div><br>The same way you're doing it here, only without=
an intermediate, dependency-injected object. Make the class's constructors=
of interest private and make the "one or more specific functions" that can=
allocate them friends.<br><br>That way, it is the writer of the class who =
gets to decide which functions get to create it. You're not limited to one =
specific form of `main`.<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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_828_15713586.1364461804558--
.
Author: Rob Meijer <pibara@gmail.com>
Date: Fri, 29 Mar 2013 08:54:18 +0100
Raw View
--485b397dd3ab2268ad04d90b9472
Content-Type: text/plain; charset=ISO-8859-1
2013/3/28 Nicol Bolas <jmckesson@gmail.com>
> On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:
>>
>>
>>
>>
>> 2013/3/28 Nicol Bolas <jmck...@gmail.com>
>>
>> On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>>>>
>>>> A few months ago I wrote a blog post about a potential singleton
>>>> alternative that I dubbed RAII-Caps (capability like references for access
>>>> to the constructor of resource management (RAI) classes.
>>>>
>>>> http://minorfs.wordpress.com/**2**013/01/18/raiicap-pattern-**inje**
>>>> cted-singleton-**alternative-**for-c/<http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/>
>>>>
>>>> Although I'm rather embarrassed by the small size of the actual code
>>>> needed for this proposal (a few lines only and small lines at that), I
>>>> believe it may be an extremely modest useful addition to the standard
>>>> library.
>>>>
>>>> template <typename T>
>>>> class raiicap {
>>>> public:
>>>> friend int main(int,char **);
>>>> private:
>>>> raiicap(){}
>>>> };
>>>>
>>>> My proposal thus is the addition of this tiny raiicap template to the
>>>> standard library.
>>>>
>>>>
>>> So you've developed a class that is only useful via dependency
>>> injection, can only be used within the direct context of `main` (and only
>>> one version of main at that), and in the end, it only provides *half*of the singleton concept. And it doesn't even really do that, since `main`
>>> is perfectly capable of constructing more than one of them.
>>>
>>>
>> The concept is that main, using this simple template class can be made
>> the 'initial source of authority' for constructing RAII objects
>> for scares resources. It can not "only be USED within the direct context of
>> `main`", it's a token of authority that can only ORIGINATE within the
>> direct context of `main` from where it can be discretionary delegated to
>> other parts of the program, for example an object who's responsibility it
>> is to instantiate only a single instance, or even to instantiate only a
>> single instance AND provide a global access point to it.
>>
>
> When I said that it "can only be used within the direct context of
> `main`," I meant `raiicap`, not the classes that use it. You can't do
> anything with `raiicap` outside of `main`.
>
The raiicap is a discretionary token of authority that 'originates' at
main, making logical computational root and the compositional root
conveniently fall together, and allowing the authority to use the
constructor to be passed around in a discretionary way. So saying that you
can't do anything with raiicap outside of main is like saying you can't do
anything with a factory created object outside of the factory.
> And again, this only works with one version of `main`.
>
>
Yes, this should be fixed, any version of main as defined in the standard
should indeed be included as a friend.
> I understand quite well what you're trying to do. I'm saying that not
> everyone *wants* singletons to be allocated by `main`.
>
The usecase is a RAIIish 'alternative' to the 'limited or single resource'
part Singletons that does not imply the 'global access' part of the
Singleton pattern. So if people 'want' Singletons fall outside of the
intended audience, and 'creating a Singleton' falls outside of the usecase.
> And what of code that uses `int main()`, which is just as standard C++ as
> `int main(int argc, const char *argv)`?
>
Agreed.
> There's also a fair amount of code out there that doesn't use `main` at
> all; either they're using `WinMain` or they're being called by some other
> library that *itself* uses `main`. You're effectively saying that none of
> this code can use your helper class.
>
The standard provides us with 'main' as a logical computational root that
we can use as compositional root concerning the authority to construct RAII
objects. I propose the above as a facility that uses this logical
computational root.
If a specific compiler or a framework provides an alternative logical
computational root that falls outside of the standard and that effectively
disables delegation of authority from the standard defined main to the
compiler/framework specific computational root, than that would indeed be a
problem. Do you have details on how important compilers and frameworks
obscure and inhibit the use of the standard defined main for the user?
For compiler builders I would think there should not be much of a problem
to allow them to add an extra friend definition to raiicap (for example to
winmain) for the version of the standard library that ships with their
compiler, but maybe this is a no-go, I don't know.
If a significant number of C++ users would have to invent their own version
> of `raiicap` in order to use the arbitrary, then what good is it? If a user
> cannot force `raiicap` to use a specific function, rather than just one
> form of `main`, then you've limited the use cases for this tools a lot.
>
I disagree, the user should not be able to force `raiicap` to use an
arbitrary function. The creator of a compiler or a framework that inhibits
the direct use of main by the user should ideally however be able to do
discretionary delegation of its authority to construct arbitrary raiicaps.
Depending on the existence of important real-life frameworks that would
need this and dependent on the ability of compiler vendors to extend the
stl defined types, it may be a good idea for me to look into this and see
if I can write an extended proposal that allows for this. In any case its
essential that the creator of a library that defines RAII classes should
have no notion of the
framework, compiler etc that uses it.
>
> And what of the people who want to split up their `main` functions,
> perhaps because they're getting rather big? What if it's more natural to
> put that initialization in some other function that's called by `main`?
>
There is no problem there.
> Main is not the center of everyone's universe. Your tool is too
> restrictive. And C++ doesn't offer a way to generalize it to a
> user-provided function without employing macros. So I don't think it's a
> good tool.
>
Basically discretionary delegation is what makes the tool flexible. User
provided functions would brake the model and render the pattern useless. It
might however be usefull to change the proposal as to allow the delegation
of a full 'root of authority' by framework builders.
>
> There are far better ways to restrict the construction of an object
>>> instance to one or more specific functions than this.
>>>
>>
>> Could you elaborate?
>>
>
> The same way you're doing it here, only without an intermediate,
> dependency-injected object. Make the class's constructors of interest
> private and make the "one or more specific functions" that can allocate
> them friends.
>
> That way, it is the writer of the class who gets to decide which functions
> get to create it.
>
What business does 'the writer of the class' have 'statically' determining
what function gets to create it. My proposal allows the writer of the class
to state: "The creator of the 'program' gets to do discretionary delegate
the right to create".
--
---
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/?hl=en.
--485b397dd3ab2268ad04d90b9472
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">2013/3/28 Nicol Bolas <span dir=3D"ltr"><<a href=3D"mailto:jmcke=
sson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>></span><br><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padd=
ing-left:1ex">
On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px=
;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1e=
x">
<div dir=3D"ltr"><br><div><br><br><div class=3D"gmail_quote">2013/3/28 Nico=
l Bolas <span dir=3D"ltr"><<a>jmck...@gmail.com</a>></span><div class=
=3D"im"><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
..8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-s=
tyle:solid;padding-left:1ex">
<div><div>On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-=
width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddin=
g-left:1ex">
<div dir=3D"ltr"><div>A few months ago I wrote a blog post about a potentia=
l singleton alternative that I dubbed RAII-Caps (capability like references=
for access to the constructor of resource management (RAI) classes.</div>
<div><br></div><div><a href=3D"http://minorfs.wordpress.com/2013/01/18/raii=
cap-pattern-injected-singleton-alternative-for-c/" target=3D"_blank">http:/=
/minorfs.wordpress.com/<u></u>2<u></u>013/01/18/raiicap-pattern-<u></u>inje=
<u></u>cted-singleton-<u></u>alternative-<u></u>for-c/</a><br>
</div><div><br></div>Although I'm rather=A0embarrassed=A0by the small s=
ize of the actual code needed for this proposal (a few lines only and small=
lines at that), I believe it may be an extremely =A0modest useful addition=
to the standard library.<div>
<br></div><div><div style=3D"font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace;line-height:15.390625px;f=
ont-size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!import=
ant;outline:0px!important;padding:0px 1em!important;vertical-align:baseline=
!important;border-top-left-radius:0px!important;border-top-right-radius:0px=
!important;border-bottom-right-radius:0px!important;border-bottom-left-radi=
us:0px!important;background-image:none!important;float:none!important;min-h=
eight:auto!important;overflow:visible!important;width:auto!important;direct=
ion:ltr!important;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">template</code> <code style=3D"border:0px!important;font-family:Co=
nsolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;margin:0px!important;outline:0px!important;padding:0px!imp=
ortant;vertical-align:baseline!important;font-size:1em!important;line-heigh=
t:1.1em!important;border-top-left-radius:0px!important;border-top-right-rad=
ius:0px!important;border-bottom-right-radius:0px!important;border-bottom-le=
ft-radius:0px!important;background-image:none!important;float:none!importan=
t;min-height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;display:inline!important;color:black!important">&l=
t;</code><code style=3D"border:0px!important;font-family:Consolas,'Bits=
tream Vera Sans Mono','Courier New',Courier,monospace!important=
;font-weight:bold!important;margin:0px!important;outline:0px!important;padd=
ing:0px!important;vertical-align:baseline!important;font-size:1em!important=
;line-height:1.1em!important;border-top-left-radius:0px!important;border-to=
p-right-radius:0px!important;border-bottom-right-radius:0px!important;borde=
r-bottom-left-radius:0px!important;background-image:none!important;float:no=
ne!important;min-height:auto!important;overflow:visible!important;width:aut=
o!important;direction:ltr!important;display:inline!important;color:rgb(0,10=
2,153)!important">typename</code> <code style=3D"border:0px!important;font-=
family:Consolas,'Bitstream Vera Sans Mono','Courier New',Co=
urier,monospace!important;margin:0px!important;outline:0px!important;paddin=
g:0px!important;vertical-align:baseline!important;font-size:1em!important;l=
ine-height:1.1em!important;border-top-left-radius:0px!important;border-top-=
right-radius:0px!important;border-bottom-right-radius:0px!important;border-=
bottom-left-radius:0px!important;background-image:none!important;float:none=
!important;min-height:auto!important;overflow:visible!important;width:auto!=
important;direction:ltr!important;display:inline!important;color:black!impo=
rtant">T></code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">class</code> <code style=3D"border:0px!important;font-family:Conso=
las,'Bitstream Vera Sans Mono','Courier New',Courier,monosp=
ace!important;margin:0px!important;outline:0px!important;padding:0px!import=
ant;vertical-align:baseline!important;font-size:1em!important;line-height:1=
..1em!important;border-top-left-radius:0px!important;border-top-right-radius=
:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-=
radius:0px!important;background-image:none!important;float:none!important;m=
in-height:auto!important;overflow:visible!important;width:auto!important;di=
rection:ltr!important;display:inline!important;color:black!important">raiic=
ap {</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">public</code><code style=3D=
"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
9;,'Courier New',Courier,monospace!important;margin:0px!important;o=
utline:0px!important;padding:0px!important;vertical-align:baseline!importan=
t;font-size:1em!important;line-height:1.1em!important;border-top-left-radiu=
s:0px!important;border-top-right-radius:0px!important;border-bottom-right-r=
adius:0px!important;border-bottom-left-radius:0px!important;background-imag=
e:none!important;float:none!important;min-height:auto!important;overflow:vi=
sible!important;width:auto!important;direction:ltr!important;display:inline=
!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;font-weight:bold!important;margin:0px!=
important;outline:0px!important;padding:0px!important;vertical-align:baseli=
ne!important;font-size:1em!important;line-height:1.1em!important;border-top=
-left-radius:0px!important;border-top-right-radius:0px!important;border-bot=
tom-right-radius:0px!important;border-bottom-left-radius:0px!important;back=
ground-image:none!important;float:none!important;min-height:auto!important;=
overflow:visible!important;width:auto!important;direction:ltr!important;dis=
play:inline!important;color:rgb(0,102,153)!important">friend</code> <code s=
tyle=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace!important;font-weight:bol=
d!important;margin:0px!important;outline:0px!important;padding:0px!importan=
t;vertical-align:baseline!important;font-size:1em!important;line-height:1.1=
em!important;border-top-left-radius:0px!important;border-top-right-radius:0=
px!important;border-bottom-right-radius:0px!important;border-bottom-left-ra=
dius:0px!important;background-image:none!important;float:none!important;min=
-height:auto!important;overflow:visible!important;width:auto!important;dire=
ction:ltr!important;display:inline!important;color:gray!important">int</cod=
e> <code style=3D"border:0px!important;font-family:Consolas,'Bitstream =
Vera Sans Mono','Courier New',Courier,monospace!important;margi=
n:0px!important;outline:0px!important;padding:0px!important;vertical-align:=
baseline!important;font-size:1em!important;line-height:1.1em!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;display:inline!important;color:black!important">main(</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;font-weight:bold!im=
portant;margin:0px!important;outline:0px!important;padding:0px!important;ve=
rtical-align:baseline!important;font-size:1em!important;line-height:1.1em!i=
mportant;border-top-left-radius:0px!important;border-top-right-radius:0px!i=
mportant;border-bottom-right-radius:0px!important;border-bottom-left-radius=
:0px!important;background-image:none!important;float:none!important;min-hei=
ght:auto!important;overflow:visible!important;width:auto!important;directio=
n:ltr!important;display:inline!important;color:gray!important">int</code><c=
ode style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera =
Sans Mono','Courier New',Courier,monospace!important;margin:0px=
!important;outline:0px!important;padding:0px!important;vertical-align:basel=
ine!important;font-size:1em!important;line-height:1.1em!important;border-to=
p-left-radius:0px!important;border-top-right-radius:0px!important;border-bo=
ttom-right-radius:0px!important;border-bottom-left-radius:0px!important;bac=
kground-image:none!important;float:none!important;min-height:auto!important=
;overflow:visible!important;width:auto!important;direction:ltr!important;di=
splay:inline!important;color:black!important">,</code><code style=3D"border=
:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono','=
;Courier New',Courier,monospace!important;font-weight:bold!important;ma=
rgin:0px!important;outline:0px!important;padding:0px!important;vertical-ali=
gn:baseline!important;font-size:1em!important;line-height:1.1em!important;b=
order-top-left-radius:0px!important;border-top-right-radius:0px!important;b=
order-bottom-right-radius:0px!important;border-bottom-left-radius:0px!impor=
tant;background-image:none!important;float:none!important;min-height:auto!i=
mportant;overflow:visible!important;width:auto!important;direction:ltr!impo=
rtant;display:inline!important;color:gray!important">char</code> <code styl=
e=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mon=
o','Courier New',Courier,monospace!important;margin:0px!importa=
nt;outline:0px!important;padding:0px!important;vertical-align:baseline!impo=
rtant;font-size:1em!important;line-height:1.1em!important;border-top-left-r=
adius:0px!important;border-top-right-radius:0px!important;border-bottom-rig=
ht-radius:0px!important;border-bottom-left-radius:0px!important;background-=
image:none!important;float:none!important;min-height:auto!important;overflo=
w:visible!important;width:auto!important;direction:ltr!important;display:in=
line!important;color:black!important">**);</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">private</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;margin:0px!importan=
t;outline:0px!important;padding:0px!important;vertical-align:baseline!impor=
tant;font-size:1em!important;line-height:1.1em!important;border-top-left-ra=
dius:0px!important;border-top-right-radius:0px!important;border-bottom-righ=
t-radius:0px!important;border-bottom-left-radius:0px!important;background-i=
mage:none!important;float:none!important;min-height:auto!important;overflow=
:visible!important;width:auto!important;direction:ltr!important;display:inl=
ine!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;margin:0px!important;outline:0px!impor=
tant;padding:0px!important;vertical-align:baseline!important;font-size:1em!=
important;line-height:1.1em!important;border-top-left-radius:0px!important;=
border-top-right-radius:0px!important;border-bottom-right-radius:0px!import=
ant;border-bottom-left-radius:0px!important;background-image:none!important=
;float:none!important;min-height:auto!important;overflow:visible!important;=
width:auto!important;direction:ltr!important;display:inline!important;color=
:black!important">raiicap(){}</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important;color:black!important">};</code></div>
</div><div><br></div><div>My proposal thus is the addition of this tiny rai=
icap template to the standard library.<br></div><br></div></blockquote></di=
v></div><div><br>So you've developed a class that is only useful via de=
pendency injection, can only be used within the direct context of `main` (a=
nd only one version of main at that), and in the end, it only provides <i>h=
alf</i> of the singleton concept. And it doesn't even really do that, s=
ince `main` is perfectly capable of constructing more than one of them.<br>
<br></div></blockquote><div><br></div><div>The concept is that main, using =
this simple template class can be made the 'initial source of authority=
' for constructing RAII objects for=A0scares=A0resources. It can not &q=
uot;only be USED within the direct context of `main`", it's a toke=
n of authority that can only ORIGINATE within the direct context of `main` =
from where it can be discretionary delegated to other parts of the program,=
for example an object who's responsibility it is to instantiate only a=
single instance, or even=A0to instantiate only a single instance AND provi=
de a global=A0access=A0point to it.</div>
</div></div></div></div></blockquote><div><br>When I said that it "can=
only be used within the direct context of `main`," I meant `raiicap`,=
not the classes that use it. You can't do anything with `raiicap` outs=
ide of `main`. </div>
</blockquote><div><br></div><div style>The raiicap is a discretionary token=
of authority that 'originates' at main, making logical computation=
al root and the compositional root conveniently fall together, and allowing=
the authority to use the constructor to be passed around in a discretionar=
y way. So saying that you can't do anything with raiicap outside of mai=
n is like saying you can't do anything with a factory created object ou=
tside of the factory.=A0</div>
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div>And again, this only works with one ver=
sion of `main`.<br>
<br></div></blockquote><div><br></div><div style>Yes, this should be fixed,=
any version of main as defined in the standard should indeed be included a=
s a friend.</div><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204=
,204);border-left-style:solid;padding-left:1ex">
<div>I understand quite well what you're trying to do. I'm saying t=
hat not everyone <i>wants</i> singletons to be allocated by `main`. </div><=
/blockquote><div><br></div><div style>The usecase is =A0a RAIIish 'alte=
rnative' to the 'limited or single resource' part Singletons th=
at does not imply the 'global access' part of the Singleton pattern=
.. So if people 'want' Singletons fall outside of the intended audie=
nce, and 'creating a Singleton' falls outside of the usecase.</div>
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div>And what of code that uses `int main()`=
, which is just as standard C++ as `int main(int argc, const char *argv)`?<=
/div>
</blockquote><div><br></div><div style>Agreed.</div><div>=A0</div><blockquo=
te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-widt=
h:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-le=
ft:1ex">
<div> There's also a fair amount of code out there that doesn't use=
`main` at all; either they're using `WinMain` or they're being cal=
led by some other library that <i>itself</i> uses `main`. You're effect=
ively saying that none of this code can use your helper class.<br>
</div></blockquote><div><br></div><div style>The standard provides us with =
'main' as a logical computational root that we can use as compositi=
onal root concerning the authority to construct RAII objects. I propose the=
above as a facility that uses this logical computational root.=A0</div>
<div style><br></div><div style>If a specific compiler or a framework provi=
des an alternative logical computational root that falls outside of the sta=
ndard and that effectively disables delegation of authority from the standa=
rd defined main to the compiler/framework specific computational root, than=
that would indeed be a problem. Do you have details =A0on how important co=
mpilers and frameworks obscure and inhibit the use of the standard defined =
main for the user?</div>
<div style>For compiler builders I would think there should not be much of =
a problem to allow them to add an extra friend definition to raiicap (for e=
xample to winmain) for the version of the standard library that ships with =
their compiler, but maybe this is a no-go, I don't know.</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div>If a significant number of C++ users w=
ould have to invent their own version of `raiicap` in order to use the arbi=
trary, then what good is it? If a user cannot force `raiicap` to use a spec=
ific function, rather than just one form of `main`, then you've limited=
the use cases for this tools a lot.<br>
</div></blockquote><div><br></div><div style>I disagree, the user should no=
t be able to force=A0`raiicap` to use an arbitrary=A0function. The creator =
of a compiler or a framework that inhibits the direct use of main by the us=
er should ideally however be able to do discretionary=A0delegation of its a=
uthority to construct arbitrary raiicaps. Depending on the existence of=A0i=
mportant=A0real-life frameworks that would need this and dependent on the a=
bility of compiler vendors to extend the stl defined types, it may be a goo=
d idea for me to look into this and see if I can write an extended proposal=
that allows for this. In any case its essential that the creator of a libr=
ary that defines RAII classes should have no notion of the</div>
<div style>framework, compiler etc that uses it.=A0</div><div>=A0</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddi=
ng-left:1ex">
<div><br>And what of the people who want to split up their `main` functions=
,=20
perhaps because they're getting rather big? What if it's more natur=
al to
put that initialization in some other function that's called by `main`=
?<br></div></blockquote><div><br></div><div style>There is no problem there=
..</div><div><br></div><div>=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex">
<div>Main is not the center of everyone's universe. Your tool is too re=
strictive. And C++ doesn't offer a way to generalize it to a user-provi=
ded function without employing macros. So I don't think it's a good=
tool.<br>
</div></blockquote><div><br></div><div style>Basically discretionary delega=
tion is what makes the tool flexible. User provided functions would brake t=
he model and render the pattern useless. It might however be usefull to cha=
nge the proposal as to allow the delegation of a full 'root of authorit=
y' by framework builders.</div>
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div><br></div><div class=3D"im"><blockquote=
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:=
1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left=
:1ex">
<div dir=3D"ltr"><div><div class=3D"gmail_quote">
<div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-st=
yle:solid;padding-left:1ex"><div>There are far better ways to restrict the =
construction of an object instance to one or more specific functions than t=
his.</div>
</blockquote><div><br></div><div>Could you elaborate?<br></div></div></div>=
</div></blockquote></div><div><br>The same way you're doing it here, on=
ly without an intermediate, dependency-injected object. Make the class'=
s constructors of interest private and make the "one or more specific =
functions" that can allocate them friends.<br>
<br></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div>That way, it is the writer of =
the class who gets to decide which functions get to create it.</div>
</blockquote><div>=A0</div><div>What business does 'the writer of the c=
lass' have 'statically' determining what function gets to creat=
e it. My proposal allows the writer of the class to state: "The creato=
r of the 'program' gets to do discretionary delegate the right to c=
reate".</div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--485b397dd3ab2268ad04d90b9472--
.
Author: Rob Meijer <pibara@gmail.com>
Date: Fri, 29 Mar 2013 12:42:55 +0100
Raw View
--047d7b2e3e7aa6c72504d90ec580
Content-Type: text/plain; charset=ISO-8859-1
An updated version for facilitating the framework scenario:
template <typename T>
class raiicap {
raiicap() {}
public:
raiicap(raiicap<void> const&) {}
friend int main(int,char **);
};
This could than for example be used like:
void use(resource &r) {
r.use();
};
void allocate_and_use(raiicap<resource> const
&authority_to_allocate_specific_resource) {
resource r(authority_to_allocate_specific_resource);
use(r);
};
void frameworkmain(raiicap<void> const &authority_to_allocate_any_resource){
raiicap<resource>
authority_to_allocate_specific_resource(authority_to_allocate_any_resource);
allocate_and_use(authority_to_allocate_specific_resource);
};
int main(int argc,char**argv) {
raiicap<void> authority_to_allocate_any_resource;
frameworkmain(authority_to_allocate_any_resource);
};
Next to the original:
int main(int argc,char**argv) {
raiicap<resource> authority_to_allocate_specific_resource();
allocate_and_use(authority_to_allocate_specific_resource);
};
2013/3/29 Rob Meijer <pibara@gmail.com>
>
>
>
> 2013/3/28 Nicol Bolas <jmckesson@gmail.com>
>
>> On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:
>>>
>>>
>>>
>>>
>>> 2013/3/28 Nicol Bolas <jmck...@gmail.com>
>>>
>>> On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:
>>>>>
>>>>> A few months ago I wrote a blog post about a potential singleton
>>>>> alternative that I dubbed RAII-Caps (capability like references for access
>>>>> to the constructor of resource management (RAI) classes.
>>>>>
>>>>> http://minorfs.wordpress.com/**2**013/01/18/raiicap-pattern-**inje**
>>>>> cted-singleton-**alternative-**for-c/<http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/>
>>>>>
>>>>> Although I'm rather embarrassed by the small size of the actual code
>>>>> needed for this proposal (a few lines only and small lines at that), I
>>>>> believe it may be an extremely modest useful addition to the standard
>>>>> library.
>>>>>
>>>>> template <typename T>
>>>>> class raiicap {
>>>>> public:
>>>>> friend int main(int,char **);
>>>>> private:
>>>>> raiicap(){}
>>>>> };
>>>>>
>>>>> My proposal thus is the addition of this tiny raiicap template to the
>>>>> standard library.
>>>>>
>>>>>
>>>> So you've developed a class that is only useful via dependency
>>>> injection, can only be used within the direct context of `main` (and only
>>>> one version of main at that), and in the end, it only provides *half*of the singleton concept. And it doesn't even really do that, since `main`
>>>> is perfectly capable of constructing more than one of them.
>>>>
>>>>
>>> The concept is that main, using this simple template class can be made
>>> the 'initial source of authority' for constructing RAII objects
>>> for scares resources. It can not "only be USED within the direct context of
>>> `main`", it's a token of authority that can only ORIGINATE within the
>>> direct context of `main` from where it can be discretionary delegated to
>>> other parts of the program, for example an object who's responsibility it
>>> is to instantiate only a single instance, or even to instantiate only a
>>> single instance AND provide a global access point to it.
>>>
>>
>> When I said that it "can only be used within the direct context of
>> `main`," I meant `raiicap`, not the classes that use it. You can't do
>> anything with `raiicap` outside of `main`.
>>
>
> The raiicap is a discretionary token of authority that 'originates' at
> main, making logical computational root and the compositional root
> conveniently fall together, and allowing the authority to use the
> constructor to be passed around in a discretionary way. So saying that you
> can't do anything with raiicap outside of main is like saying you can't do
> anything with a factory created object outside of the factory.
>
>
>> And again, this only works with one version of `main`.
>>
>>
> Yes, this should be fixed, any version of main as defined in the standard
> should indeed be included as a friend.
>
>
>> I understand quite well what you're trying to do. I'm saying that not
>> everyone *wants* singletons to be allocated by `main`.
>>
>
> The usecase is a RAIIish 'alternative' to the 'limited or single
> resource' part Singletons that does not imply the 'global access' part of
> the Singleton pattern. So if people 'want' Singletons fall outside of the
> intended audience, and 'creating a Singleton' falls outside of the usecase.
>
>
>> And what of code that uses `int main()`, which is just as standard C++ as
>> `int main(int argc, const char *argv)`?
>>
>
> Agreed.
>
>
>> There's also a fair amount of code out there that doesn't use `main` at
>> all; either they're using `WinMain` or they're being called by some other
>> library that *itself* uses `main`. You're effectively saying that none
>> of this code can use your helper class.
>>
>
> The standard provides us with 'main' as a logical computational root that
> we can use as compositional root concerning the authority to construct RAII
> objects. I propose the above as a facility that uses this logical
> computational root.
>
> If a specific compiler or a framework provides an alternative logical
> computational root that falls outside of the standard and that effectively
> disables delegation of authority from the standard defined main to the
> compiler/framework specific computational root, than that would indeed be a
> problem. Do you have details on how important compilers and frameworks
> obscure and inhibit the use of the standard defined main for the user?
> For compiler builders I would think there should not be much of a problem
> to allow them to add an extra friend definition to raiicap (for example to
> winmain) for the version of the standard library that ships with their
> compiler, but maybe this is a no-go, I don't know.
>
> If a significant number of C++ users would have to invent their own
>> version of `raiicap` in order to use the arbitrary, then what good is it?
>> If a user cannot force `raiicap` to use a specific function, rather than
>> just one form of `main`, then you've limited the use cases for this tools a
>> lot.
>>
>
> I disagree, the user should not be able to force `raiicap` to use an
> arbitrary function. The creator of a compiler or a framework that inhibits
> the direct use of main by the user should ideally however be able to do
> discretionary delegation of its authority to construct arbitrary raiicaps.
> Depending on the existence of important real-life frameworks that would
> need this and dependent on the ability of compiler vendors to extend the
> stl defined types, it may be a good idea for me to look into this and see
> if I can write an extended proposal that allows for this. In any case its
> essential that the creator of a library that defines RAII classes should
> have no notion of the
> framework, compiler etc that uses it.
>
>
>>
>> And what of the people who want to split up their `main` functions,
>> perhaps because they're getting rather big? What if it's more natural to
>> put that initialization in some other function that's called by `main`?
>>
>
> There is no problem there.
>
>
>
>> Main is not the center of everyone's universe. Your tool is too
>> restrictive. And C++ doesn't offer a way to generalize it to a
>> user-provided function without employing macros. So I don't think it's a
>> good tool.
>>
>
> Basically discretionary delegation is what makes the tool flexible. User
> provided functions would brake the model and render the pattern useless. It
> might however be usefull to change the proposal as to allow the delegation
> of a full 'root of authority' by framework builders.
>
>
>>
>> There are far better ways to restrict the construction of an object
>>>> instance to one or more specific functions than this.
>>>>
>>>
>>> Could you elaborate?
>>>
>>
>> The same way you're doing it here, only without an intermediate,
>> dependency-injected object. Make the class's constructors of interest
>> private and make the "one or more specific functions" that can allocate
>> them friends.
>>
>> That way, it is the writer of the class who gets to decide which
>> functions get to create it.
>>
>
> What business does 'the writer of the class' have 'statically' determining
> what function gets to create it. My proposal allows the writer of the class
> to state: "The creator of the 'program' gets to do discretionary delegate
> the right to create".
>
--
---
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/?hl=en.
--047d7b2e3e7aa6c72504d90ec580
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">An updated version for facilitating the framework scenario=
:<div><br></div><div><div>template <typename T></div><div>class raiic=
ap {</div><div>=A0 =A0 raiicap() {}</div><div>=A0 public:</div><div>=A0 =A0=
raiicap(raiicap<void> const&) {}</div>
<div>=A0 =A0 friend int main(int,char **);</div><div>};</div></div><div><br=
></div><div style>This could than for example be used like:</div><div style=
><br></div><div style><div>void use(resource &r) {</div><div>=A0 r.use(=
);</div>
<div>};</div><div><br></div><div>void allocate_and_use(raiicap<resource&=
gt; const &authority_to_allocate_specific_resource) {</div><div>=A0 =A0=
resource r(authority_to_allocate_specific_resource);</div><div>=A0 =A0 use=
(r);</div>
<div>};</div><div><br></div><div>void frameworkmain(raiicap<void> con=
st &authority_to_allocate_any_resource){</div><div>=A0 =A0 raiicap<r=
esource> authority_to_allocate_specific_resource(authority_to_allocate_a=
ny_resource);</div>
<div>=A0 =A0 allocate_and_use(authority_to_allocate_specific_resource);</di=
v><div>};</div><div><br></div><div>int main(int argc,char**argv) {</div><di=
v>=A0 raiicap<void> authority_to_allocate_any_resource;</div><div>=A0=
frameworkmain(authority_to_allocate_any_resource);</div>
<div>};</div><div><br></div><div style>Next to the original:</div><div styl=
e><br></div><div style><div>int main(int argc,char**argv) {</div><div>=A0 r=
aiicap<resource> authority_to_allocate_specific_resource();</div><div=
>
=A0 allocate_and_use(authority_to_allocate_specific_resource);</div><div>};=
</div><div><br></div><div><br></div></div></div></div><div class=3D"gmail_e=
xtra"><br><br><div class=3D"gmail_quote">2013/3/29 Rob Meijer <span dir=3D"=
ltr"><<a href=3D"mailto:pibara@gmail.com" target=3D"_blank">pibara@gmail=
..com</a>></span><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"><br><div class=3D"gmail_ext=
ra"><br><br><div class=3D"gmail_quote"><div class=3D"im">2013/3/28 Nicol Bo=
las <span dir=3D"ltr"><<a href=3D"mailto:jmckesson@gmail.com" target=3D"=
_blank">jmckesson@gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex">
On Wednesday, March 27, 2013 10:20:13 PM UTC-7, pibara wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px=
;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1e=
x">
<div dir=3D"ltr"><br><div><br><br><div class=3D"gmail_quote">2013/3/28 Nico=
l Bolas <span dir=3D"ltr"><<a>jmck...@gmail.com</a>></span><div><br><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;pa=
dding-left:1ex">
<div><div>On Wednesday, March 27, 2013 3:21:27 PM UTC-7, pibara wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-=
width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddin=
g-left:1ex">
<div dir=3D"ltr"><div>A few months ago I wrote a blog post about a potentia=
l singleton alternative that I dubbed RAII-Caps (capability like references=
for access to the constructor of resource management (RAI) classes.</div>
<div><br></div><div><a href=3D"http://minorfs.wordpress.com/2013/01/18/raii=
cap-pattern-injected-singleton-alternative-for-c/" target=3D"_blank">http:/=
/minorfs.wordpress.com/<u></u>2<u></u>013/01/18/raiicap-pattern-<u></u>inje=
<u></u>cted-singleton-<u></u>alternative-<u></u>for-c/</a><br>
</div><div><br></div>Although I'm rather=A0embarrassed=A0by the small s=
ize of the actual code needed for this proposal (a few lines only and small=
lines at that), I believe it may be an extremely =A0modest useful addition=
to the standard library.<div>
<br></div><div><div style=3D"font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace;line-height:15.390625px;f=
ont-size:14px;color:rgb(255,236,208);border:0px!important;margin:0px!import=
ant;outline:0px!important;padding:0px 1em!important;vertical-align:baseline=
!important;border-top-left-radius:0px!important;border-top-right-radius:0px=
!important;border-bottom-right-radius:0px!important;border-bottom-left-radi=
us:0px!important;background-image:none!important;float:none!important;min-h=
eight:auto!important;overflow:visible!important;width:auto!important;direct=
ion:ltr!important;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">template</code> <code style=3D"border:0px!important;font-family:Co=
nsolas,'Bitstream Vera Sans Mono','Courier New',Courier,mon=
ospace!important;margin:0px!important;outline:0px!important;padding:0px!imp=
ortant;vertical-align:baseline!important;font-size:1em!important;line-heigh=
t:1.1em!important;border-top-left-radius:0px!important;border-top-right-rad=
ius:0px!important;border-bottom-right-radius:0px!important;border-bottom-le=
ft-radius:0px!important;background-image:none!important;float:none!importan=
t;min-height:auto!important;overflow:visible!important;width:auto!important=
;direction:ltr!important;display:inline!important;color:black!important">&l=
t;</code><code style=3D"border:0px!important;font-family:Consolas,'Bits=
tream Vera Sans Mono','Courier New',Courier,monospace!important=
;font-weight:bold!important;margin:0px!important;outline:0px!important;padd=
ing:0px!important;vertical-align:baseline!important;font-size:1em!important=
;line-height:1.1em!important;border-top-left-radius:0px!important;border-to=
p-right-radius:0px!important;border-bottom-right-radius:0px!important;borde=
r-bottom-left-radius:0px!important;background-image:none!important;float:no=
ne!important;min-height:auto!important;overflow:visible!important;width:aut=
o!important;direction:ltr!important;display:inline!important;color:rgb(0,10=
2,153)!important">typename</code> <code style=3D"border:0px!important;font-=
family:Consolas,'Bitstream Vera Sans Mono','Courier New',Co=
urier,monospace!important;margin:0px!important;outline:0px!important;paddin=
g:0px!important;vertical-align:baseline!important;font-size:1em!important;l=
ine-height:1.1em!important;border-top-left-radius:0px!important;border-top-=
right-radius:0px!important;border-bottom-right-radius:0px!important;border-=
bottom-left-radius:0px!important;background-image:none!important;float:none=
!important;min-height:auto!important;overflow:visible!important;width:auto!=
important;direction:ltr!important;display:inline!important;color:black!impo=
rtant">T></code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;font-wei=
ght:bold!important;margin:0px!important;outline:0px!important;padding:0px!i=
mportant;vertical-align:baseline!important;font-size:1em!important;line-hei=
ght:1.1em!important;border-top-left-radius:0px!important;border-top-right-r=
adius:0px!important;border-bottom-right-radius:0px!important;border-bottom-=
left-radius:0px!important;background-image:none!important;float:none!import=
ant;min-height:auto!important;overflow:visible!important;width:auto!importa=
nt;direction:ltr!important;display:inline!important;color:rgb(0,102,153)!im=
portant">class</code> <code style=3D"border:0px!important;font-family:Conso=
las,'Bitstream Vera Sans Mono','Courier New',Courier,monosp=
ace!important;margin:0px!important;outline:0px!important;padding:0px!import=
ant;vertical-align:baseline!important;font-size:1em!important;line-height:1=
..1em!important;border-top-left-radius:0px!important;border-top-right-radius=
:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-=
radius:0px!important;background-image:none!important;float:none!important;m=
in-height:auto!important;overflow:visible!important;width:auto!important;di=
rection:ltr!important;display:inline!important;color:black!important">raiic=
ap {</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">public</code><code style=3D=
"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
9;,'Courier New',Courier,monospace!important;margin:0px!important;o=
utline:0px!important;padding:0px!important;vertical-align:baseline!importan=
t;font-size:1em!important;line-height:1.1em!important;border-top-left-radiu=
s:0px!important;border-top-right-radius:0px!important;border-bottom-right-r=
adius:0px!important;border-bottom-left-radius:0px!important;background-imag=
e:none!important;float:none!important;min-height:auto!important;overflow:vi=
sible!important;width:auto!important;direction:ltr!important;display:inline=
!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;font-weight:bold!important;margin:0px!=
important;outline:0px!important;padding:0px!important;vertical-align:baseli=
ne!important;font-size:1em!important;line-height:1.1em!important;border-top=
-left-radius:0px!important;border-top-right-radius:0px!important;border-bot=
tom-right-radius:0px!important;border-bottom-left-radius:0px!important;back=
ground-image:none!important;float:none!important;min-height:auto!important;=
overflow:visible!important;width:auto!important;direction:ltr!important;dis=
play:inline!important;color:rgb(0,102,153)!important">friend</code> <code s=
tyle=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans =
Mono','Courier New',Courier,monospace!important;font-weight:bol=
d!important;margin:0px!important;outline:0px!important;padding:0px!importan=
t;vertical-align:baseline!important;font-size:1em!important;line-height:1.1=
em!important;border-top-left-radius:0px!important;border-top-right-radius:0=
px!important;border-bottom-right-radius:0px!important;border-bottom-left-ra=
dius:0px!important;background-image:none!important;float:none!important;min=
-height:auto!important;overflow:visible!important;width:auto!important;dire=
ction:ltr!important;display:inline!important;color:gray!important">int</cod=
e> <code style=3D"border:0px!important;font-family:Consolas,'Bitstream =
Vera Sans Mono','Courier New',Courier,monospace!important;margi=
n:0px!important;outline:0px!important;padding:0px!important;vertical-align:=
baseline!important;font-size:1em!important;line-height:1.1em!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;display:inline!important;color:black!important">main(</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;font-weight:bold!im=
portant;margin:0px!important;outline:0px!important;padding:0px!important;ve=
rtical-align:baseline!important;font-size:1em!important;line-height:1.1em!i=
mportant;border-top-left-radius:0px!important;border-top-right-radius:0px!i=
mportant;border-bottom-right-radius:0px!important;border-bottom-left-radius=
:0px!important;background-image:none!important;float:none!important;min-hei=
ght:auto!important;overflow:visible!important;width:auto!important;directio=
n:ltr!important;display:inline!important;color:gray!important">int</code><c=
ode style=3D"border:0px!important;font-family:Consolas,'Bitstream Vera =
Sans Mono','Courier New',Courier,monospace!important;margin:0px=
!important;outline:0px!important;padding:0px!important;vertical-align:basel=
ine!important;font-size:1em!important;line-height:1.1em!important;border-to=
p-left-radius:0px!important;border-top-right-radius:0px!important;border-bo=
ttom-right-radius:0px!important;border-bottom-left-radius:0px!important;bac=
kground-image:none!important;float:none!important;min-height:auto!important=
;overflow:visible!important;width:auto!important;direction:ltr!important;di=
splay:inline!important;color:black!important">,</code><code style=3D"border=
:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono','=
;Courier New',Courier,monospace!important;font-weight:bold!important;ma=
rgin:0px!important;outline:0px!important;padding:0px!important;vertical-ali=
gn:baseline!important;font-size:1em!important;line-height:1.1em!important;b=
order-top-left-radius:0px!important;border-top-right-radius:0px!important;b=
order-bottom-right-radius:0px!important;border-bottom-left-radius:0px!impor=
tant;background-image:none!important;float:none!important;min-height:auto!i=
mportant;overflow:visible!important;width:auto!important;direction:ltr!impo=
rtant;display:inline!important;color:gray!important">char</code> <code styl=
e=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mon=
o','Courier New',Courier,monospace!important;margin:0px!importa=
nt;outline:0px!important;padding:0px!important;vertical-align:baseline!impo=
rtant;font-size:1em!important;line-height:1.1em!important;border-top-left-r=
adius:0px!important;border-top-right-radius:0px!important;border-bottom-rig=
ht-radius:0px!important;border-bottom-left-radius:0px!important;background-=
image:none!important;float:none!important;min-height:auto!important;overflo=
w:visible!important;width:auto!important;direction:ltr!important;display:in=
line!important;color:black!important">**);</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0</code><code style=3D"border:0px!important;=
font-family:Consolas,'Bitstream Vera Sans Mono','Courier New=
9;,Courier,monospace!important;font-weight:bold!important;margin:0px!import=
ant;outline:0px!important;padding:0px!important;vertical-align:baseline!imp=
ortant;font-size:1em!important;line-height:1.1em!important;border-top-left-=
radius:0px!important;border-top-right-radius:0px!important;border-bottom-ri=
ght-radius:0px!important;border-bottom-left-radius:0px!important;background=
-image:none!important;float:none!important;min-height:auto!important;overfl=
ow:visible!important;width:auto!important;direction:ltr!important;display:i=
nline!important;color:rgb(0,102,153)!important">private</code><code style=
=3D"border:0px!important;font-family:Consolas,'Bitstream Vera Sans Mono=
','Courier New',Courier,monospace!important;margin:0px!importan=
t;outline:0px!important;padding:0px!important;vertical-align:baseline!impor=
tant;font-size:1em!important;line-height:1.1em!important;border-top-left-ra=
dius:0px!important;border-top-right-radius:0px!important;border-bottom-righ=
t-radius:0px!important;border-bottom-left-radius:0px!important;background-i=
mage:none!important;float:none!important;min-height:auto!important;overflow=
:visible!important;width:auto!important;direction:ltr!important;display:inl=
ine!important;color:black!important">:</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important">=A0=A0=A0=A0</code><code style=3D"border:0px!impo=
rtant;font-family:Consolas,'Bitstream Vera Sans Mono','Courier =
New',Courier,monospace!important;margin:0px!important;outline:0px!impor=
tant;padding:0px!important;vertical-align:baseline!important;font-size:1em!=
important;line-height:1.1em!important;border-top-left-radius:0px!important;=
border-top-right-radius:0px!important;border-bottom-right-radius:0px!import=
ant;border-bottom-left-radius:0px!important;background-image:none!important=
;float:none!important;min-height:auto!important;overflow:visible!important;=
width:auto!important;direction:ltr!important;display:inline!important;color=
:black!important">raiicap(){}</code></div>
<div style=3D"font-family:Consolas,'Bitstream Vera Sans Mono','=
Courier New',Courier,monospace;line-height:15.390625px;font-size:14px;c=
olor:rgb(255,236,208);border:0px!important;margin:0px!important;outline:0px=
!important;padding:0px 1em!important;vertical-align:baseline!important;bord=
er-top-left-radius:0px!important;border-top-right-radius:0px!important;bord=
er-bottom-right-radius:0px!important;border-bottom-left-radius:0px!importan=
t;background-image:none!important;float:none!important;min-height:auto!impo=
rtant;overflow:visible!important;width:auto!important;direction:ltr!importa=
nt;white-space:pre!important">
<code style=3D"border:0px!important;font-family:Consolas,'Bitstream Ver=
a Sans Mono','Courier New',Courier,monospace!important;margin:0=
px!important;outline:0px!important;padding:0px!important;vertical-align:bas=
eline!important;font-size:1em!important;line-height:1.1em!important;border-=
top-left-radius:0px!important;border-top-right-radius:0px!important;border-=
bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;b=
ackground-image:none!important;float:none!important;min-height:auto!importa=
nt;overflow:visible!important;width:auto!important;direction:ltr!important;=
display:inline!important;color:black!important">};</code></div>
</div><div><br></div><div>My proposal thus is the addition of this tiny rai=
icap template to the standard library.<br></div><br></div></blockquote></di=
v></div><div><br>So you've developed a class that is only useful via de=
pendency injection, can only be used within the direct context of `main` (a=
nd only one version of main at that), and in the end, it only provides <i>h=
alf</i> of the singleton concept. And it doesn't even really do that, s=
ince `main` is perfectly capable of constructing more than one of them.<br>
<br></div></blockquote><div><br></div><div>The concept is that main, using =
this simple template class can be made the 'initial source of authority=
' for constructing RAII objects for=A0scares=A0resources. It can not &q=
uot;only be USED within the direct context of `main`", it's a toke=
n of authority that can only ORIGINATE within the direct context of `main` =
from where it can be discretionary delegated to other parts of the program,=
for example an object who's responsibility it is to instantiate only a=
single instance, or even=A0to instantiate only a single instance AND provi=
de a global=A0access=A0point to it.</div>
</div></div></div></div></blockquote><div><br>When I said that it "can=
only be used within the direct context of `main`," I meant `raiicap`,=
not the classes that use it. You can't do anything with `raiicap` outs=
ide of `main`. </div>
</blockquote><div><br></div></div><div>The raiicap is a discretionary token=
of authority that 'originates' at main, making logical computation=
al root and the compositional root conveniently fall together, and allowing=
the authority to use the constructor to be passed around in a discretionar=
y way. So saying that you can't do anything with raiicap outside of mai=
n is like saying you can't do anything with a factory created object ou=
tside of the factory.=A0</div>
<div class=3D"im">
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div>And again, this only works with one ver=
sion of `main`.<br>
<br></div></blockquote><div><br></div></div><div>Yes, this should be fixed,=
any version of main as defined in the standard should indeed be included a=
s a friend.</div><div class=3D"im"><div>=A0</div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left=
-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>I understand quite well what you're trying to do. I'm saying t=
hat not everyone <i>wants</i> singletons to be allocated by `main`. </div><=
/blockquote><div><br></div></div><div>The usecase is =A0a RAIIish 'alte=
rnative' to the 'limited or single resource' part Singletons th=
at does not imply the 'global access' part of the Singleton pattern=
.. So if people 'want' Singletons fall outside of the intended audie=
nce, and 'creating a Singleton' falls outside of the usecase.</div>
<div class=3D"im">
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div>And what of code that uses `int main()`=
, which is just as standard C++ as `int main(int argc, const char *argv)`?<=
/div>
</blockquote><div><br></div></div><div>Agreed.</div><div class=3D"im"><div>=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-styl=
e:solid;padding-left:1ex">
<div> There's also a fair amount of code out there that doesn't use=
`main` at all; either they're using `WinMain` or they're being cal=
led by some other library that <i>itself</i> uses `main`. You're effect=
ively saying that none of this code can use your helper class.<br>
</div></blockquote><div><br></div></div><div>The standard provides us with =
'main' as a logical computational root that we can use as compositi=
onal root concerning the authority to construct RAII objects. I propose the=
above as a facility that uses this logical computational root.=A0</div>
<div><br></div><div>If a specific compiler or a framework provides an alter=
native logical computational root that falls outside of the standard and th=
at effectively disables delegation of authority from the standard defined m=
ain to the compiler/framework specific computational root, than that would =
indeed be a problem. Do you have details =A0on how important compilers and =
frameworks obscure and inhibit the use of the standard defined main for the=
user?</div>
<div>For compiler builders I would think there should not be much of a prob=
lem to allow them to add an extra friend definition to raiicap (for example=
to winmain) for the version of the standard library that ships with their =
compiler, but maybe this is a no-go, I don't know.</div>
<div class=3D"im">
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div>If a significant number of C++ users w=
ould have to invent their own version of `raiicap` in order to use the arbi=
trary, then what good is it? If a user cannot force `raiicap` to use a spec=
ific function, rather than just one form of `main`, then you've limited=
the use cases for this tools a lot.<br>
</div></blockquote><div><br></div></div><div>I disagree, the user should no=
t be able to force=A0`raiicap` to use an arbitrary=A0function. The creator =
of a compiler or a framework that inhibits the direct use of main by the us=
er should ideally however be able to do discretionary=A0delegation of its a=
uthority to construct arbitrary raiicaps. Depending on the existence of=A0i=
mportant=A0real-life frameworks that would need this and dependent on the a=
bility of compiler vendors to extend the stl defined types, it may be a goo=
d idea for me to look into this and see if I can write an extended proposal=
that allows for this. In any case its essential that the creator of a libr=
ary that defines RAII classes should have no notion of the</div>
<div>framework, compiler etc that uses it.=A0</div><div class=3D"im"><div>=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-styl=
e:solid;padding-left:1ex">
<div><br>And what of the people who want to split up their `main` functions=
,=20
perhaps because they're getting rather big? What if it's more natur=
al to
put that initialization in some other function that's called by `main`=
?<br></div></blockquote><div><br></div></div><div>There is no problem there=
..</div><div class=3D"im"><div><br></div><div>=A0</div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border=
-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>Main is not the center of everyone's universe. Your tool is too re=
strictive. And C++ doesn't offer a way to generalize it to a user-provi=
ded function without employing macros. So I don't think it's a good=
tool.<br>
</div></blockquote><div><br></div></div><div>Basically discretionary delega=
tion is what makes the tool flexible. User provided functions would brake t=
he model and render the pattern useless. It might however be usefull to cha=
nge the proposal as to allow the delegation of a full 'root of authorit=
y' by framework builders.</div>
<div class=3D"im">
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex"><div><br></div><div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-le=
ft-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div><div class=3D"gmail_quote">
<div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-st=
yle:solid;padding-left:1ex"><div>There are far better ways to restrict the =
construction of an object instance to one or more specific functions than t=
his.</div>
</blockquote><div><br></div><div>Could you elaborate?<br></div></div></div>=
</div></blockquote></div><div><br>The same way you're doing it here, on=
ly without an intermediate, dependency-injected object. Make the class'=
s constructors of interest private and make the "one or more specific =
functions" that can allocate them friends.<br>
<br></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div>That way, it is the writer of =
the class who gets to decide which functions get to create it.</div>
</blockquote><div>=A0</div></div><div>What business does 'the writer of=
the class' have 'statically' determining what function gets to=
create it. My proposal allows the writer of the class to state: "The =
creator of the 'program' gets to do discretionary delegate the righ=
t to create".</div>
</div></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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--047d7b2e3e7aa6c72504d90ec580--
.
Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Fri, 29 Mar 2013 13:03:13 +0100
Raw View
--e89a8fb1ff183ee47404d90f0e32
Content-Type: text/plain; charset=ISO-8859-1
I think limiting to main() is a mistake. I have a lot of code which would
benefit from a way to force the type to be used only
by one non-main function OR one other type. A variation of your type which
allow specifying which function or type is the only user of the CRTP type
would be far more useful.
Joel Lamotte
--
---
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/?hl=en.
--e89a8fb1ff183ee47404d90f0e32
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think limiting to main() is a mistake. I have a lot of c=
ode which would benefit from a way to force the type to be used only=A0<div=
style>by one non-main function OR one other type. A variation of your type=
which allow specifying which function or type is the only user of the CRTP=
type would be far more useful.</div>
<div style><br></div><div style>Joel Lamotte</div><div style><br></div></di=
v>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--e89a8fb1ff183ee47404d90f0e32--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 29 Mar 2013 18:31:28 -0700 (PDT)
Raw View
------=_Part_1062_18622536.1364607088456
Content-Type: text/plain; charset=ISO-8859-1
On Friday, March 29, 2013 12:54:18 AM UTC-7, pibara wrote:
>
> 2013/3/28 Nicol Bolas <jmck...@gmail.com <javascript:>>
>
>> There's also a fair amount of code out there that doesn't use `main` at
>> all; either they're using `WinMain` or they're being called by some other
>> library that *itself* uses `main`. You're effectively saying that none
>> of this code can use your helper class.
>>
>
> The standard provides us with 'main' as a logical computational root that
> we can use as compositional root concerning the authority to construct RAII
> objects. I propose the above as a facility that uses this logical
> computational root.
>
`main` is not a "logical computational root". It isn't even the first code
that is required to be executed in a C++ application. It is merely the
first code that can assume that all globally-accessible objects have been
initialized.
My point is that this method only works if `main` is the root of your
application's code. It doesn't have to be, and people for whom this isn't
true would be unable to use your code, even if they did have a root.
> If a specific compiler or a framework provides an alternative logical
> computational root that falls outside of the standard and that effectively
> disables delegation of authority from the standard defined main to the
> compiler/framework specific computational root, than that would indeed be a
> problem. Do you have details on how important compilers and frameworks
> obscure and inhibit the use of the standard defined main for the user?
>
Well, since that would include a healthy percentage of Windows
applications, I'm guessing that it's a non-trivial number. Not to mention
every application plugin or DLLs in general.
> For compiler builders I would think there should not be much of a problem
> to allow them to add an extra friend definition to raiicap (for example to
> winmain) for the version of the standard library that ships with their
> compiler, but maybe this is a no-go, I don't know.
>
> If a significant number of C++ users would have to invent their own
>> version of `raiicap` in order to use the arbitrary, then what good is it?
>> If a user cannot force `raiicap` to use a specific function, rather than
>> just one form of `main`, then you've limited the use cases for this tools a
>> lot.
>>
>
> I disagree, the user should not be able to force `raiicap` to use an
> arbitrary function. The creator of a compiler or a framework that inhibits
> the direct use of main by the user should ideally however be able to do
> discretionary delegation of its authority to construct arbitrary raiicaps.
>
So, you want everyone to rewrite their frameworks and such, all to
accommodate a type that someone can just rewrite flawlessly *in less than a
minute*?
And of course, that doesn't deal with the C frameworks that call into C++
code, where such delegation is simply impossible.
Depending on the existence of important real-life frameworks that would
> need this and dependent on the ability of compiler vendors to extend the
> stl defined types, it may be a good idea for me to look into this and see
> if I can write an extended proposal that allows for this. In any case its
> essential that the creator of a library that defines RAII classes should
> have no notion of the
> framework, compiler etc that uses it.
>
>
>> Main is not the center of everyone's universe. Your tool is too
>> restrictive. And C++ doesn't offer a way to generalize it to a
>> user-provided function without employing macros. So I don't think it's a
>> good tool.
>>
>
> Basically discretionary delegation is what makes the tool flexible. User
> provided functions would brake the model and render the pattern useless. It
> might however be usefull to change the proposal as to allow the delegation
> of a full 'root of authority' by framework builders.
>
>
>>
>> There are far better ways to restrict the construction of an object
>>>> instance to one or more specific functions than this.
>>>>
>>>
>>> Could you elaborate?
>>>
>>
>> The same way you're doing it here, only without an intermediate,
>> dependency-injected object. Make the class's constructors of interest
>> private and make the "one or more specific functions" that can allocate
>> them friends.
>>
>> That way, it is the writer of the class who gets to decide which
>> functions get to create it.
>>
>
> What business does 'the writer of the class' have 'statically' determining
> what function gets to create it.
>
It's their class. The owner of a class has the right to determine who gets
to create it. That's what your entire construct relies upon: the owner of
the class must use this `raiicap` tag to force users to only create the
object if they have authorization to do so.
The only difference is who decides who has that authorization. In your
case, it's delegated to some other class. In my case, it's determined on a
class-by-class basis. So each class can decide, for themselves, who gets to
create them.
> My proposal allows the writer of the class to state: "The creator of the
> 'program' gets to do discretionary delegate the right to create".
>
"But only if the user has direct, modifiable access to `main`."
--
---
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/?hl=en.
------=_Part_1062_18622536.1364607088456
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Friday, March 29, 2013 12:54:18 AM UTC-7, pibara wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote=
">2013/3/28 Nicol Bolas <span dir=3D"ltr"><<a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"wq_CAjBl9uAJ">jmck...@gmail.com</a>&g=
t;</span><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px =
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-=
style:solid;padding-left:1ex">
<div> There's also a fair amount of code out there that doesn't use `main` =
at all; either they're using `WinMain` or they're being called by some othe=
r library that <i>itself</i> uses `main`. You're effectively saying that no=
ne of this code can use your helper class.<br>
</div></blockquote><div><br></div><div>The standard provides us with 'main'=
as a logical computational root that we can use as compositional root conc=
erning the authority to construct RAII objects. I propose the above as a fa=
cility that uses this logical computational root. <br></div></div></div></d=
iv></blockquote><div><br>`main` is not a "logical computational root". It i=
sn't even the first code that is required to be executed in a C++ applicati=
on. It is merely the first code that can assume that all globally-accessibl=
e objects have been initialized.<br><br>My point is that this method only w=
orks if `main` is the root of your application's code. It doesn't have to b=
e, and people for whom this isn't true would be unable to use your code, ev=
en if they did have a root.<br> </div><blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div></div><d=
iv>If a specific compiler or a framework provides an alternative logical co=
mputational root that falls outside of the standard and that effectively di=
sables delegation of authority from the standard defined main to the compil=
er/framework specific computational root, than that would indeed be a probl=
em. Do you have details on how important compilers and frameworks obs=
cure and inhibit the use of the standard defined main for the user?</div></=
div></div></div></blockquote><div><br>Well, since that would include a heal=
thy percentage of Windows applications, I'm guessing that it's a non-trivia=
l number. Not to mention every application plugin or DLLs in general.<br>&n=
bsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><di=
v><div class=3D"gmail_quote">
<div>For compiler builders I would think there should not be much of a prob=
lem to allow them to add an extra friend definition to raiicap (for example=
to winmain) for the version of the standard library that ships with their =
compiler, but maybe this is a no-go, I don't know.</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div>If a significant number of C++ users w=
ould have to invent their own version of `raiicap` in order to use the arbi=
trary, then what good is it? If a user cannot force `raiicap` to use a spec=
ific function, rather than just one form of `main`, then you've limited the=
use cases for this tools a lot.<br>
</div></blockquote><div><br></div><div>I disagree, the user should not be a=
ble to force `raiicap` to use an arbitrary function. The creator =
of a compiler or a framework that inhibits the direct use of main by the us=
er should ideally however be able to do discretionary delegation of it=
s authority to construct arbitrary raiicaps.</div></div></div></div></block=
quote><div><br>So, you want everyone to rewrite their frameworks and such, =
all to accommodate a type that someone can just rewrite flawlessly <i>in le=
ss than a minute</i>?<br><br>And of course, that doesn't deal with the C fr=
ameworks that call into C++ code, where such delegation is simply impossibl=
e.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div><div class=3D"gmail_quote"><div>Depending on the existence of =
important real-life frameworks that would need this and dependent on t=
he ability of compiler vendors to extend the stl defined types, it may be a=
good idea for me to look into this and see if I can write an extended prop=
osal that allows for this. In any case its essential that the creator of a =
library that defines RAII classes should have no notion of the</div>
<div>framework, compiler etc that uses it. </div><div> </div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddi=
ng-left:1ex">
<div>Main is not the center of everyone's universe. Your tool is too restri=
ctive. And C++ doesn't offer a way to generalize it to a user-provided func=
tion without employing macros. So I don't think it's a good tool.<br>
</div></blockquote><div><br></div><div>Basically discretionary delegation i=
s what makes the tool flexible. User provided functions would brake the mod=
el and render the pattern useless. It might however be usefull to change th=
e proposal as to allow the delegation of a full 'root of authority' by fram=
ework builders.</div>
<div> </div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div><br></div><div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border=
-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div><div class=3D"gmail_quote">
<div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-st=
yle:solid;padding-left:1ex"><div>There are far better ways to restrict the =
construction of an object instance to one or more specific functions than t=
his.</div>
</blockquote><div><br></div><div>Could you elaborate?<br></div></div></div>=
</div></blockquote></div><div><br>The same way you're doing it here, only w=
ithout an intermediate, dependency-injected object. Make the class's constr=
uctors of interest private and make the "one or more specific functions" th=
at can allocate them friends.<br>
<br></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div>That way, it is the writer of =
the class who gets to decide which functions get to create it.</div>
</blockquote><div> </div><div>What business does 'the writer of the cl=
ass' have 'statically' determining what function gets to create it.</div></=
div></div></div></blockquote><div> </div><div>It's their class. The ow=
ner of a class has the right to determine who gets to create it. That's wha=
t your entire construct relies upon: the owner of the class must use this `=
raiicap` tag to force users to only create the object if they have authoriz=
ation to do so.<br><br>The only difference is who decides who has that auth=
orization. In your case, it's delegated to some other class. In my case, it=
's determined on a class-by-class basis. So each class can decide, for them=
selves, who gets to create them.<br> </div><blockquote class=3D"gmail_=
quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pa=
dding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>My =
proposal allows the writer of the class to state: "The creator of the 'prog=
ram' gets to do discretionary delegate the right to create".</div></div></d=
iv></div></blockquote><div><br>"But only if the user has direct, modifiable=
access to `main`."<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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1062_18622536.1364607088456--
.
Author: Jonathan Wakely <cxx@kayari.org>
Date: Thu, 4 Apr 2013 09:27:31 -0700 (PDT)
Raw View
------=_Part_389_22784064.1365092851615
Content-Type: text/plain; charset=ISO-8859-1
Enforcing "Parameterise from Above" instead of the reprehensible Singleton
is nice, and this is a handy utility for a particular subset of PfA use
cases, but it is too specific to those particular use cases and doesn't
belong in the standard.
--
---
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/?hl=en.
------=_Part_389_22784064.1365092851615
Content-Type: text/html; charset=ISO-8859-1
Enforcing "Parameterise from Above" instead of the reprehensible Singleton is nice, and this is a handy utility for a particular subset of PfA use cases, but it is too specific to those particular use cases and doesn't belong in the standard.<br><br><br>
<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 email 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="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
------=_Part_389_22784064.1365092851615--
.
Author: Bb Hh <frankhb1989@gmail.com>
Date: Sun, 14 Apr 2013 11:11:53 +0800
Raw View
--20cf307ca13688007f04da497f15
Content-Type: text/plain; charset=ISO-8859-1
The ::main is particular. IIRC the standard forbids the "use" of global
main. There might be some non-trivial work to do, though I'm not sure if
there is any implementation depending on this.
2013/4/5 Jonathan Wakely <cxx@kayari.org>
> Enforcing "Parameterise from Above" instead of the reprehensible Singleton
> is nice, and this is a handy utility for a particular subset of PfA use
> cases, but it is too specific to those particular use cases and doesn't
> belong in the standard.
>
>
>
> --
>
> ---
> 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/?hl=en.
>
>
>
--
---
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/?hl=en.
--20cf307ca13688007f04da497f15
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The ::main is particular. IIRC the standard forbids the &q=
uot;use" of global main. There might be some non-trivial work to do, t=
hough I'm not sure if there is any implementation depending on this.<br=
>
</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2013/4/=
5 Jonathan Wakely <span dir=3D"ltr"><<a href=3D"mailto:cxx@kayari.org" t=
arget=3D"_blank">cxx@kayari.org</a>></span><br><blockquote class=3D"gmai=
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex">
Enforcing "Parameterise from Above" instead of the reprehensible =
Singleton is nice, and this is a handy utility for a particular subset of P=
fA use cases, but it is too specific to those particular use cases and does=
n't belong in the standard.<div class=3D"HOEnZb">
<div class=3D"h5"><br><br><br>
<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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=A0<br>
=A0<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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--20cf307ca13688007f04da497f15--
.