"Chris M. Thomasson" <no@[EMAIL PROTECTED]
> wrote in message
news:Kc9Fk.39673$hX5.4784@[EMAIL PROTECTED]
> "Dmitriy V'jukov" <dvyukov@[EMAIL PROTECTED]
> wrote in message
>
news:aabd7f24-429e-4276-bbcc-790bbc4959b2@[EMAIL PROTECTED]
>> On Oct 2, 10:50 pm, "Chris M. Thomasson" <n...@[EMAIL PROTECTED]
> wrote:
>>
>> > Please correct me if I am wrong, but it seems as if this particular
>> > allocator interface would "need" to know what type it was dealing
with
>> > in
>> > advance; correct?
>>
>> Yes,
>>
>> > In other words, it probably could not be used to overload
>> > global operator new/delete right?
>>
>> Yes.
>>
>> > Or, is `derived_t' dealing with internal
>> > allocator structures. Where am I going wrong here Dmitriy? You know,
I
>> > was
>> > thinking about creating something special for C++. But, I am a C
>> > programmer,
>> > and felt the need to sup****t my language of choice. The cool thing
>> > about C++
>> > is that you can do exactly what you did. Also, you can overload class
>> > local
>> > delete operator and have it automatically return the size of the
>> > dynamic
>> > allocation be it single object or array. If the user allocated an
>> > array, you
>> > simply divide this size of object size, and bam you have array size.
>
>> It's not always true. For example:
>
>
> [...]
>
>
> Check this program out:
[...]
Okay. I see it works on array dtor. It does not work on single object
dtor... Please check this out! Run the origin program. I get an output
of:
custom_allocator::allocate(00246C50, 2234)
custom_allocator::deallocate(00246C50, 1234)
custom_allocator::allocate(00247760, 11174)
custom_allocator::deallocate(00247760, 11174)
Now, swap out the origin main function with the following:
int main() {
buf2* b = new buf2[1];
delete [] b;
b = new buf2[5];
delete [] b;
std::getchar();
return 0;
}
Here is the output I get now:
custom_allocator::allocate(00246C50, 2238)
custom_allocator::deallocate(00246C50, 2238)
custom_allocator::allocate(00247760, 11174)
custom_allocator::deallocate(00247760, 11174)
Wow... It works now! ****%T!!!!!
;^O


|