Quote from n3337 12.3.1/3
A non-explicit copy/move constructor (12.8) is a converting constructor. An implicitly-declared copy/move constructor is not an explicit constructor; it may be called for implicit type conversions.
Quote from ANSI ISO IEC 14882 2003
A non-explicit copy-constructor (12.8) is a converting constructor. An implicitly-declared copy constructor is not an explicit constructor; it may be called for implicit type conversions.
I have no ideas, how copy-constructor
can be used for implicit
type conversions
. And if it's misprint/error in standard, why it's not corrected since C++03 standard? Any links and examples (if we can use it for type conversions
) are really appreciated.
A copy constructor can convert from an object of a derived type by slicing it:
struct A {};
struct B : A {};
B b;
A a = b; // uses A::A(A const&) to convert B to A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With