I'm having trouble compiling some very simple boost::function and boost::bind code under Xcode 4.4.1 using the default Apple LLVM compiler 4.0. I've simplified the code down to:
#include
#include
struct Monitor {
void Change(int a, int b);
void Lose() {
auto b = boost::bind(&Monitor::Change, this);
boost::function f(b);
}
};
On the second line of the Lose() function I get the error "reference to non-static member function must be called". The full error message is below.
I haven't been able to figure out just where the problem is. Is this an incompatibility between Boost 1.50 and Xcode 4.4.1, or am I making some other mistake? Is there a straightforward workaround?
Thanks,
—Stuart
In file included from /Users/samalone/Projects/functionbind/functionbind/main.cpp:1:
In file included from /Users/samalone/Boost/boost/bind.hpp:22:
In file included from /Users/samalone/Boost/boost/bind/bind.hpp:26:
In file included from /Users/samalone/Boost/boost/mem_fn.hpp:22:
/Users/samalone/Boost/boost/bind/mem_fn.hpp:342:16: error: reference to non-static member function must be called
return (p->*f_);
^~~~~~~~
/Users/samalone/Boost/boost/bind/bind.hpp:243:16: note: in instantiation of member function 'boost::_mfi::dm::operator()' requested here
return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_]);
^
/Users/samalone/Boost/boost/bind/bind_template.hpp:61:27: note: in instantiation of function template specialization 'boost::_bi::list1 >::operator(), boost::_bi::list2 >' requested here
BOOST_BIND_RETURN l_(type(), f_, a, 0);
^
/Users/samalone/Boost/boost/function/function_template.hpp:153:33: note: in instantiation of function template specialization 'boost::_bi::bind_t, boost::_bi::list1> >::operator()' requested here
BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
^
/Users/samalone/Boost/boost/function/function_template.hpp:75:36: note: expanded from macro 'BOOST_FUNCTION_RETURN'
# define BOOST_FUNCTION_RETURN(X) X
^
/Users/samalone/Boost/boost/function/function_template.hpp:907:53: note: in instantiation of member function 'boost::detail::function::void_function_obj_invoker2, boost::_bi::list1>>, void, int, int>::invoke' requested here
{ { &manager_type::manage }, &invoker_type::invoke };
^
/Users/samalone/Boost/boost/function/function_template.hpp:722:13: note: in instantiation of function template specialization 'boost::function2::assign_to, boost::_bi::list1>> >' requested here
this->assign_to(f);
^
/Users/samalone/Boost/boost/function/function_template.hpp:1042:5: note: in instantiation of function template specialization 'boost::function2::function2, boost::_bi::list1>> >' requested here
base_type(f)
^
/Users/samalone/Projects/functionbind/functionbind/main.cpp:9:42: note: in instantiation of function template specialization 'boost::function::function, boost::_bi::list1>> >' requested here
boost::function f(b);
^
1 error generated.