Is it possible to create function-static objects programmatically?
<p>I need to create a vector which holds the pointers to some static objects (e.g., a1, a2, a3). </p>

<pre><code>void foo()
{
    static TEST a1, a2, a3;
    static vector&lt;TEST *&gt; m_test;
    m_test.push_back( &amp;a1 );
    m_test.push_back( &amp;a2 );
    m_test.push_back( &amp;a3 );
}
</code></pre>

<p>But I don't want to have to write out the declaration for each <code>static</code> object.</p>

<p>How can I use a loop to do this? I have tried something like:</p>

<pre><code>    for (unsigned int i=0; i&lt;10; i++)
    {
        m_test.push_back( &amp;(static TEST()));
    }
</code></pre>

<p>But it seems the <code>static</code> doesn't have any effect inside an expression, as the objects get destroyed, as I'd expect from a normal temporary.</p>
