Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2003-08-08 14:36:25


"David Abrahams" <dave_at_[hidden]> wrote in message
news:u8yq45mv9.fsf_at_boost-consulting.com...
> [...]
> Don't pass metafunctions directly; it's bad for interoperability.
> Then you get a metafunction taking a template template
> parameter, and you can't use it in lambda expressions.

Hmm...ok, I'm not getting anywhere talking about it abstractly, so
I'll just say that I'm trying to figure out how to improve the policy
adaptor interface for smart_ptr. In particular, I would like to go
from this:

smart_ptr<int, my_policy<_>, my_other_policy<_> > p;

to this:

smart_ptr<int, my_policy, my_other_policy> p;

I know I can do this by changing my_*policy to a metafunction
class. But then smart_ptr doesn't know where the guts are.
Aleksey gave me the impression that I could mix and match,
since the policy adaptor uses lambda to deal with the policies.
But when I tried to do that, I found out the rude way that the
policy client (smart_ptr) could no longer find the stuff in the
nested apply<> template, because it assumed the policy
contained all the stuff.

Now that I think about it, things would "just work" if I declared
the policies this way:

<typename T, Policies>
class smart_ptr
{
public:
    typedef OwnershipPolicy::apply<T> ownership_policy;
    typedef StoragePolicy::apply<T> storage_policy;
    // ...
};

But then, that doesn't work for policies which are *not*
metafunction classes. I have a feeling the policy adaptor
needs to detect whether the policy is a metafunction class
or a lambda expression, but I don't really know what I'm
talking about at this point.

Dave


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