You don’t need a stateful deleter in your unique_ptr (usually)

With the increasing probability of your average project using at least C++11, std::unique_ptr is one of the most popular solutions1 to dynamically managing memory in C++.

It usually goes like this: if your object can’t be a scoped object, that is one with automatic lifetime (colloquially: on the stack, or a class’s member), wrap it in std::unique_ptr. This will ensure it’s freed when it finally goes out of scope. Herb Sutter goes more in-depth into this topic in his last C++Con talk:

Herb Sutter: Leak-Freedom in C++… By Default.

This advice is sound and deserves being spread.

An erase/remove idiom gotcha

I was investigating a crash in my application recently. Despite working in the production environment, I was able to launch the debug version in a debugger (yay). Soon enough, I got a promising SIGSEGV in the expression implementing the erase-remove idiom:

vec.erase(std::remove_if(vec.begin(), vec.end(),
          [&orig](auto const& msg){
    return ==;

Can you spot the bug already?