|
Boost : |
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-05-02 12:07:26
> ----- Original Message -----
> From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>
>
Couple notes:
1. I like the idea. With only one exclusion: smart_ptr on singleton or
monotype object (in this case I can't skip constructor and destructor for
empty class). We should support the way for user to force inheritance.
2. It could be done without PC
3. I still feel that adding one level of indirection would be good.
So here I think it could look like:
template<typename Policies>
class basic_smart_ptr : public Policies
{
typedef typename Policies::storage_policy storage_policy;
...
};
template<typename StoragePolicy,...>
struct simple_linear_policies_adaptor : StoragePolicy, OwnershipPolicy
{
// typedefs
// Constructors
};
template<bool first_is_empty,bool second_is_empty>
struct optional_parents_impl
{
template<typename Mother,typename Father>
struct are : Mother, Father
{
// Constructors
};
};
template<>
struct optional_parents_impl<false,false>
...
template<>
struct optional_parents_impl<false,true>
...
template<>
struct optional_parents_impl<true,false>
...
template<typename Mother,typename Father>
struct optional_parents :
optional_parents_impl<is_empty<Mother>,is_empty<Father>
>::are<Mother,Father>
{
// Constructors
};
template<typename StoragePolicy,...>
struct opt_linear_policies_adaptor : optional_parents<StoragePolicy,
optional_parents<OwnershipPolicy,...>>>>
{
// typedefs
// Constructors
};
template<typename Policy,typename Base>
struct vertical_adaptor : Policy, Base {}
template<typename StoragePolicy,...>
struct vertical_policies_adaptor : vertical_adaptor<StoragePolicy,
vertical_adaptor<OwnershipPolicy,...>>>>
template<typename StoragePolicy,...>
typedef basic_smart_ptr<opt_linear_policies_adaptor<StoragePolicy,...> >
smart_ptr;
Gennadiy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk