title: Iterating over a set
body: <p>I'm trying to write some code that overrides the &lt;&lt; operator for a given set, so it actually gives me the set between "{...}".</p>
  
  <pre><code>template&lt;typename T&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; out, const set&lt;T&gt; &amp; v){    
      iterator myIt = v.begin();
      out &lt;&lt; "{";
      while(myIt != v.end()-1) {
       out&lt;&lt;*myIt&lt;&lt;",";
       myIt++;
  }
  out &lt;&lt; *myIt &lt;&lt; "}";
  return out;
  }
  </code></pre>
  
  <p>However this does not seem to work, someone who is willing to give me some advice?</p>