From: David Abrahams (dave_at_[hidden])
Date: 2003-08-08 16:30:02
"David B. Held" <dheld_at_[hidden]> writes:
> "David Abrahams" <dave_at_[hidden]> wrote in message
>> 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
Yes, and I'm trying to say, "don't do it by switching to template
> But then smart_ptr doesn't know where the guts are.
Huh? What guts? Precise speaking, please!
Aren't they in the nested apply<>?
> 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
What, specifically, did you try?
> 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.
This is way too vague for me to say anything useful.
> Now that I think about it, things would "just work" if I declared
> the policies this way:
> <typename T, Policies>
^----------something's missing here
> class smart_ptr
> 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,
No; just transform everything into a metafunction class using lambda,
and you're done.
> but I don't really know what I'm talking about at this point.
Me neither ;->
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk