[C++-sig] Wrapping a function that takes class type, such as type_info
Adam Preble
adam.preble at gmail.com
Tue Feb 21 09:03:56 CET 2012
I am using Boost 1.47
I have these class methods:
void Remove(const std::type_info &type);
void Remove(const boost::python::type_info type);
I tried wrapping them both in Boost.Python:
void (Entity::*Remove1)(const std::type_info&) = &Foo::Remove;
void (Entity::*Remove2)(const boost::python::type_info) = & Foo::Remove;
class_< Foo , boost::noncopyable, shared_ptr< Foo > >(" Foo", init<>())
...
.def("Remove", Remove1)
.def("Remove", Remove2)
...
(I just tried type_info of both namespaces to be comprehensive here...)
It'll compile and and I'll get that Remove method fine. Except I can't
seem to cram something into it when I try to actually execute the
subroutine. Say I have class Bar wrapped in Python too, and I have been
using it fine and dandy. How do I get Remove() to accept the type of Bar
as an argument?
Say:
foo = Foo()
foo.Remove(Bar)...
foo.Remove(type(Bar))...
I just can't get any love here:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
foo.Remove(Foo, type)
did not match C++ signature:
Remove(class game::Entity {lvalue}, struct boost::python::type_info)
Remove(class game::Entity {lvalue}, class type_info)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20120221/3924b8f9/attachment.html>
More information about the Cplusplus-sig
mailing list