Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

This post is not about the downsides of the language itself but those of proposing to your colleagues to implement in Modern C++. When I say, modern C++ I actually mean C++17 but for the most part C++14 specific features also count.

class my_class_t {
    int blah;
	// other blah blah

For a simple class like the above, more people expect the following as how the class is instantiated.

my_class_t *m = new my_class_t();

instead of:

auto m = std::make_unique<my_class_t>();

Once the scope of m expires, unless the pointer was moved to another scope the default destructor is called avoiding delete.

Everything’s too convenient

As I mentioned in an earlier post, this requires a different mindset from using the old school C approach to memory management. In some strange ways, relying on compilers, static checkers and analyzers for various facilities reduces the amount of attention paid to the code quality during code reviews.

For all it’s powers and beauty Modern C++ unlocks, I’d urge you to pay more attention to the code you write than ever before. Be paranoid, use all possible clang-tools as possible but also be thorough with code reviews.

Bring Your Own Cause

If you think any info here has remotely helped you consider dropping a penny for this cause, just click me . You can visit Unfortunately, there are plenty of sad things happening all over the world, if you have a different cause or charity you'd rather support please do. And if you did make a donation, please drop a note to me (annotated) or leave a comment here (anonymous is OK!) and I will use that as motivation to write more useful content here.

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes