what is wrong here? associativity? evaluation order? how to change order?
<p>The associativity of stream insertion operator is rtl, forgetting this fact sometimes cause to runtime or logical errors.
for example:</p>

<p>1st-</p>

<pre><code>int F()
{
   static int internal_counter c=0;
   return ++c;
}
</code></pre>

<p>in the main function:</p>

<pre><code>//....here is main()
cout&lt;&lt;”1st=”&lt;&lt;F()&lt;&lt;”,2nd=”&lt;&lt;F()&lt;&lt;”,3rd=”&lt;&lt;F();
</code></pre>

<p>and the output is:</p>

<pre><code>1st=3,2nd=2,3rd=1
</code></pre>

<p>that is different from what we expect at first look.</p>

<p>2nd-
suppose that we have an implementation of stack data structure like this:</p>

<pre><code>    //
    //... a Stack&lt;DataType&gt; class …… 
    //

    Stack&lt;int&gt; st(10);
    for(int i=1;i&lt;11;i++)
       st.push(i);

cout&lt;&lt;st.pop()&lt;&lt;endl&lt;&lt;st.pop()&lt;&lt;endl&lt;&lt;st.pop()&lt;&lt;endl&lt;&lt;st.pop()&lt;&lt;endl;
</code></pre>

<p>expected output is something like:</p>

<pre><code>10
9
8
7
</code></pre>

<p>but we have:</p>

<pre><code>7
8
9
10
</code></pre>

<p>There is no internal bug of &lt;&lt; implementation but it can be so confusing... 
and finally[:-)] my question: is there any way to change associativity of an operator by overloading it?</p>

<p>do you think this could be not reverse? i mean is it possible to change order by modifying or changing an open source STL?</p>
