title: std::ostream::operator<< not defined for std::string?
body: <p>I have stumbled upon an error for which I cannot grasp the reason.</p>
  
  <p>I think it basically gets down to this error:</p>
  
  <pre><code> error: no matching function for call to ‘std::basic_ostream&lt;char&gt;::operator&lt;&lt;(const std::basic_string&lt;char&gt;&amp;)’
  </code></pre>
  
  <p>I looked into specification on <a href="http://www.cplusplus.com/reference/iostream/ostream/operator%3C%3C/" rel="nofollow">www.cplusplus.com</a> and indeed it says there is no definition for <code>std::ostream::operator&lt;&lt;</code> with <code>std::string</code> as an argument.</p>
  
  <p>My question is, what happens when one writes <code>std_ostream_instance &lt;&lt; std_fancy_string;</code>. I believe it is one of the most common invocations ( e.g. <code>std::out &lt;&lt; std::string("Hello world!")</code> ) next to <code>const char*</code>.</p>
  
  <p>The error originates from these lines:</p>
  
  <pre><code>template&lt;typename T&gt; 
  void Log::_log(const T&amp; msg)
  {  _sink-&gt;operator&lt;&lt;( msg ); }
  </code></pre>
  
  <p><code>_sink</code> is defied as <code>std::ostream*</code>
  There are some wrapping functions around but it breaks here.</p>
  
  <p>I think I could work around by writing </p>
  
  <pre><code>template&lt;&gt; 
  void Log::_log&lt;std::string&gt;(const std::string&amp; msg) {
    _sink-&gt;operator&lt;&lt;( msg.c_str() );
  }
  </code></pre>
  
  <p>since there is <code>ostream&amp; operator&lt;&lt; (ostream&amp; out, const unsigned char* s );</code> defined by default.</p>
  
  <p>I just see no reason why it is not guessed automatically since it clearly works in simple use like <code>cout &lt;&lt; any_std_string</code>.</p>
  
  <p>Not sure if this is relevant but I want to be able to pass down through my log functions anything than can be handled by <code>std::ostream</code>. I used explicit non-templated declarations but decided to move to template for <code>log(const T&amp; anything_to_log)</code> to refacator it. It seemed plain stupid to have 5+ overloads. I get the error when I try compiling something like <code>Log::log( std::string("test case") )</code>.</p>
  
  <p>It looks like something stupid-simple but I cannot get it on my own. Tried to google and search stack to no avail.</p>
  
  <p>With regards, luk32.</p>
  
  <p>PS. I checked the work-around and it works. Why it's not implicitly done ?</p>