Subject: Re: phoenix lambda-lambda for_each example
From: Joel de Guzman <[email-masked]>
To: Aleksey Gurtovoy <[email-masked]>
Cc: David Abrahams <[email-masked]>, Noah Stein <[email-masked]>, [email-masked], Jaakko Jarvi <[email-masked]>
Date: Wed, 03 Mar 2004 11:39:26 +0800

Aleksey Gurtovoy wrote:

> Joel de Guzman writes:
> 
>>>Actually that case is kind of strange.  I think in MPL we're
>>>deciding
>>>that you need to do something like:
>>>  for_each(arg1, function(for_each(arg1, cout << arg1 << ' ')))(v)
>>>to prevent v from being substituted into *all* of the arg1s.
>>
>>I thought about that too. Upon meditation, I realized it is
>>not necessary. In this case, Phoenix has scope! 
> 
> 
> What if I don't want the scope there?
> 
>     std::vector<int> v1, v2;
>     copy( arg1, back_inserter(arg2) )(v1, v2); // fails???

No, that's ok! Why? because copy does not require a lambda-lambda.
The signature of for_each is: for_each(c, lambda) while the signature
of copy is simply copy(c, c).

Cheers,
-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net