Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-05-01 23:13:12


"Andrei Alexandrescu" <andrewalex_at_[hidden]> wrote in message
news:aaqd13$8sr$1_at_main.gmane.org...
> [...]
> Now when defining smart_ptr, the policies come wrapped in
> OptionallyInherit:
>
> template
> <
> typename T,
> template <typename> class OwnershipPolicy,
> template <typename> class ConversionPolicy,
> template <typename> class CheckingPolicy,
> template <typename> class StoragePolicy
> >
> class smart_ptr
> : public OptionallyInherit<
> StoragePolicy<T>,
> OptionallyInherit<CheckingPolicy<
> typename StoragePolicy<T>::stored_type> >,
> OptionallyInherit<OwnershipPolicy<
> typename StoragePolicy<T>::pointer_type> >,
> OptionallyInherit<ConversionPolicy<
> typename StoragePolicy<T>::pointer_type> > > >
> {
> ...
> };
> [...]

Cool. This also looks somewhat like Gennadiy's policy
adaptor suggestion, with some optimization. But I would
use a tree structure instead of a list. ;) (Unless there's a good
reason not to, of course)

    class smart_ptr
        : public OptionallyInherit<
            OptionallyInherit<
                StoragePolicy<T>,
                CheckingPolicy<typename StoragePolicy<T>::stored_type>
>,
            OptionallyInherit<
                OwnershipPolicy<typename StoragePolicy<T>::pointer_type>
                ConversionPolicy<typename StoragePolicy<T>::pointer_type>
>
>

I'll take a look at boost::compressed_pair, to see if it can be
re-used. This is a relief (if it works), because even though VC6
responded to the same MI-EBO hacks that bcc did, I couldn't get
the auto_ptr-compatible SmartPtr below 5 bytes on either one.

Dave


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