Topic: Allowing constructors to apply
Author: Arthur Tchaikovsky <atch.cpp@gmail.com>
Date: Mon, 24 Jun 2013 09:14:21 +0100
Raw View
Hi, perhaps instead of static the default keyword would be more
appropriate as it will suggest that object will get initialized to its
default values?
On 6/23/13, Johannes Schaub <schaub.johannes@googlemail.com> wrote:
>
>
> On Sunday, June 23, 2013 2:01:35 PM UTC+2, Johannes Schaub wrote:
>>
>>
>>
>> (Thanks to Xeo for proposing "static" to abuse for this).
>>
>
> Oops. Looks like I confused those nick names. FredOverflow proposed the
> abuse: http://chat.stackoverflow.com/transcript/message/10161711#10161711
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Johannes Schaub <schaub.johannes@googlemail.com>
Date: Mon, 24 Jun 2013 10:19:44 +0200
Raw View
2013/6/24 Arthur Tchaikovsky <atch.cpp@gmail.com>:
> Hi, perhaps instead of static the default keyword would be more
> appropriate as it will suggest that object will get initialized to its
> default values?
>
Not necessarily
struct HelperStruct {
A(Manager *m)
:static A{m->factory(), m->layouter()} {
m->prepare();
}
shared_ptr<Factory> factory;
shared_ptr<Factory> layouter;
};
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Arthur Tchaikovsky <atch.cpp@gmail.com>
Date: Mon, 24 Jun 2013 10:42:18 +0100
Raw View
But if you doing something like your last example then the whole point
of having mechanizm of let's call it here "nullifying" object is
pointless, because you can already achieve what you've just did in
your last example, with "regular" ctors, or am I missing something?
On 6/24/13, Johannes Schaub <schaub.johannes@googlemail.com> wrote:
> 2013/6/24 Arthur Tchaikovsky <atch.cpp@gmail.com>:
>> Hi, perhaps instead of static the default keyword would be more
>> appropriate as it will suggest that object will get initialized to its
>> default values?
>>
>
> Not necessarily
>
> struct HelperStruct {
> A(Manager *m)
> :static A{m->factory(), m->layouter()} {
> m->prepare();
> }
>
> shared_ptr<Factory> factory;
> shared_ptr<Factory> layouter;
> };
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: the.ultimate.koala@gmail.com
Date: Sun, 1 Sep 2013 03:52:51 -0700 (PDT)
Raw View
------=_Part_2423_18151591.1378032771277
Content-Type: text/plain; charset=ISO-8859-1
Can't you do this by delegating to a private constructor ?
struct HelperStruct {
A(Manager *m)
: A{m->factory(), m->layouter()} {
m->prepare();
}
shared_ptr<Factory> factory;
shared_ptr<Factory> layouter:
private:
A(const shared_ptr<Factory>& factory_, const shared_ptr<Factory>&
layouter_)
: factory{factory_}, layouter{layouter_} {
}
}
On Monday, June 24, 2013 10:19:44 AM UTC+2, Johannes Schaub wrote:
>
> 2013/6/24 Arthur Tchaikovsky <atch...@gmail.com <javascript:>>:
> > Hi, perhaps instead of static the default keyword would be more
> > appropriate as it will suggest that object will get initialized to its
> > default values?
> >
>
> Not necessarily
>
> struct HelperStruct {
> A(Manager *m)
> :static A{m->factory(), m->layouter()} {
> m->prepare();
> }
>
> shared_ptr<Factory> factory;
> shared_ptr<Factory> layouter;
> };
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2423_18151591.1378032771277
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Can't you do this by delegating to a private constructor ?=
<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,=
250); border-color: rgb(187, 187, 187); border-style: solid; border-width:=
1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"sub=
prettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">&nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">HelperStruct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br> A<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">Manager</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">m</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> <br> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> A</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">m</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">-></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>factory</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">-></span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">layouter</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> <br> m</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">-></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">prepare</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> <br> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br> <br> &n=
bsp; shared_ptr</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</span><span style=3D"color: #606;" class=3D"styled-by-prettify">F=
actory</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> factory</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> <br> &n=
bsp; shared_ptr</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</span><span style=3D"color: #606;" class=3D"styled-by-prettify">F=
actory</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> layouter<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">private</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br> =
A</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(const <=
/span><code class=3D"prettyprint"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">shared_ptr</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Factory</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">& factory</span></code><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">_, </span><code class=3D"prettyprint"><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">const </span><code class=3D"prettypr=
int"><span style=3D"color: #000;" class=3D"styled-by-prettify">shared_ptr</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Factory</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">& layouter</span></code=
><span style=3D"color: #000;" class=3D"styled-by-prettify"></span></code><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">_)</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> <br> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> factory{factory_}, la=
youter{layouter_}</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=
</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span></div></code></div><br><br><br>On Monday, June 24, 2013 10:19:44 AM U=
TC+2, Johannes Schaub wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">20=
13/6/24 Arthur Tchaikovsky <<a href=3D"javascript:" target=3D"_blank" gd=
f-obfuscated-mailto=3D"qm8lqDpcMxwJ">atch...@gmail.com</a>>:
<br>> Hi, perhaps instead of static the default keyword would be more
<br>> appropriate as it will suggest that object will get initialized to=
its
<br>> default values?
<br>>
<br>
<br>Not necessarily
<br>
<br> struct HelperStruct {
<br> A(Manager *m)
<br> :static A{m->factory(), m->layouter()=
} {
<br> m->prepare();
<br> }
<br>
<br> shared_ptr<Factory> factory;
<br> shared_ptr<Factory> layouter;
<br> };
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2423_18151591.1378032771277--
.