|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-05-14 15:20:43
Just to clarify, we're talking about mpl::lambda here.
"David B. Held" <dheld_at_[hidden]> writes:
> Ok, suppose we have a policy-based class Foo, and a policy P:
>
> template <typename Policy>
> class Foo
> {
> // ...
> };
>
> struct P
> {
> template <typename T>
> struct apply
> {
> typedef policy type;
> };
> };
P is a "metafunction class"
> Now, my understanding is that we can use Lambda so that we can
> invoke Foo this way:
>
> Foo<P> f;
for some definition of "invoke" ;-)
> Or define P in this way:
>
> template <typename T>
> struct P
> {
> // policy
> };
P is a "metafunction"
> and call Foo this way:
For some defintion of "call" ;-)
> Foo<P<_> > f;
P<_> is a "lambda expression"
> But if I require that everyone define P in the first way, then Lambda
> should not be necessary, is that correct? Is there still a reason to
> use Lambda in that case?
In the upcoming version of MPL (very soon now) mpl::apply -- which
you'll want to use even to invoke metafunction classes portably (no,
using P::template apply<whatever>::type doesn't work everywhere) --
will invoke mpl::lambda internally, so the upshot is that passing
either lambda expressions or metafunction classes will work.
-- Dave Abrahams Boost Consulting http://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