Boost logo

Boost :

Subject: Re: [boost] Proposal: Monotonic Containers
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-06-09 10:16:19


joaquin_at_[hidden] wrote
On Tuesday, June 09, 2009 10:03 AM
> Stewart, Robert escribió:
>
> > If custom_allocator<node<T> > is not specialized to do the same as
> > custom_allocator<T>, or to use the same memory pool, then it
> > doesn't fit the proposal.
>
> Point conceded, but how would you do otherwise? Specifying a
> custom allocator is your only way to affect the container's
> allocation behavior. Seems like you're implying that the
> container wrapping approach is in some way more powerful than
> directly specifying the custom allocator, which is not.

My intention was to point out the deficiency of the allocator approach, but I should also have highlighted the deficiency of simply extending the node based containers via derivation. With knowledge of implementation details, that may be sufficient, but it would require potentially different details for each supported platform. That, of course, implies the need to rewrite the node based containers to have complete control.

> Your only chance to solve the problem you mention is to make
> custom_allocator<node_type<T> > use the same memory pool.
> There's a way to do this.
>
> If you construct the container with
>
> custom_allocator<T> a;
> xxx<T,...,custom_allocator<T> > x(a);
>
> then xxx will use an object of type custom_allocator<node<T>
> for its allocation needs, which perforce will be an object
> differnt to the allocator a you've passed; but the container
> is required to construct this internal allocator as a copy of
> a:
>
> // inside xxx implementation
> custom_allocator<node<T> > internal_a(a);
>
> So you can use this knowledge to pass info around, for
> instance on the memory pool to be used.

Interesting. That complicates the allocator, but it seems like it could work. The remaining issue, of course, is how the memory pools are managed since sizeof(node<T>) is not likely sizeof(T).

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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