mercredi 15 avril 2015

Why can't unique_ptr infer the type of the deleter?

Let's say I want to use a custom deleter with an unique_ptr:



void custom_deleter(int* obj)
{
delete obj;
}


Why do I have to write this:



std::unique_ptr<int, void(*)(int*)> x(new int, custom_deleter);


instead of this:



std::unique_ptr<int> x(new int, custom_deleter); //does not compile


?


Can't the type of the deleter be inferred?


Aucun commentaire:

Enregistrer un commentaire