$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-28 23:40:45
AMDG
Giovanni Piero Deretta wrote:
> That is, something like this is actually possible:
>
>   void foo  () {
>     int i =
>      lambda
>       // introduce formal parameter names
>       [  _<class left>(),
>          _<class right>()
>       ]
>       // now use them!
>       [_<left>() + _<right>()]
>       // actual parameters values
>      ( 10,  20 );
>   }
>
> The _<...>() looks a bit clumsy, but it might be actually usable.
>   
I'd rather not use _.  arg sound better.
lambda<class left, class right>(arg<left>() + arg<right>())
> Still the non-descriptive _N placeholders bother me.
> Using the named placeholder trick it would become:
>
>   typedef   compose<
>     // introduce formal args names
>     args<
>       class range
>     , class init
>     , class op
>     >
>     // expression
>   , fold(reverse(range), init, op)
>     // function name
>   > reverse_fold;
>
> With complex expressions, this could be quite a readability improvement.
> Except for confirming that the above expression does actually compile
> (at least with gcc), I have yet to try to implement it,
> but I think it should be fairly easy.
>
> Comments
Wow.  This is awesome.  You'd probably better reference the standard 
(3.3.1/5)
since most people will look at this and be surprised to find that
it's legal.  (I certainly was)
In Christ,
Steven Watanabe