/ ARTICLES, C++

Placement new operator in C++

It is no secret that I am a big fan of C++. I love learning new ways to make my code more elegant and performant.

I work in embedded systems, and have done so in C++ for a few years, although now I am working on a beefier (but still embedded) system running java.

But one thing you will probably run into when programming for embedded systems, if you are using C++ is that you will most likely have some kind of memory map, or an object you would like to have allocated in a specific location.

This was lukely not overlooked by C++, but is normally an obscure use case, so I never got to learn it.

This article in Dr. Dobb's presents the placement new operator (a way to redefine how "new" works for your object), enabling you to do neat stuff with it, like passing an address as parameter.

Congratulations to Dan Saks on this highly recomended article.

rui

Rui Pires

Working as a professional full time remote developer from the Azores since 2011.

Read More