Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-05-11 11:32:44


From: Jason Hise <chaos_at_[hidden]>
> Rob Stewart wrote:
> >From: "Pavel Vozenilek" <pavel_vozenilek_at_[hidden]>
> >>"Rob Stewart" wrote:
[the next two levels of attributions were lost]
> >>
> >>>>>1. Creator policy is redundant with the standard Allocator concept, I
> >>>>>think. Though the standard Allocator concept has some subtle, tricky
> >>>>>semantics, I think it's nevertheless worth using: that would permit
> >>>>>interoperability with existing allocator implementations.
> >>>>>
> >>>>Thinking it again: you are likely right here.
> >>>>
> >>>>Handling of constructor arguments could be separated
> >>>>from allocation.
> >>>>
> >>>I don't know about that, but perhaps an adapter could be provided
> >>>to make a standard allocator look like a creator?
> >>>
> >>I should be possible w/o adapter. Just expecting std::allocator like
> >>parameter in template.
> >
> >That's only true if you separate the construction functionality
> >from the allocation. If you can't for some reason (I haven't
> >looked to see whether it is possible), an adapter can rely on the
> >allocator for its memory management.

Summary with implied but possibly misunderstood information:

OP: Creator policy is redundant with standard allocators.

Pavel: Maybe you're right; construction and allocation could be
handled separately.

Me: An adapter could be used to fit a standard allocator into the
creator mold.

Pavel: No need for an adapter; change template parameter list.

Me: That only works if you separate construction from allocation
since allocators don't construct from argument lists.

> Just to make sure... have you looked at create_using_std_allocator? It

Nope.

> is designed to make it easy to use anything that fits the description of
> a standard allocator, and allows you to specify whether or not failed
> allocation (returning null) results in a bad_alloc exception being thrown.

That sounds like just the adapter I was suggesting.

> I personally do not feel that creation and allocation are redundant.
> Allocation is initialization of memory, and creation is the
> initialization of an object.

I didn't say they were redundant, but that was the original
point being made.

> Additionally, I feel that it is important that creators be easy for
> client code to write when necessary. The current interface required for
> a singleton creator is, IMO, much simpler to meet than the interface for
> a standard allocator. Being able to write a creator makes it easy to
> wrap other existing libraries with singletons relatively quickly.

I agree. The simpler interface is superior to that of an
allocator for those writing a creator without need for an
allocator. However, for those clients with a standard allocator,
your create_using_std_allocator adapter gives the best of both
worlds.

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

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