
On Aug 27, 2004, at 9:08 AM, Bronek Kozicki wrote:
David Abrahams wrote:
Bronek Kozicki <brok@rubikon.pl> writes:
Howard Hinnant wrote:
template<class T, class D = typename detail::default_delete<T>::type> class move_ptr;
why in type? This could be stored in trampoline function, stored together with pointer, something like this http://b.kozicki.pl/cpp/ext_auto_ptr_090.zip It's a space-vs-time tradeoff.
right, but do you really believe that deleter should belong to type? Tradeoff is really small (3 pointers more, no extra allocations), and it gives *runtime* choice of deleter. Thus with it you can write "source" function (the one returning smart pointer), and caller of this function does not need to know anything about deleter. Heck, you can even safely pass pointers and other things between dynamic libraries, each using its own copy of statically linked CRT.
I can see the utility of something like this. Perhaps we are talking about two different kinds of smart pointers, neither inherently better than the other. Sometimes you need hatchet, sometimes you need a carving knife. -Howard