Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-03 07:04:18


From: "David B. Held" <dheld_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:009801c1f215$4d773ea0$1d00a8c0_at_pdimov2...
> > [...]
> > template<class T> void f(typename ptr<T>::shared p);
> >
> > ptr<int>::shared q;
> >
> > f(p); // fail
>
> I assume you mean f(q). ;) Is it the fact that shared is a typedef
> inside ptr that confuses the compiler? Would it be tremendously
> difficult for the compiler to handle this situation in the expected
> way?

In the general case, yes. The compiler doesn't solve type equations.
ptr<T>::shared may be an arbitrarily complex type function.

> > [...]
> > 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
> > };
> > [...]
>
> I see. This is yet another policy bundler. How exactly do you
> go about passing the right parameters to the policies?

[typename] Config::storage_policy::template apply<RightParameter> [::type].
With templated typedefs that could be simplified to

Config::template storage_policy<RightParameter>.


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