Tea For One

Blogs are like assholes. Everyone has one and most of them are full of shit.
Feb 02
Permalink

Misplaced intentions

One of the things I like about working with C++ is that I learn something new every day.  The language has some dark corners and thorny features that you might not run into under normal circumstances.  Today I learned all about placement new while tracking down a nasty memory leak.  Which leads me to today’s tip of the day:

If you choice to use an esoteric language feature in order to elegantly solve a difficult problem, that makes you a rockstar.  If you choice to use an esoteric language feature  where it is not absolutely necessary and proceed to use it incorrectly, that makes you a douchebag.

So folks, please remember to explicitly invoke the destructor for an object constructed with placement new.  Simply deallocating the buffer doesn’t cut it. 

Remember: only you can prevent yourself from being a douchebag.