From 62ea451a03dbd33c293e53e6f6a777a23b87f18c Mon Sep 17 00:00:00 2001 From: "deanm@google.com" Date: Mon, 8 Sep 2008 15:20:57 +0000 Subject: 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 --- base/lazy_instance.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/lazy_instance.h b/base/lazy_instance.h index 33eefe8..0849503 100644 --- a/base/lazy_instance.h +++ b/base/lazy_instance.h @@ -64,7 +64,8 @@ class LazyInstanceHelper { }; 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 // created if neccessary. Constructs with |ctor| in the space provided by @@ -81,7 +82,8 @@ template > class LazyInstance : public LazyInstanceHelper { public: 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() { return *Pointer(); -- cgit v1.1