How does the custom deleter of std::unique_ptr work?

This works for me in MSVC10

int x = 5;
auto del = [](int * p) { std::cout << "Deleting x, value is : " << *p; };
std::unique_ptr<int, decltype(del)> px(&x, del);

And on gcc 4.5, here

I’ll skip going to the standard, unless you don’t think that example is doing exactly what you’d expect it to do.

Leave a Comment