Re: Compiler chooses conv ctor - why?
Cezary H. Noweta wrote:
Hello,
Alex Blekhman wrote:
struct Y {};
class X
{
public:
X() {}
X(Y) {}
private:
X(const X&);
};
int main()
{
Y y;
X x1 = y; // ill-formed, inaccessible cctor
X x2(y); // OK, direct initialization
return 0;
}
According to the standard `x1' instance cannot be constructed due to
inaccessible copy constructor (which may be eliminated during
construction of an object by the compiler, but the copy semantics
must be preserved anyway).
But this elimination is an element of the semantics (8.5[14]). Such
elimination involves an elimination of checking cctor access, doesn't
it?
Huh? Elimination of the copy is allowed, but not required. Even if it
is forgone (the compiler decides to optimize it away), the copy-ctor has
to be available _as_if_ it were used (12.8/15).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask