title: C++ implicit conversions
body: <p>Several comments on a recent answer of mine, <a href="https://stackoverflow.com/questions/862858/what-other-useful-casts-can-be-used-in-c/862896#862896">What other useful casts can be used in C++</a>, suggest that my understanding of C++ conversions is faulty. Just to clarify the issue, consider the following code:</p>
  
  <pre><code>#include &lt;string&gt;
  
  struct A {
      A( const std::string &amp; s ) {}
  };
  
  void func( const A &amp; a ) {
  }
  
  int main() {
      func( "one" );                  // error
      func( A("two") );           // ok
      func( std::string("three") );   // ok
  }
  </code></pre>
  
  <p>My assertion was that the the first function call is an error, becauuse there is no conversion from a const char * to an A. There is a conversion from a string to an A, but using this would involve more than one conversion. My understanding is that this is not allowed, and this seems to be confirmed by g++ 4.4.0 &amp; Comeau compilers. With Comeau, I get the following error:</p>
  
  <pre><code>"ComeauTest.c", line 11: error: no suitable constructor exists 
        to convert from "const char [4]" to "A"
        func( "one" );                    // error
  </code></pre>
  
  <p>If you can point out, where I am wrong, either here or in the original answer, preferably with reference to the C++ Standard, please do so.</p>
  
  <p><strong>And the answer from the C++ standard seems to be:</strong> </p>
  
  <blockquote>
    <p>At most one user-defined conversion
    (constructor or conversion function)
    is implicitly applied to a single value.</p>
  </blockquote>
  
  <p><strong>Thanks to Abhay for providing the quote.</strong></p>