
David Abrahams writes:
Aleksey Gurtovoy <agurtovoy@meta-comm.com> writes:
David Abrahams writes:
[Aleksey, I'm not sure why the sort Expression Semantics uses explicit lambda and apply_wrap2; I don't think it helps to make anything clearer]
Because there is no other way to write that out (auxiliary metafunction aside).
Sorry, I must be dense. Why not just use apply<...> ?
The code in question is this (from http://www.boost.org/libs/mpl/doc/refmanual/sort.html): typedef back_inserter< vector<> > aux_in; typedef lambda<pred>::type p; typedef begin<s>::type pivot; typedef partition< iterator_range< next<pivot>::type, end<s>::type > , apply_wrap2<p,_1,deref<pivot>::type> // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ , aux_in , aux_in >::type partitioned; If 'pred' is a placeholder expression (e.g. 'is_float<_1>'), replacing the highlighted line with , apply<pred,_1,deref<pivot>::type> would blend together two of them into one, leading to unpredictable results: // the above is actually equivalent to this one, which // is not going to work , apply< is_float<_1>, _1, deref<pivot>::type > -- Aleksey Gurtovoy MetaCommunications Engineering