title: Overloading output stream operator for vector<T>
body: <p>What is a recommended way to overload the output stream operator? The following can <strike>not</strike> be done. It is expected that compilation will fail if the operator &lt;&lt; is not defined for a type T.</p>
  
  <pre><code>template &lt; class T &gt;
  inline std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const std::vector&lt;T&gt;&amp; v) 
  {
      os &lt;&lt; "[";
      for (std::vector&lt;T&gt;::const_iterator ii = v.begin(); ii != v.end(); ++ii)
      {
          os &lt;&lt; " " &lt;&lt; *ii;
      }
      os &lt;&lt; " ]";
      return os;
  }
  </code></pre>
  
  <p>EDIT: It does compile, the problem was unrelated and was in the namespace. Thanks for assistance.</p>