• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSAutoreleasePool and static data member constructors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSAutoreleasePool and static data member constructors
      • From: "Clark Cox" <email@hidden>
References: 
 >NSAutoreleasePool and static data member constructors (From: Erik Buck <email@hidden>)
 >Re: NSAutoreleasePool and static data member constructors (From: "Clark Cox" <email@hidden>)
 >Re: NSAutoreleasePool and static data member constructors (From: Uli Kusterer <email@hidden>)
 >Re: NSAutoreleasePool and static data member constructors (From: "Clark Cox" <email@hidden>)

  • Prev by Date: How an I get an NSAttributedString into an NSView?
  • Next by Date: Re: display int in cocoa
  • Previous by thread: Re: NSAutoreleasePool and static data member constructors
  • Next by thread: Re: NSAutoreleasePool and static data member constructors
  • Index(es):
    • Date
    • Thread