title: templated conversion operator string() doesn't compile
body: <p>The following compiles in VS 2005 but not in 2010 or 2012: </p>
  
  <pre><code>#include &lt;string&gt;
  
  template &lt;typename TT&gt; TT getAs();
  template &lt;&gt;            std::string getAs() { return "bye"; }
  template &lt;&gt;            int getAs() { return 123; }
  
  class Foo
  {
  public:
      template &lt;typename TT&gt;
          TT getAs() const { return ::getAs&lt;TT&gt;(); }
  
      template &lt;typename TT&gt;
          operator TT() const { return ::getAs&lt;TT&gt;(); }
  };
  
  Foo tempFoo() { return Foo(); }
  
  int main()
  {
      Foo foo;
      std::string testStringLocal = foo;                            // OK in 2010, FAIL in 2012
      int testIntTemp = tempFoo();                                  // OK
      std::string testStringTemp = tempFoo().getAs&lt;std::string&gt;();  // OK
      const std::string&amp; testStringTemp2 = tempFoo();               // OK
  
      std::string testStringTemp3 = tempFoo();                    // FAIL!
  }
  </code></pre>
  
  <p>Compiler complains on two lines of <code>main()</code> that conversion not possible. But if I replace the template definition of <code>operator TT()</code> by a set of equivalent overloads, </p>
  
  <pre><code>class Foo
  {
  public:
      template &lt;typename TT&gt;
          TT getAs() const { return ::getAs&lt;TT&gt;(); }
  
      operator std::string() const { return ::getAs&lt;std::string&gt;(); }
      operator int() const { return ::getAs&lt;int&gt;(); }
  };
  </code></pre>
  
  <p>then everything builds fine. Note based on the <code>main()</code> lines that are marked OK that this problem is specific to template operator TT when string is template param AND (in 2010, but not in 2012) a temporary is involved. </p>
  
  <p>Is this not valid code? Why is it valid in some cases? </p>