Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-09-28 08:39:31


Zeljko Vrba wrote:
> On Fri, Sep 28, 2007 at 12:55:07PM +0300, Peter Dimov wrote:
>>
>> That's what the A argument is for. You quoted the wrong clause.
>>
> Oh, sorry. You mean this constructor:
>
> template<class Y, class D, class A> shared_ptr(Y * p, D d, A a);
>
> A question: why is the API designed so that using a custom allocator
> forces the user to specify a deallocator? I.e. the two are
> orthogonal, so why force the (use A) => (must use D) implication?

Given an Allocator concept, it'd be possible to add

template<class Y, Allocator A> shared_ptr( Y * p, A a );

In practice, it's rare for the user to want to use a custom allocator for
the control block, yet not use a custom allocator for the object, so forcing
him to pass a deleter as well is not as constraining. One might even argue
that it removes the ambiguity that is present in the above form, where it
isn't clear whether A should be used to deallocate *p as well.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net