Declare static variable inside a function call in C++
<p>I have a C++ program with many thousands of string literals in the code which need to be translated, for example:</p>

<pre><code>statusBar-&gt;Print( "My Message" );
</code></pre>

<p>I wrapped the string literals with a function which looks up the value in a dictionary and returns the translated version:</p>

<pre><code>statusBar-&gt;Print( Translated( "My Message" ) );
</code></pre>

<p>The problem is that after profiling I've discovered that doing this look up all over the code is a performance problem.  What I'd like to do is change lines like that to:</p>

<pre><code>static const char * translatedMessage5 = Translated( "My Message" );
statusBar-&gt;Print( translatedMessage5 );
</code></pre>

<p>But due to the many thousands of instances of this in the code, it's going to be error prone (and a bit of a maintenance nightmare).  I was hoping that I could turn <code>Translated</code> into a macro which declared the static variable in-line.  This obviously doesn't work.  Anyone have a better idea?</p>
