0

Just by implementing a destructor (even if it's not doing anything), MSVC will register a static initializer as to register the empty destructor. Pretty awesome. Verified that the c++ initializer is no longer in the __xc_a array.

Review URL: http://codereview.chromium.org/1812

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1841 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
deanm@google.com
2008-09-08 15:20:57 +00:00
parent f660b6a9ea
commit 62ea451a03

@ -64,7 +64,8 @@ class LazyInstanceHelper {
}; };
explicit LazyInstanceHelper(LinkerInitialized x) { /* state_ is 0 */ } explicit LazyInstanceHelper(LinkerInitialized x) { /* state_ is 0 */ }
~LazyInstanceHelper() { } // Declaring a destructor (even if it's empty) will cause MSVC to register a
// static initializer to register the empty destructor with atexit().
// Make sure that instance is created, creating or waiting for it to be // Make sure that instance is created, creating or waiting for it to be
// created if neccessary. Constructs with |ctor| in the space provided by // created if neccessary. Constructs with |ctor| in the space provided by
@ -81,7 +82,8 @@ template <typename Type, typename Traits = DefaultLazyInstanceTraits<Type> >
class LazyInstance : public LazyInstanceHelper { class LazyInstance : public LazyInstanceHelper {
public: public:
explicit LazyInstance(LinkerInitialized x) : LazyInstanceHelper(x) { } explicit LazyInstance(LinkerInitialized x) : LazyInstanceHelper(x) { }
~LazyInstance() { } // Declaring a destructor (even if it's empty) will cause MSVC to register a
// static initializer to register the empty destructor with atexit().
Type& Get() { Type& Get() {
return *Pointer(); return *Pointer();