Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
conditions for automatic generation of default ctor, copy ctor,and default assignment operator (oper
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="James Kanze, post: 3524676"] I don't understand your reasoning. There's not a single const object in my example. The template constructor is chosen when the argument is a non-const lvalue, because the instantiation of the template (C::C(C&)) is a better match. The compiler generated copy constructor has the signature C::C( C const& ) (in this case), and will be called when the argument is const, or isn't an lvalue---both case in which the template constructor couldn't be called. Note that the compiler generated copy constructor doesn't always take a const reference---if the class contains a member or has a base whose copy constructor (user provided) takes a non-const reference, the the compiler generated copy constructor will also take a non-const reference. Such cases are (hopefully) rare, however. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
conditions for automatic generation of default ctor, copy ctor,and default assignment operator (oper
Top