Re: Compiler chooses conv ctor - why?
- From: "Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx>
- Date: Mon, 14 Apr 2008 15:25:45 -0400
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
.
- Follow-Ups:
- Re: Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Re: Compiler chooses conv ctor - why?
- References:
- Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Re: Compiler chooses conv ctor - why?
- From: Alex Blekhman
- Re: Compiler chooses conv ctor - why?
- From: Charles Wang[MSFT]
- Re: Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Re: Compiler chooses conv ctor - why?
- From: Alex Blekhman
- Re: Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Compiler chooses conv ctor - why?
- Prev by Date: Re: Compiler chooses conv ctor - why?
- Next by Date: Re: Array of char pointers.
- Previous by thread: Re: Compiler chooses conv ctor - why?
- Next by thread: Re: Compiler chooses conv ctor - why?
- Index(es):
Relevant Pages
|
Loading