Hacker News new | ask | show | jobs
by nhaehnle 4484 days ago
Honestly, writing safe C++ code means just following a few rules of thumb. Most importantly: never do pointer arithmetic, always use smart pointers.

Basically, 99% of your work should use only about 10% of the feature set of C++ explicitly. The vast majority of the time, you shouldn't even write templates (just use the ones in the STL and project-specific ones that make sense).

But it's really nice that those other 90% of features are there when you need them.

2 comments

Your 10% is going to be different to my 10%. Almost all the C++ code I write includes new templates. Almost none of it includes inheritance.

I rarely use smart pointers that aren't implementation details (private class members)

Their should be a guide about how to write modern and unclutered C++ without the 90% of it.
And a compiler that only accepts the 10%.
"C++: The Good Parts"