Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] Boost.Bind works, labmda bind fails to compile
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-12-30 09:41:22


On Wed, Dec 30, 2009 at 7:14 AM, Igor R <boost.lists_at_[hidden]> wrote:
> Hello,
>
> Could someone please explain the following behavior:
>
> #include <boost/lambda/bind.hpp>
> #include <boost/bind.hpp>
>
> struct Functor
> {
>        void operator()() const
>        {}
>        template<class T> void func(T t)
>        {}
> };
>
> int main()
> {
>        Functor f;
>        boost::lambda::bind(&Functor::func<Functor>, &f, f); // doesn't compile
>        boost::bind(&Functor::func<Functor>, &f, f); // compiles well
> }

Does it work with Boost.Phoenix? Boost.Phoenix includes the
functionality of both and a great deal more. I have not tried this,
but curious if it works for you:

#include <boost/spirit/home/phoenix/bind/bind_function.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>

struct Functor
{
       void operator()() const
       {}
       template<class T> void func(T t)
       {}
};

int main()
{
       Functor f;
       boost::phoenix::bind(&Functor::func<Functor>, &f, f); // Does
this compile?
       boost::lambda::bind(&Functor::func<Functor>, &f, f); // doesn't compile
       boost::bind(&Functor::func<Functor>, &f, f); // compiles well
}


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