Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-02 15:09:43


From: "David B. Held" <dheld_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:009301c1f1d8$07185670$1d00a8c0_at_pdimov2...
> > [...]
> > The only problem with this design is that ptr<T>::shared is a
> > nondeduced context; template writers must still use the full
> > smart_ptr<T, P1, P2, P3, ...> syntax.
>
> I wish I knew what a nondeduced context was. ;) Could you give
> me a quick overview?

template<class T> void f(typename ptr<T>::shared p);

ptr<int>::shared q;

f(p); // fail

> Also, do you see this as a situation that a
> typical user would encounter often, or something that would be
> more of an issue for library writers?

I don't know, really. It's possible that it will be rare.

> Finally, do you have any
> suggestions that would help simplify a fat policy list (short of
> typedef templates, of course)?

The only suggestion I have is to encode the fat policy list in a single type
(usually called a configuration):

struct shared_config
{
    typedef assert_check checking_policy;
    typedef shared_ownership ownership_policy;
// etc
};

smart_ptr<T, shared_config> p;

We can't templates in a configuration in this way because we don't have
templated typedefs (what else) but it's possible to wrap every template
template parameter in a class, working around the problem (as MPL does.)


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