[boost.function] member function object problem

Hi, I perform some tests and run into problems. The following code doesn't compile: ---8<--- #include <boost/python.hpp> namespace python = boost::python; struct My { void exec_test() { } }; int main() { Py_Initialize(); boost::function<void (My*)> exec_test = &My::exec_test; //L13 My my; if (python::handle_exception(exec_test(&my))) { if (PyErr_Occurred()) { PyErr_Print(); } } return 0; } --->8--- $ LANG=en g++ -I /usr/include/python2.5 python_embedded.cpp -o python_embedded -l python2.5 -l boost_python python_embedded.cpp: In function 'int main()': python_embedded.cpp:13: error: variable 'boost::function<void ()(My*), std::allocator<void> > exec_test' has initializer but incomplete type but the code snipped from the boost.function doc page works: ---8<--- #include <boost/function.hpp> struct X { void foo() {} }; int main() { boost::function<void (X*)> f = &X::foo; X x; f(&x); } --->8--- I see no difference that matter, what happens here? Thanks, Olaf

AMDG Olaf Peter wrote:
Hi,
I perform some tests and run into problems. The following code doesn't compile:
---8<--- #include <boost/python.hpp>
boost::function<void (My*)> exec_test = &My::exec_test; //L13
--->8---
$ LANG=en g++ -I /usr/include/python2.5 python_embedded.cpp -o python_embedded -l python2.5 -l boost_python python_embedded.cpp: In function 'int main()': python_embedded.cpp:13: error: variable 'boost::function<void ()(My*), std::allocator<void> > exec_test' has initializer but incomplete type
Add #include <boost/function.hpp> In Christ, Steven Watanabe

Steven Watanabe schrieb:
AMDG
Olaf Peter wrote:
Hi,
I perform some tests and run into problems. The following code doesn't compile:
---8<--- #include <boost/python.hpp>
boost::function<void (My*)> exec_test = &My::exec_test; //L13
--->8---
$ LANG=en g++ -I /usr/include/python2.5 python_embedded.cpp -o python_embedded -l python2.5 -l boost_python python_embedded.cpp: In function 'int main()': python_embedded.cpp:13: error: variable 'boost::function<void ()(My*), std::allocator<void> > exec_test' has initializer but incomplete type
Add
#include <boost/function.hpp>
oh, dear ... Thanks, Olaf
participants (2)
-
Olaf Peter
-
Steven Watanabe