title: Invalid range expression of std::valarray in range for loop
body: <p>I have a simple usage of traversing a temporary <code>std::valarray</code> expression in range for loop, but got <strong><code>error</code>: invalid range expression ...</strong></p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;valarray&gt;
  
  int main()
  {
  
      std::valarray&lt;int&gt; xxx {2,7,1,8,2,8};
      std::valarray&lt;int&gt; zzz {xxx};
  
      for (auto x : xxx + zzz) std::cout &lt;&lt; x &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>clang++ main.cpp -std=c++11</p>
  
  <pre><code>main.cpp:10:17: error: invalid range expression of type 'std::__1::__val_expr&lt;std::__1::_BinaryOp&lt;std::__1::plus&lt;int&gt;, std::__1::valarray&lt;int&gt;, std::__1::valarray&lt;int&gt; &gt; &gt;'; no viable 'begin' function available
      for (auto x : xxx + zzz) std::cout &lt;&lt; x &lt;&lt; std::endl;
                  ^ ~~~
  </code></pre>
  
  <p><strong>Is there really a good reason that it does not compile as I expected?</strong>
  Return type of the overloaded <code>operator+</code> is <code>valarray&lt;T&gt;</code>, so theoretically, value of the expression should be a temporary instance of type <code>valarray&lt;T&gt;</code>.</p>
  
  <p><strong>Synopsis:</strong></p>
  
  <pre><code>template&lt;class T&gt; valarray&lt;T&gt; operator+ (const valarray&lt;T&gt;&amp; x, const valarray&lt;T&gt;&amp; y);
  </code></pre>
  
  <p><strong>Version:</strong> Apple LLVM version 8.0.0 (clang-800.0.38) Target: x86_64-apple-darwin15.6.0</p>
  
  <p><strong>Note</strong> following line works</p>
  
  <pre><code>for (auto x : xxx += zzz) std::cout &lt;&lt; x &lt;&lt; std::end;
  </code></pre>