Hello,
Can someone please tell me why this doesn't work?
#include
#include
#include
using namespace std;
using namespace boost;
struct MyClass {
int i;
void foo(int j){
printf("%d, %d\n", i, j);
}
function bar() {
return bind<void>(&MyClass::foo, this);
}
};
$ g++ -c -g -I/usr/local/include/boost-1_33_1 -I.. foo.cpp
/usr/local/include/boost-1_33_1/boost/mem_fn.hpp: In member function
'R& boost::_mfi::dm::operator()(T*) const [with R = void ()
(int), T = MyClass]':
/usr/local/include/boost-1_33_1/boost/bind.hpp:229: instantiated
from 'void boost::_bi::list1<A1>::operator()(boost::_bi::type<void>,
F&, A&, int) [with F = void (MyClass::*)(int), A =
boost::_bi::list1, A1 = boost::_bi::value]'
/usr/local/include/boost-1_33_1/boost/bind/bind_template.hpp:32:
instantiated from 'typename boost::_bi::result_traits::type
boost::_bi::bind_t::operator()(A1&) [with A1 = int, R =
void, F = void (MyClass::*)(int), L =
boost::_bi::list1 >]'
/usr/local/include/boost-1_33_1/boost/function/function_template.hpp:
136: instantiated from 'static void
boost::detail::function::void_function_obj_invoker1::invoke(boost::detail::function::any_pointer, T0) [with
FunctionObj = boost::_bi::bind_t > >, R = void, T0 = int]'
/usr/local/include/boost-1_33_1/boost/function/function_template.hpp:
479: instantiated from 'void boost::function1::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t > >, R = void, T0 =
int, Allocator = std::allocator<void>]'
/usr/local/include/boost-1_33_1/boost/function/function_template.hpp:
430: instantiated from 'void boost::function1::assign_to(Functor) [with Functor =
boost::_bi::bind_t > >, R = void, T0 =
int, Allocator = std::allocator<void>]'
/usr/local/include/boost-1_33_1/boost/function/function_template.hpp:
294: instantiated from 'boost::function1::function1(Functor, typename
boost::enable_if_c::value, int>::type) [with Functor =
boost::_bi::bind_t > >, R = void, T0 =
int, Allocator = std::allocator<void>]'
/usr/local/include/boost-1_33_1/boost/function/function_template.hpp:
637: instantiated from 'boost::function::function(Functor, typename
boost::enable_if_c::value, int>::type) [with Functor =
boost::_bi::bind_t > >, R = void, T0 =
int, Allocator = std::allocator<void>]'
foo.cpp:15: instantiated from here
/usr/local/include/boost-1_33_1/boost/mem_fn.hpp:347: error: invalid
use of non-static member function
Thanks,
Sean
--
Compassion, tolerance, consideration of others, the responsible
use of knowledge and power. These principles transcend the
barriers between religious believers and non-believers; they
belong not to one faith, but to all faiths.
-- The 14th Dalai Lama