Quote:
>> Why not? Just assign the deleter along with the pointer.
Yes, I know - I gave a bad excuse for that one.
New excuse: Doing this requires moving the functor type out of the template parameter list for ref_ptr<>. In order to do that, and still support a templated functor type, we'd have to mimic the boost::shared_ptr implementation (which is similiar to the functor implementation used by my thread class). I just didn't want the implementation to get that big for this "tutorial design review of a smart pointer" thread
I fail to see the problem. You don't need to implement anything, that's what Boost.Function does for you.
Quote:
>> For getting both of these, you either have to [keep what you have] or use something akin to Boost.Function.
I still don't see the benefit of using boost::function[N] or something like it. When the "ZeroRef" functor is a templated type, both of your example functors will always work (unless your compiler is broken). Notice that boost::shared_ptr simply uses a template argument for the functor type as ref_ptr does (not to say that they do it in the same way).
The benefit is that you don't need the additional template parameter and thus can pass around the pointers more freely. For example, you could have a std::list that stores smart pointers to integers from various sources. They could come from malloc, new, get_temporary_buffer, GlobalAlloc, LocalAlloc, HeapAlloc... and the deletion semantics of each one would still be ensured. If the deleter is a template parameter, this is not possible, because different deleters cause the pointer to be of a different type.