Conversion operators
<p>This code is not compilable.
I can't find why in standard. Can someone explain?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

template&lt;typename T&gt;
class S
{
public:
   explicit S(const std::string&amp; s_):s(s_)
   {
   }
   std::ostream&amp; print(std::ostream&amp; os) const
   {
      os &lt;&lt; s &lt;&lt; std::endl;
      return os;
   }
private:
   std::string s;
};

template&lt;typename T&gt;
std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const S&lt;T&gt;&amp; obj)
{
   return obj.print(os);
}

/*template&lt;&gt;
std::ostream&amp; operator &lt;&lt; &lt;std::string&gt; (std::ostream&amp; os, const S&lt;std::string&gt;&amp; obj)
{
   return obj.print(os);
}*/

class Test
{
public:
   explicit Test(const std::string&amp; s_):s(s_)
   {
   }
   //operator std::string() const { return s; }
   operator S&lt;std::string&gt;() const { return S&lt;std::string&gt;(s); }
private:
   std::string s;
};

int main()
{
   Test t("Hello");
   std::cout &lt;&lt; t &lt;&lt; std::endl;
}
</code></pre>

<p>Compiler output:</p>

<pre><code>source.cpp: In function 'int main()':
source.cpp:47:17: error: no match for 'operator&lt;&lt;' in 'std::cout &lt;&lt; t'
source.cpp:47:17: note: candidates are:
In file included from include/c++/4.7.1/iostream:40:0,
                 from source.cpp:1:
include/c++/4.7.1/ostream:106:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; (*)(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp;)) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
include/c++/4.7.1/ostream:106:7: note:   no known conversion for argument 1 from 'Test' to 'std::basic_ostream&lt;char&gt;::__ostream_type&amp; (*)(std::basic_ostream&lt;char&gt;::__ostream_type&amp;) {aka std::basic_ostream&lt;char&gt;&amp; (*)(std::basic_ostream&lt;char&gt;&amp;)}'
....
</code></pre>
