dlux42 <dlux@spam.sch.bme.hu> wrote:
And what if you use the deallocator as a template parameter?
+ It does not cost extra space + Don't need to use an extra reference-counted pointer - The interface is not consistent with shared_ptr
How about that? I would be happy to see this advancement in the scoped_ptr class.
The main reason that scoped_ptr doesn't provide this feature is that nobody made a convincing case for it. (An example of a convincing case: "In my project I have encountered the following situation: <description with real(istic sounding) identifiers> and I believe that scoped_ptr<X, D> would be a perfect fit." Some non-examples: "Someone might find it useful." "Wouldn't it be cool if...") I suspect that most people just use editor inheritance or specialize ~scoped_ptr.
Anyway: Do you know any smart-pointer class, which supports custom deallocator and can transfer ownership? (auto_ptr does not support custom deallocator and either smart_ptr or shared_ptr does not support release() method).
No. auto_ptr<X, D> would indeed be useful, but many compilers can't handle the machinery that is needed to build an auto_ptr, which is probably why there are few auto_ptr reimplementations and enhancements around.