Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

IMO move semantics, auto, lambdas and smart pointers have changed the way we write C++ dramatically. I work on both old and modern C++ codebases and the difference is like night and day...


I think I'd just give up and become a baker or something if I had to go back to pre c++11.


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.


I 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 ;-)


std::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.


Yes! Also, it significantly reduces the need for user defined destructors and move constructors/assignment operators.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: