Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-08-30 07:44:10


Phil Bouchard:

> template<class P, class D, class A>
> class sp_counted_impl_pda: public sp_counted_base
> {
> ...
> virtual void destroy() // nothrow
> {
> typedef typename A::template rebind< this_type >::other A2;
>
> A2 a2( a_ );
>
> this->~this_type();
> a2.deallocate( this, 1 );
> // ugh!
> }
> };
>
> This is ill-formed code.

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

> 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.


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