On Wed, 3 Apr 2013, Derek Gaston wrote:

It's simply not possible Roy.  The code to do the push_back is in
the same .C file with the thing it's trying to push_back on.  

Right.  Which doesn't matter.  C++ guarantees that two static objects
declared in the same file will be initialized in the order of
declaration, but it absolutely does not guarantee that a static object
declared in a file will be initialized before any object in any other
file calls any method in the first file.

If you
can't count on statics in the same .C file being created before you
try to use them.... then we're all screwed!

This is actually not too hard to fix.  We just use the "Construct on
First Use" idiom for the containers.  I'll demonstrate with a patch
shortly.

That static will get created when the translation unit is loaded to
run Singleton::Setup::Setup() (if not before then).  

No, it really really won't.  There is no "interrupt one constructor to
run another just-in-time" code in C++.
---
Roy
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to