From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-03-25 01:09:22
>> Will I be able to write:
>> any<fast_allocator> a;
>> values = a;
>> IOW, I don't think your proposal provides any means to convert between
>> 'any' with different allocators. And I'm not sure you can easily achieve
> Sure you can. You just store a copy of the allocator along with the data
> you are holding. The holders would look like this:
> virtual holder* clone() = 0
> holder* result = allocator.allocate(1);
> new (result) holder(value, allocator);
> return result;
Aha, that's what I was trying to say, but not very clearly. Yes, *this* will
work. But... it means that if you do
any<fast_allocator> a2 = a1;
Then value stored in a2 will be allocated using a1's allocator, not a2's.
Once any is created with a specific allocator, all copies will use the same
allocator, which is doubtful behaviour. In the example above, the
"fast_allocator" parameter has no effect at all.
Even if this behavior is desirable, you don't need to add template parameter
to 'any'. You can add template parameter to 'holder' only, and another
constructor, which allows to specify allocator.
> virtual void destroy() = 0
> Allocator allocator(this->allocator);
> This requires allocators to be CopyConstsructible, of course.
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk