title: Clang typecasting using C++11 has ambiguous compiler behaviour
body: <p>Consider the following code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  class Foo {
  public:
    template&lt; typename T&gt; 
    operator vector&lt; T &gt;() const {
      return vector&lt; T &gt;();
    }
  
    template&lt; typename T&gt; 
    operator T() const {
      return T();
    }
  };
  
  int main () {
    Foo b;
    vector&lt; int &gt;  q = b;
    q = b;
  }
  </code></pre>
  
  <p>Compiling this with Clang or g++ using either of the two commands:</p>
  
  <pre><code>g++ test.cpp
  clang++ test.cpp
  </code></pre>
  
  <p>Enabling C++11 features, however, it fails:</p>
  
  <pre><code>g++ --std=c++0x test.cpp
  clang++ --std=c++11 test.cpp
  </code></pre>
  
  <p>The error message reads as follows:</p>
  
  <pre><code>test.cpp:20:5: error: use of overloaded operator '=' is ambiguous (with operand types 'vector&lt;int&gt;' and 'Foo')
    q = b;
    ~ ^ ~
  /usr/include/c++/4.6/bits/stl_vector.h:373:7: note: candidate function
        operator=(vector&amp;&amp; __x)
        ^
  /usr/include/c++/4.6/bits/stl_vector.h:362:7: note: candidate function
        operator=(const vector&amp; __x);
        ^
  /usr/include/c++/4.6/bits/stl_vector.h:394:7: note: candidate function
        operator=(initializer_list&lt;value_type&gt; __l)
        ^
  1 error generated.
  </code></pre>
  
  <p>It is unclear to me why it works without C++11, while it fails with. Moveover, note that the line</p>
  
  <pre><code>vector&lt; int &gt;  q = b; // In the main function, line 19
  </code></pre>
  
  <p>in the main function does not cause an error. Can anyone explain why it does not work, and what one can do to make it work with C++11?</p>