Optimization in std::string based on same const literals
<p>We know compilers can reuse identical constant string literal to save memory efficiently. This optimization is optional for compilers.</p>

<p><em><a href="http://stackoverflow.com/q/13515561/952747">Two string literals have the same pointer value?</a></em></p>

<pre><code>const char *s1 = "HELLO";
const char *s2 = "HELLO";
</code></pre>

<p><code>s1</code> and <code>s2</code> can have same address. They have the same address in many compilers. For example, both are pointing to the address <code>0x409044</code>.</p>

<p>Well.</p>

<p>The question in my mind is, why <code>std::string</code> dosen't try to has same advantage? And it doesn't try to just wrap <code>std::string</code> around that address.</p>

<pre><code>const std::string ss1("HELLO");
const std::string ss2("HELLO");

cout &lt;&lt; (void*) ss1.c_str() &lt;&lt; endl;
cout &lt;&lt; (void*) ss2.c_str() &lt;&lt; endl;
</code></pre>

<p><code>ss1</code> and <code>ss2</code> have two distinct addresses.</p>

<p>Is it technically impossible? Prohibited by the language? Or the developers of implementations of the standard library just don't want it?</p>
