|
Boost : |
From: Ion Gaztañaga (ion_g_m_at_[hidden])
Date: 2005-03-24 04:02:10
Hi to all,
Shmem library makes use of pointer typedef to use a smart relative pointer
as allocator::pointer to be able to put containers in shared memory.
Standard allows considering pointer as T* and that allocators of equal type
are equals, but using typedefs and comparing allocators at run-time opens a
new way to use containers. In my case in shared memory.
boost::unordered_* family uses does not suppose allocator typedefs and uses
(for example, uses construct instead of placement new) and because of that
we will be able to place it in shared memory to create in memory data-bases.
In my opinion, since it does not hurt, if you respect allocator typedefs and
functions, you can get some advantages. Regards,
Ion
----- Original Message -----
From: "Tom Widmer" <tom_usenet_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, March 23, 2005 3:57 PM
Subject: [boost] Re: How much should I care about allocators?
> Michael Stevens wrote:
>
>> GCC is correct. There is a get out clause in the library standard. Look
>> at section 20.1.5 "Allocator requirements" paragraph 4:
>>
>> Implementations of containers described in this International Standard
>> are permitted to assume that their Allocator template parameter meets the
>> following two additional requirements beyond those in Table 32. All
>> instances of a given allocator type are required to be interchangeable
>> and always compare equal to each other. The typedef members pointer,
>> const_pointer, size_type, and difference_type are required to be T*, T
>> const*, size_t, and ptrdiff_t, respectively.
>>
>> I suspect many implementation (including those not in the standard) have
>> this requirement!
>
> Dinkumware's library doesn't. It is certainly something to strive for when
> writing a container, since otherwise your container cannot be used with
> certain useful allocators.
>
> Tom
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk