Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda]
From: Marcin Zalewski (marcin.zalewski_at_[hidden])
Date: 2010-02-28 14:59:49


Joel,

On Fri, Feb 26, 2010 at 21:46, Joel de Guzman <joel_at_[hidden]> wrote:
> On 2/27/2010 1:30 AM, Marcin Zalewski wrote:
>>>>
>>>> I am trying to use lambda's constructor [1] with fusion's fused [2].
>>>> Fused requires that the function object passed to it has a following
>>>> valid expression:
>>>>
>>>>  boost::result_of<  F(T1  ...TN)>::type
>>>>
>>>> Unfortunately, constructor does not support result_of.
>>>
>>> Use Phoenix instead of Lambda, and problem solved ;)
>>
>> Actually, it seems that Phoeinx's construct does not do the same thing
>> as lambda's constructor. Using lambda, you can write:
>>
>> constructor<T>() c;
>> c(arg1, ..., argn);
>>
>> With Phoenix, you need to give arguments ahead of time:
>>
>> construct<T>(ctor_arg1, ctor_arg2, ..., ctor_argN);
>>
>> That's not exactly the same. Lambda works out very nicely in a
>> situation where it is not possible to say how many arguments will
>> there be until they are collected.
>
> That (constructor) is very easy to add as a phoenix lazy function
> (just a few lines of code).

I think I understand what do you mean about turning constructor into a
lazy function, but, I think, I had something else in mind. The lambda
constructor object does not need to know ahead of time how many
arguments will it take. It basically takes a type parameter, and then,
*at the time of call*, it calls the appropriate constructor. This is
useful when, in a given context, you do not know which constructor
will be called. Can one use phoenix's constructor in such unplanned
way?

-m


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net