Re: NSAutoreleasePool and static data member constructors
Re: NSAutoreleasePool and static data member constructors
- Subject: Re: NSAutoreleasePool and static data member constructors
- From: Uli Kusterer <email@hidden>
- Date: Thu, 11 Oct 2007 01:50:05 +0200
Am 11.10.2007 um 00:19 schrieb Clark Cox:
On 10/10/07, Uli Kusterer <email@hidden> wrote:
So, I don't think you can
use C++ smart pointers and the likes as instance variables. You /have
to/ use pointers and new and delete them properly.
Smart pointers take care of this for you.
Only if their constructors are called. But as we found out, they
are on 10.4, but if you deploy on 10.3 you'll want to use regular
pointers and new and delete your C++ objects.
The rest of your e-mail is spot on:
Global autorelease pool or pool created before main() - bad idea
Throwing exceptions across language boundaries - bad idea
You forgot: Implicitly or explicitly relying on initialization
order of globals or class-static variables - bad idea
This is really a matter too few C++ programmers are aware of: If
you have two object-type globals, and one uses the other from its
constructor, this is *a programming error*. You cannot know whether
your target object has already been constructed at the time the
constructor uses it.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden