4 ms·
It wouldn't be the same trait, for example https://stackoverflow.com/questions/43606777/why-is-class-with-non-const-copy-constructor-not-treated-as-copy-constr
by unddoch 1y ago
It wouldn't be the same trait, for example
https://stackoverflow.com/questions/43606777/why-is-class-with-non-const-copy-constructor-not-treated-as-copy-constructible https://stackoverflow.com/questions/43606777/why-is-class-wi...
- kazinator 1y agoYou mean, it still wouldn't be an accurate name? Maybe has_const_copy_constructor?
- unddoch 1y agoI guess it's better, but with C++ being C++, you will then need to decide if you consider struct A { A(const volatile& A); }; as a class with a const copy constructor. Maybe someone cares? Proper templated classes don't behave like this. If you manually define a copy constructor in a template class it has to work. And if it works only conditionally (like in many container classes) you need to add constraints on your constructors (>C++20) or derive from appropriately specialized base classes (e.g. std::_Optional_base in libstdc++). It sucks to tell users "you're holding it wrong", but I don't think there's a way to make it simpler without breaking everything written since C++11.
- kazinator 1y agoThe extra qualification doesn't prevent it from taking const objects, so ...