[phoenix] binding member_functions

Hi there, I think there are some problems with binding functions if
the class has a const and a non-const version of the same member.
Please consider the following code:
#include

Christian Henning wrote:
Hi there, I think there are some problems with binding functions if the class has a const and a non-const version of the same member. Please consider the following code:
[snips] No, it's not a bug. When you get the address of a member function, there is relly no way in C++ to know which overload you want to get. You have to state it explicitly with a cast. The same thing happens with Boost.Bind, for example, try: point const p; double x = boost::bind( &point::prob, _1 )(p); and you'll get the exact same error. The Boost Bind docs has a good explanation on this. See "Binding an overloaded function" here: http://www.boost.org/doc/libs/1_37_0/libs/bind/bind.html#Troubleshooting Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net

Thanks Joel, for you explanation. Do you think that maybe for c++0x
that problem is resolved? Also, do the C++ lambda function suffer from
the same problem?
Christian
On Mon, Nov 10, 2008 at 8:37 PM, Joel de Guzman
Christian Henning wrote:
Hi there, I think there are some problems with binding functions if the class has a const and a non-const version of the same member. Please consider the following code:
[snips]
No, it's not a bug. When you get the address of a member function, there is relly no way in C++ to know which overload you want to get. You have to state it explicitly with a cast.
The same thing happens with Boost.Bind, for example, try:
point const p; double x = boost::bind( &point::prob, _1 )(p);
and you'll get the exact same error. The Boost Bind docs has a good explanation on this. See "Binding an overloaded function" here:
http://www.boost.org/doc/libs/1_37_0/libs/bind/bind.html#Troubleshooting
Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Christian Henning wrote:
Thanks Joel, for you explanation. Do you think that maybe for c++0x that problem is resolved?
No I don't think so. Also, do the C++ lambda function suffer from
the same problem?
With C++ lambda, you don't have to do the bind dance. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
participants (2)
-
Christian Henning
-
Joel de Guzman