I'm working on some code with unique_ptrs and the like. The line is:
std::unique_ptr<char[], void(*)(void*)> result(..., std::free);
which works. I realize that the type that std::free gives is that second template parameter. I tried using:
std::unique_ptr<char[], decltype(std::free)> result(..., std::free);
which would be easier to read and less bug-prone. But I get errors related to <memory> and "instantiating a data member with a function type".
Would there be a way to do this?