Is it possible to use a custom delete file after creating std::shared_ptr without using new ?
My problem is that object creation is handled by the factory class, and its constructors and destructors are protected, which gives a compilation error, and I don't want to use new because of its shortcomings.
To clarify: I prefer to create generic pointers like this, which does not allow you to set a user remote (I think):
auto sp1 = make_shared<Song>(L"The Beatles", L"Im Happy Just to Dance With You");
Or I can create them like this, which allows me to meet the deleteter task via an argument:
auto sp2(new Song, MyDeleterFunc);
But the second uses new , which AFAIK is not as effective as the highest type of distribution.
Perhaps this is clearer: is it possible to get the benefits of make_shared<> , as well as a custom deleter? Does this mean that you need to write a distributor?
source share