4 ms·
"The implicitly-declared or defaulted copy constructor for class T is defined as deleted if any of the following conditions are true ... T has a user-defined m
by tlb 8y ago
"The implicitly-declared or defaulted copy constructor for class T is defined as deleted if any of the following conditions are true ... T has a user-defined move constructor or move assignment operator" (since C++11)
https://en.cppreference.com/w/cpp/language/copy_constructor https://en.cppreference.com/w/cpp/language/copy_constructor
But there's no harm in explicitly deleting it, and it helps document the intent.
- _pmf_ 8y agoWhat's the motivation behind this?
- tlb 8y agoThe committee probably observed that in most cases where people wanted a move constructor, they needed either no copy constructor or a more complicated one (to handle duplicating a resource.) So creating a default copy constructor (a convenience in the common case of a simple structure) wasn't a win. Perhaps if you were designing C++ from scratch without legacy and had a more Python-like mindset, you'd require an explicit "= default" rather than complicated rules about whether a default is provided for you or not.
- deleted 8y ago[deleted]