title: C++: input and output stream operators: associativity
body: <p><strong>Input/Output stream operators associativity in theory:</strong></p>
  
  <p>LEFT TO RIGHT</p>
  
  <p>(for example, according to this: <a href="http://cs.smu.ca/~porter/csc/ref/cpp_operators.html" rel="nofollow">Sait Mary's University website</a></p>
  
  <p><strong>Input/Output stream operators associativity on practice:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int func0() {
    std::cout &lt;&lt; "func0 executed" &lt;&lt; std::endl;
    return 0;
  }
  
  int func1() {
    std::cout &lt;&lt; "func1 executed" &lt;&lt; std::endl;
    return 1;
  }
  
  int func2() {
    std::cout &lt;&lt; "func2 executed" &lt;&lt; std::endl;
    return 2;
  }
  
  int main() {
    std::cout &lt;&lt; func0() &lt;&lt; func1() &lt;&lt; func2() &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>Output (MSVCPP 2010, 2012):</p>
  
  <pre><code>func2 executed
  func1 executed
  func0 executed
  012
  Press any key to continue . . .
  </code></pre>
  
  <p>This sample demonstrates that functions are called in RIGHT TO LEFT order (despite of their values are printed as expected LEFT TO RIGHT).</p>
  
  <p><strong>The question:</strong>
  How this code sample correlates with Standard words about LEFT TO RIGHT execution? And why functions execution performed in RIGHT TO LEFT order?</p>