Rozental, Gennadiy wrote: > I am having hard time grasping how this %#$% lambda facility > is working.
I hope you mean "what it does/how to use it" as opposite to "how it does what it does" ;). > Unfortunally paper does not provide enough information. > Could you at least provide general scetch? Amoung other things I > would like to know when I need to use _ and when _1,_2,...? The numbered placeholders (_1, _2, ...) have the same semantics as those in equivalent run-time libraries, Boost.Bind and Boost.Lambda. You can always use them and forget about unnamed form (_). The only real value associated with the latter is its visual appeal :). The "table" below demonstrates the semantics of both forms: // numbered placeholders semantics plus<_1, int_c<5> > == bind<meta_fun2<plus>,_1,int_c<5> > plus< int_c<5>,_1 > == bind<meta_fun2<plus>,int_c<5>,_1 > plus< int_c<5>,_2 > == bind<meta_fun2<plus>,int_c<5>,_2 > plus<_1,_2> == bind<meta_fun2<plus>,_1,_2> plus<_2,_1> == bind<meta_fun2<plus>,_2,_1> logical_or< is_same<_1,int>, is_same<_1,long> > = bind< meta_fun2<logical_or> , bind< meta_fun2<is_same>,_1,int > , bind< meta_fun2<is_same>,_1,long > > is_same< _1, add_pointer<_2> > == bind< meta_fun2<is_same> , _1 , bind< meta_fun1<add_pointer>, _2 > > // unnamed placeholder semantics plus< _,int_c<5> > == plus<_1, int_c<5> > plus< int_c<5>,_ > == plus< int_c<5>,_1 > ??? == plus< int_c<5>,_2 > // can't be built using unnamed notation plus<_,_> == plus<_1,_2> ??? == plus<_2,_1> logical_or< is_same<_,int>, is_same<_,long> > = logical_or< is_same<_1,int>, is_same<_1,long> > is_same< _, add_pointer<_> > != is_same< _1, add_pointer<_2> > // !!! is_same< _, add_pointer<_> > == bind< meta_fun2<is_same> , _1 , bind< meta_fun1<add_pointer>, _1 > // !!! > > Could you write in a form of step by step description how > fold-family algorithms are working? >From the reference docs (http://www.mywikinet.com/mpl/ref/Reference/iter_fold.html): Expression ~~~~~~~~~~ typedef iter_fold<Sequence,T,Op>::type t; Semantics ~~~~~~~~~ Equivalent to typedef lambda<Op>::type op; typedef begin<Sequence>::type i1; typedef apply<op,T,i1>::type t1; typedef i1::next i2; typedef apply<op,t1,i2>::type t2; ... typedef apply<op,T,in>::type tn; typedef in::next last; typedef tn t; , where n == size<Sequence>::type::value and last is identical to end<Sequence>::type; Equivalent to typedef T t; if the sequence is empty. > Also is there gen_scattered/linear_hierarchy implementation > somewhere for MPL sequenses? MPL's 'inherit_linearly' algorithm + 'inherit' metafunction (in the CVS now) cover both of these. Please see http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/m pl/example/inherit_linearly.cpp and http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/m pl/example/inherit_multiply.cpp for the corresponding examples. HTH, Aleksey _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost