Boost logo

Boost :

From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2002-09-22 11:26:26


"Peter Dimov" <pdimov_at_[hidden]> writes:

| From: "Gabriel Dos Reis" <gdr_at_[hidden]>
| >
| > A remarkable property about std::allocator<T> is that if it optimizes
| > for a given T then it is perfectly reasonable to expect
| > std::allocator<T>::template rebind<U>::other (for varying U) to
| > optimize equally well :-)
|
| The question is not whether I know that std::allocator<T>::template
| rebind<U>::other is std::allocator<U> (which I do), but whether

I perfectly understood that. That is why I didn't phrase my sentence
in terms of whether you knew std::allocator<T>::template
rebind<U>::other is an alternate name for std::allocator<U> or not.

| int * p = std::allocator<int>().allocate(1, 0);
| std::allocator<int>().deallocate(p, 1);
| long * q = std::allocator<long>().allocate(1, 0);
| std::allocator<long>().deallocate(q, 1);
| void * * r = std::allocator<void *>().allocate(1, 0);
| std::allocator<void *>().deallocate(r, 1);
|
| will reuse the same node when sizeof(int) ~= sizeof(long) ~= sizeof(void*),
| or it will result in a pessimization compared to plain new (which will reuse
| the node if it has a node allocator.)

I don't know what Dinkumware does. But I belive SGI-STL defived
implementations reuse nodes.

-- Gaby


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk