J
Juha Nieminen
James said:And what is that price?
sizeof(T*) * amount_of_objects
James said:And what is that price?
Alf said:In the face of complete code demonstrating that that isn't necessary,
you maintain that it's necessary.
Worked fine for me.
I'm at a loss as for how you have managed to make them not work.
Also regarding the alleged complication.
Alf said:Demonstrated now two or three times
Well it isn't like that. It's not an either-or for the includes. And you
don't actually need to include anything for the instantiation.
You have misunderstood. There is no choice of header files. There's just
a choice of where to get a definition from: write it (1 line) or
#include it (1 line), which anyway makes that part very explicit, which
is good.
If you're not aware that you're dealing with incomplete type then
something is very wrong.
Yeah, except none of that is relevant.
You've argued the opposite earlier in this thread.
I didn't agree then
"I'm more worried about the space that pointer requires.
Making it static removes it from the smart pointer object, making the
smart pointer smaller and lighter. It seems to me that it's perfectly
possible to create a smart pointer class which works with incomplete
types without any overhead"
And yes, it's possible, and you've been shown how.
You've been given complete code that demonstrates that conclusion to be
false.
sizeof(T*) * amount_of_objects
James said:Maybe, maybe not. On a Sun Sparc, in 32 bit mode, the price is
0. (Allocation granularity is 8 bytes, to ensure alignment of a
double. The reference count is 4 bytes. There are thus 4 bytes
leftover when it is allocated. Just the size of a T*.)
Question: Will shared_ptr in the new standard support
user-defined custom allocators for the smart pointer to
allocate its data?
James said:I hope not. Too much added complexity for too little benefit.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.