Static Initialization Order in C++
<p>A common soution to the static initialization order problem in C++ is the "construct on first use" idiom. This idiom puts a function wrapper around your static object.</p>

<p>Without the idiom, you'd have:</p>

<pre><code>Foo bar;
</code></pre>

<p>With the idiom, you'd have:</p>

<pre><code>Foo &amp;bar()
{
   static Foo *ptr = new Foo();
   return *ptr;
}
</code></pre>

<p>Moving from the first to the second requires that all uses of <code>bar</code> change from <code>bar</code> to <code>bar()</code>. I'm in a situation where I can't make this change (far too many use sites, lose naturalness of use of <code>operator&lt;&lt;</code>). I've tried all sorts of syntactic contortions to find a way to implement this idiom that doesn't require that the call sites change.  I cannot find one. Does anybody in the community have a trick up their sleeve to allow this?</p>

<p>Thanks,
Dave</p>
