Re: Making a smart pointer which works with incomplete types
* Juha Nieminen:
Alf P. Steinbach wrote:
You mean, by explaining things carefully, and even posting working code?
The first code you posted didn't work
I beg your pardon, it worked very nicely. I posted tested code to you. Don't lie.
because it required the type to be complete at destruction.
It did not have such requirement.
Perhaps you managed to misunderstand it.
Note that in all codes so far, including your own, there has been a function
that does the destruction, at a point where the type is complete; I'm assuming
that is not what you're referring to, since that would be a fallacy.
The second code might work but is unnecessarily complicated to use.
There's no need for such complication.
It's dead easy to use, but it's not as good a solution as the first.
What you have failed to do is to explain exactly *why* the code in my
original post is "absurd".
That is not a quote of me.
It's automatic, it's easy to use, it works
with incomplete types and it doesn't increment the size of the smart
pointer class. Exactly what is "absurd" there?
I don't know what you think is absurd, but the static pointer in there is, as I
wrote earlier, nonsensical. A very dirty trick to make the client code less
explicit, and less maintainable (think about replacing your smart pointer class
with something more general or just different), and less thread-safe, in a very
rare case. All in order to avoid 1 line of client code in that rare case.
You are simply struggling around the problem of admitting, that
perhaps it's not as "absurd" after all.
From my point of view it is a dirty hack. But it wasn't your hack. You asked
how to avoid it, and I've shown you some ways, and instead of whining and
worrying (but I notice that that wasn't until after an anonymous attack, don't
let those trolls influence you) I'd expect thanks for giving you solutions to
stated prob.
Cheers & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?