Boost logo

Boost :

Subject: Re: [boost] phoenix::bind
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-09-29 11:36:38


Joel de Guzman:
...
> I can definitely make sure that all those are supported.
> I supported the lambda tests in phoenix.

Unfortunately, the Lambda tests are incomplete, as they do not cover its
most frequently encountered problems. Phoenix does seem to handle abstract
classes fine, which is good, but it still has trouble with smart pointers:

#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>

namespace px = boost::phoenix;
using namespace px::arg_names;

struct A
{
    virtual void f() = 0;
};

struct X: public A
{
    void f() { std::cout << "X::f\n"; }
};

int main()
{
    boost::shared_ptr<A> px( new X );

    px::bind( &A::f, arg1 )( px ); // fail
    px::bind( &A::f, *arg1 )( px ); // fail
    px::bind( &A::f, arg1 )( px.get() ); // fail

    px::bind( &A::f, arg1 )( *px );
    px::bind( &A::f, px::ref( *px ) )();
    px::bind( &A::f, px.get() )();
}

The problem on the third line is probably caused by the rvalue-ness of
px.get(). Still, boost::bind can compile it today, so Phoenix should, too.
:-)

Incidentally, if I #include both boost/bind.hpp and phoenix under VC7.1, I
get errors in composite.hpp due to its use of _1 as an argument name. I
understand that this is caused by bind.hpp and that it's probably a compiler
issue, but a simple rename might fix it.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk