
Boost : 
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 20050809 22:26:29
David Abrahams writes:
> Aleksey Gurtovoy <agurtovoy_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk