Boost logo

Boost :

Subject: Re: [boost] [Review] Phoenix review starts today, September 21st
From: Joel de Guzman (joel_at_[hidden])
Date: 2008-09-22 21:59:32

David Abrahams wrote:
> on Mon Sep 22 2008, Joel de Guzman <> wrote:
>> David Abrahams wrote:
>>> on Mon Sep 22 2008, "Peter Dimov" <> wrote:
>>>> Mathias Gaunard:
>>>>> Loïc Joly wrote:
>>>>>> - How does this library position itself wrt the upcomming C++0x > standard,
>>>>> with native support for lambdas, and standardized support for > function or
>>>>> bind? Is it more expressive?
>>>>> The C++0x standard only specifies monomorphic lambdas at the moment.
>>>>> So Phoenix is indeed more expressive, since all expressions are polymorphic.
>>>> Except phoenix::bind, which is monomorphic, for whatever reasons. :-)
>>> Hmm, that seems like it will needlessly restrict generic code.
>> Ah that one. I think that needs clarification. The note is wrong
>> and should be corrected. A bound function pointer or member function
>> pointer is only monorphic once bound (of course -- a single function
>> pointer or member function pointer is monomorphic). The same is true
>> with bind and lambda bind.
> Yeah, but what about a bound polymorphic function object? The doc makes
> it sound like passing through bind removes that polymorphism.
>> Phoenix bind, like bind and lambda bind is polymorphic at the call
>> site in the sense that it can bind to any function and function
>> pointer and function object (which can be polymorphic). One problem
>> I notice now with the bind documentation of phoenix is that it
>> lacks the function object binding part.
>> Noted for correction. Pardon the confusion.
> I'm still confused ;-)

You can disregard the note. It is a historic artifact from V1 and
is not accurate. Phoenix2 *can* bind to polymorphic function objects.

     struct sqr
         template <typename Arg>
         struct result
             typedef Arg type;

         template <typename Arg>
         Arg operator()(Arg n) const
             return n * n;


     BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5));


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at