Re: Making a smart pointer which works with incomplete types
Alf P. Steinbach wrote:
It's a very different design goal, and very different semantics.
No, it isn't. boost::shared_ptr is guaranteed to work with incomplete
types (as long as the type is complete at construction), and it does
*not* require the user to provide it with a deleter function. (The user
*can* provide one, but is not required to do so.)
The "No, it isn't" is incorrect.
The rest is correct, but unrelated.
Unrelated? So boost::shared_ptr just happens by lucky chance to
support incomplete types exactly the way I have been describing, even
though that's not the goal of boost::shared_ptr?
You got rid of the static pointer by adding needless complexity to the
usage of the smart pointer. You have failed to explain why that would be
a better idea.
You have failed to explain what the alleged "complexity" consists of.
The additional requirements for the usage of the smart pointer in your
two different solutions.
boost::shared_ptr and my variant do not need *any* additional
requirements whatsoever from the user, compared to a smart pointer
implementation which does not support incomplete types. They can be used
*exactly* as you would use a simple vanilla smart pointer which works
only for complete types.
Having to write even one single additional line compared to this is
useless complexity and is not needed.
You have failed to explain why you think the static pointer is a good
idea.
Because it doesn't change the public interface nor the usage of the
smart pointer in any way, compared to a basic smart pointer. Everything
happens automatically and opaquely.
Your solutions add extra requirements for the user. For no good reason.
You started by asking how to get rid of it
Where exactly?
and that's
inconsistent with present position, which begs the question, why the
change of heart?
You might have a point if I had asked how to get rid of the function
pointer, but I haven't.
The only thing I have asked is why the function pointer could not be
static rather than non-static.