title: Implementation of template of a << operator // C++
body: <p>I would want to make a template of a &lt;&lt; operator in C++, that would show a Object that is a &quot;range&quot; (by that i mean any object like : std::vector, std::set, std::map, std::deque). How can i achieve this? I've been googling and looking in docs for a few days now, but without any effect. I've been doing few templates and been overriding few operators before, but these were inside of a certain class that was representing a custom vector class. I cant seem to find a good way of implementing this, because it collides with a standard cout. How do i do it then, inside of a class that can pass a vector,set,map,deque as an argument, and operator inside? I would also want this operator to return the begin() and end() iterator of an object. By now i have this code:</p>
  <pre><code>template &lt;typename T&gt;
  ostream&amp; operator&lt;&lt;(ostream&amp; os, T something)
  {
      os &lt;&lt; something.begin() &lt;&lt; something.end();
      return os;
  }
  
  </code></pre>
  <p>it doesnt really work, and i think that experienced C++ programmer can explain me why.</p>
  <p>Thanks in advance for any answer for that problem.</p>