title: Printing an std::array
body: <p>So, while playing around with std::array, I wanted an easy way to print out all elements of an array, and tried the following:</p>
  
  <pre><code>using namespace std;
  
  template &lt;class T, int N&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; o, const array&lt;T, N&gt;&amp; arr)
  {
      copy(arr.cbegin(), arr.cend(), ostream_iterator&lt;T&gt;(o, " "));
      return o;
  }
  
  int main()
  {
      array&lt;int, 3&gt; arr {1, 2, 3};
      cout &lt;&lt; arr;
  }
  </code></pre>
  
  <p>However, whenever I try to run this, I get the following errors:</p>
  
  <pre><code>test.cpp: In function 'int main()':
  test.cpp:21:10: error: cannot bind 'std::ostream {aka std::basic_ostream&lt;char&gt;}' lvalue to 'std::basic_ostream&lt;char&gt;&amp;&amp;'
  c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/ostream:581:5: error:   initializing argument 1 of 'std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;&amp;, const _Tp&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Tp = std::array&lt;int, 3u&gt;]'
  </code></pre>
  
  <p>Any ideas on what this error means, and how I would go about fixing it?</p>
  
  <p>If I replace operator&lt;&lt; with a function like template&lt;...> print_array(const array&amp;), the error changes:</p>
  
  <pre><code>test.cpp: In function 'int main()':
  test.cpp:20:17: error: no matching function for call to 'print_array(std::array&lt;int, 3u&gt;&amp;)'
  test.cpp:20:17: note: candidate is:
  test.cpp:12:6: note: template&lt;class T, int N&gt; void print_array(const std::array&lt;T, N&gt;&amp;)
  </code></pre>