Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-21 07:28:18


From: "Darin Adler" <darin_at_[hidden]>
> On Friday, July 20, 2001, at 10:33 AM, Greg Colvin wrote:
>
> > I notice that http://users.utu.fi/sisasa/oasis/cppfaq/ctors.html#[10.10]
> > recommends the following idiom:
> >
> > Fred& x()
> > {
> > static Fred* ans = new Fred();
> > return *ans;
> > }
> >
> > when I would have expected
> >
> > Fred& x()
> > {
> > static Fred ans;
> > return ans;
> > }
> >
> > or am I missing something (as usual)?
>
> I prefer the latter too, which is why I said "the problem is mentioned"
> rather than "a good solution is mentioned" in my mention of _C++ FAQ
Lite_.

I prefer the latter, but there is a difference. In the first case the
singleton is never destructed.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk