• 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: STL set inside inside a class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: STL set inside inside a class


  • Subject: Re: STL set inside inside a class
  • From: Jan Brittenson <email@hidden>
  • Date: Wed, 17 May 2006 18:54:27 -0700

Paul Forgey wrote:


On May 17, 2006, at 4:10 PM, Jan Brittenson wrote:

Paul Forgey wrote:

That means depthCount[depth]++ will always do what you expect since the default instantiation of a simple scaler type is 0.


This is only true for statics.


In an STL container the behavior is defined. When a std::map inserts an element and the mapped_type of the value to insert is not specified, mapped_type () is used. The constructor instantiation of a simple scaler type is defined to be 0.

e.g.

int i; // undefined
int j = int (); // is 0.

Good point, you're right. I was thinking within the context of why the container might not be
properly constructed and got distracted.


If
the object is static, then its initializer may not have been called yet while some other static
object's initializer wants to call it; in this case review the link order, or the order in which
the static objects appear if they're in the same file.


My experience with any static object having a constructor is to just don't do it.

Absolutely. Couldn't agree more.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >STL set inside inside a class (From: mark <email@hidden>)
 >Re: STL set inside inside a class (From: Paul Forgey <email@hidden>)
 >Re: STL set inside inside a class (From: Jan Brittenson <email@hidden>)
 >Re: STL set inside inside a class (From: Paul Forgey <email@hidden>)

  • Prev by Date: Switching from -O3 to -Os causes my code to start crashing
  • Next by Date: Re: dead-code stripping, pass two...
  • Previous by thread: [OT]Static Objects (was Re: STL set inside inside a class)
  • Next by thread: Re: STL set inside inside a class (sorry. Fixed)
  • Index(es):
    • Date
    • Thread