Explicit copy constructor behavior and pratical uses
<p>A recent question got me wondering about explicit copy constructors. Here is a sample code that I tried compiling under Visual Studio 2005 :</p>

<pre><code>struct A
{
    A() {}
    explicit A(const A &amp;) {}
};

// #1 &gt; Compilation error (expected behavior)
A retByValue()
{
    return A();
}

// #2 &gt; Compiles just fine, but why ?
void passByValue(A a)
{
}

int main()
{
    A a;
    A b(a); // #3 &gt; explicit copy construction : OK (expected behavior)
    A c = a; // #4 &gt; implicit copy construction : KO (expected behavior)

    // Added after multiple comments : not an error according to VS 2005.
    passByValue(a);
    return 0;
}
</code></pre>

<p>Now for the questions :</p>

<ul>
<li>Is #2 allowed by the standard ? If it is, what is the relevant section describing this situation ?</li>
<li>Do you known of any practical use for an explicit copy constructor ? </li>
</ul>

<p><strong>[EDIT]</strong> I just found a funny link on <a href="http://msdn.microsoft.com/en-us/library/h1y7x448.aspx">MSDN</a> with the exact same situation, and a mysterious comment from the main function : "c is copied" (as if it was obvious). As pointed by Oli Charlesworth : gcc does not compile this code and I believe he's right not to.</p>
