Implicit copy constructor

Quote from n3337 12.3.1 / 3

The implicit copy / move constructor (12.8) is a transform constructor. An implicitly declared copy / move constructor is not an explicit constructor; it can be called for implicit type conversions.

Quote from ANSI ISO IEC 14882 2003

Implicit copy constructor (12.8) is a conversion constructor. The implicitly declared copy constructor is not an explicit constructor; it can be called for implicit type conversions.

I have no idea how copy-constructor can be used for implicit type conversions . And if this is a typo / error in the standard, why is it not fixed with C ++ 03? Any links and examples (if we can use it for type conversions ) are really appreciated.

+6
source share
2 answers

The copy constructor can transform from an object of a derived type by trimming it:

 struct A {}; struct B : A {}; B b; A a = b; // uses A::A(A const&) to convert B to A 
+8
source

In implict inline inside, the inline member function is defined inside the class definition. inline keyword not used

0
source

Source: https://habr.com/ru/post/925431/


All Articles