|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-01-14 14:07:55
At 10:10 AM 1/14/2002, Peter Dimov wrote:
>You can't access SmartPtr::storage_policy in a member declaration since
>SmartPtr is incomplete at this point.
>
>You can access it in the member function body, though.
>
>Tying this to my previous question, what is the reason of the
>'pointer_type'
>(over)generalization? When is pointer_type not T*? std::allocator
flashes?
That question also occurred to me several times.
A simple nested inheritance hierarchy works particularly well if
pointer_type is always T* for the CheckingPolicy:
template < .... > // Same as Loki::SmartPtr
class smart_ptr
: public OwnershipPolicy<
StoragePolicy<
CheckingPolicy< T >, ConversionPolicy > >
{
...
};
Notice that because CheckingPolicy was allowed to assume pointer_type is
T*, the inheritance relationships are simpler. StoragePolicy can still
supply the typedefs, and OwnershipPolicy can use them. Neat and tidy.
(I made ConversionPolicy a policy of StoragePolicy; that still seems the
case to me.)
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk