Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-08-30 20:49:08


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:006401c90a95$cfd70570$6507a80a_at_pdimov2...

[...]

> I don't think you know what "ill-formed" means.

I meant dangerous if not classified undefined when you delete the class
indirectly (wrote too fast). Now I just realized destroy() should be used:

        a2.destroy( this );
        a2.deallocate( this, 1 );

>> The way shared_ptr works right now, the pool is going to be copied
>> entirely on to the sp_counted_impl_pda object.
>
> shared_ptr requires that the A argument conforms to the Allocator
> requirements in the standard (Table 40 in N2691):
>
> a1 == a2 bool returns true iff storage allocated from each can be
> deallocated via the other. operator== shall be reflexive, symmetric, and
> transitive.
>
> X a1(a); post: a1 == a
>
> X a(b); post: Y(a) == b, a == X(b)
>
> Your example is not an Allocator.

Interesting but unfortunate we cannot mix pools within allocators because it
makes allocators even less flexible (useful).

Secondly the pointer argument of deallocate() and destroy() should be passed
in as references because:
- you have better control
- the allocator knows what need to be done according to the pointer type

And shouldn't necessarily be the same as the one returned by allocate().

-Phil


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