title: Recursive vector template
body: <p>I've written the following piece of code:</p>
  
  <pre><code>template&lt;typename T&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; os, const vector&lt;T&gt;&amp; v) {
      os &lt;&lt; "{";
      for (auto i=v.begin(); i!=v.end(); ++i) {
          os &lt;&lt; *i &lt;&lt; " ";
      }
      os &lt;&lt; "}";
      return os;
  }
  </code></pre>
  
  <p>This works fine for regular <code>vector&lt;int&gt;</code> instances, but what I want to do is this:</p>
  
  <pre><code>vector&lt;vector&lt;int&gt; &gt; v={{1,2},{3,4}}
  cout &lt;&lt; v; // Should print {{1 2 } {3 4 } }
  </code></pre>
  
  <p>Instead, I get compilation errors (the following text, with a long list of candidates): <code>test.cpp|212|error: no match for 'operator&lt;&lt;' (operand types are 'std::ostream {aka std::basic_ostream&lt;char&gt;}' and 'std::vector&lt;std::vector&lt;int&gt; &gt;')|</code></p>
  
  <p>I'd have thought the templated function could be used twice, recursively. Am I wrong? If not, what gives? If so, is there some way to make this generic without duplicating code?</p>