
David Abrahams <dave@boost-consulting.com> writes:
Are you asking about runtime lambda expressions as in the Boost Lambda library, or compile-time lambda expressions as in MPL?
-- Dave Abrahams Boost Consulting www.boost-consulting.com
I was talking about MPL because that is the only one I have studied at the moment. What is the difference between the two outside of the obvious runtime/compile-time difference? I was trying to figure out how a particular placeholder gets its arguments to choose from when deciding the argument (argument 1 for _1 etc.). Thank you. Joseph L. McCay

Joe McCay <joemccay@gmail.com> writes:
David Abrahams <dave@boost-consulting.com> writes:
Are you asking about runtime lambda expressions as in the Boost Lambda library, or compile-time lambda expressions as in MPL?
-- Dave Abrahams Boost Consulting www.boost-consulting.com
I was talking about MPL because that is the only one I have studied at the moment. What is the difference between the two outside of the obvious runtime/compile-time difference?
Well, the syntax. MPL's compile-time lambdas never use parens as in the _1(5) you cited.
I was trying to figure out how a particular placeholder gets its arguments to choose from when deciding the argument (argument 1 for _1 etc.).
It's just in the definition of the placeholders template <int> struct arg; typedef arg<1> _1; typedef arg<2> _2; … template <> struct arg<N> { template < class A1 = void_ , class A2 = void_ … , class AM = void_ > struct apply { typedef AN type; }; }; and the way arguments are passed through from apply_wrap. apply_wrap<_2, int, int*, int**, int***>::type => int* Maybe this simplified definition of lambda would help: template <class T> struct lambda { typedef T type; }; template < template <class> class F, class A1 > struct lambda< F<A1> > : if_< is_placeholder_expression< F<A1> > , bind< quote1<F>, typename lambda<A1>::type > , F<A1> > {}; template < template <class,class> class F, class A1, class A2 > struct lambda< F<A1,A2> > : if_< is_placeholder_expression< F<A1,A2> > , bind< quote2<F> , typename lambda<A1>::type, typename lambda<A2>::type > , F<A1,A2> > {}; //... -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Joe McCay