|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-01 05:57:10
Daniel Frey wrote:
> David Abrahams wrote:
>> All types have a copy_ctor.
>
> I heard that several times, but I am still not sure if it's true. I
> think you are refering to the fact that the compiler generates a
> copy-ctor if the class doesn't provide one explicitly, right? But what
> happens if the compiler cannot create a copy-ctor? Consider:
>
> class A
> {
> A();
> A(A&);
> public:
> A(int) {}
> };
>
> class B
> {
> A a;
> public:
> B(int i) : a(i) {}
> };
>
> int main()
> {
> B b( 42 );
> }
Add
B b2( b );
and ask EDG:
Comeau C/C++ 4.3.0.1 (Aug 21 2002 15:45:32) for MS_WINDOWS_x86
Copyright 1988-2002 Comeau Computing. All rights reserved.
MODE:strict errors C++
"testbed.cpp", line 11: error: "A::A(A &)" is inaccessible
A a;
^
detected during implicit generation of "B::B(B &)" at line 19
1 error detected in the compilation of "testbed.cpp".
Or you could read 12.8, I guess. ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk