3 ms·
Smart pointers are not a language feature, and are generally a bad practice (shared ownership is a bad idea to begin with). Lambdas, just syntactic sugar for f
by mgaunard 4y ago
Smart pointers are not a language feature, and are generally a bad practice (shared ownership is a bad idea to begin with).
Lambdas, just syntactic sugar for function objects.
auto, you could just spell out the type and provide a mechanism to deduce it (e.g. the old result_of protocol).
Move semantics, this is simply distinguishing lvalues from rvalues in overload resolution. There were other ways to do that before albeit not as accessible to the layman.
- spacechild1 4y agoI generally disagree with your assessment, but the following needs to be called out in particular: > Smart pointers are not a language feature, and are generally a bad practice (shared ownership is a bad idea to begin with). Smart pointers don't imply shared ownership, see std::unique_ptr. Or is std::unique_ptr considered bad practice as well? That would certainly be news to me ;-)
- TillE 4y agostd::unique_ptr is of course the opposite of shared ownership, in that it requires you to explicitly transfer ownership if you need to do that. It's a beautiful feature which improves code clarity and reduces bugs.
- spacechild1 4y agoYes! Also, it significantly reduces the need for user defined destructors and move constructors/assignment operators.
- deleted 4y ago[deleted]