title: What rules govern use of multiple user-defined conversions between types?
body: <p>I have this code:</p>
  
  <pre><code>class MyString
  {
  public:
      operator const char*() const {
          return nullptr;
      }
  };
  
  class YourString
  {
  public:
      YourString() {}
      YourString(const char* ptr) {
          (void)ptr;
      }
  
      YourString&amp; operator=(const char* ptr)
      {
          return *this;
      }
  };
  
  int main()
  {
      MyString mys;
  
      YourString yoursWorks;
      yoursWorks = mys;
  
      YourString yoursAlsoWorks(mys);
  
      YourString yoursBreaks = mys;
  }
  </code></pre>
  
  <p>MSVC accepts it without issue. Clang-CL does not accept it:</p>
  
  <pre><code>$ "C:\Program Files\LLVM\msbuild-bin\CL.exe" ..\string_conversion.cpp
  ..\string_conversion.cpp(32,13):  error: no viable conversion from 'MyString' to 'YourString'
          YourString yoursBreaks = mys;
                     ^             ~~~
  ..\string_conversion.cpp(10,7):  note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'MyString' to
        'const YourString &amp;' for 1st argument
  class YourString
        ^
  ..\string_conversion.cpp(10,7):  note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'MyString' to
        'YourString &amp;&amp;' for 1st argument
  class YourString
        ^
  ..\string_conversion.cpp(14,2):  note: candidate constructor not viable: no known conversion from 'MyString' to 'const char *' for 1st argument
          YourString(const char* ptr) {
          ^
  ..\string_conversion.cpp(5,2):  note: candidate function
          operator const char*() const {
          ^
  1 error generated.
  </code></pre>
  
  <p>Nor does GCC:</p>
  
  <pre><code>$ g++.exe -std=gnu++14 ..\string_conversion.cpp
  ..\string_conversion.cpp: In function 'int main()':
  ..\string_conversion.cpp:33:27: error: conversion from 'MyString' to non-scalar type 'YourString' requested
    YourString yoursBreaks = mys;
                             ^
  </code></pre>
  
  <p>I understand that only one user-defined conversion is allowed.</p>
  
  <p>However, is MSVC justified in treating the line </p>
  
  <pre><code>YourString yoursBreaks = mys;
  </code></pre>
  
  <p>as </p>
  
  <pre><code>YourString yoursBreaks(mys);
  </code></pre>
  
  <p>and accepting it? Is that a conversion compilers are allowed to do? Under what rules is it allowed/disallowed? Is there a similar rule?</p>
  
  <p>Update: With MSVC, the <code>/Za</code> flag causes the code to not be accepted.</p>
  
  <pre><code>$ "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe" /Za ..\string_conversion.cpp
  
  string_conversion.cpp
  ..\string_conversion.cpp(33): error C2440: 'initializing': cannot convert from 'MyString' to 'YourString'
  ..\string_conversion.cpp(33): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  </code></pre>