I'm trying to expose a vector the contains some pointers to Address objects and a map that maps a pointer to an Address object to another pointer to an Address object. The operators == and != have been implemented in the Address class. I've seen this post but I still don't quite understand the answer from this and the documentation. Am I supposed to create a class that inherits from map_indexing_suite? I couldn't find a well documented example online, and copy-pasting the answer didn't help (still the same error).
Here's the code:
BOOST_PYTHON_MODULE(Utilities)
{
// this compiles without any problem
class_<std::vector<Address*>, std::vector<Address*>*>("AddressVector")
.def(vector_indexing_suite<std::vector<Address*>>());
// this does not compile
class_<std::map<Address*, Address*>, std::map<Address*, Address*>*>("AddressMap")
.def(map_indexing_suite<std::map<Address*, Address*>>());
}
Error:
In file included from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52:0,
from /usr/include/boost/python/detail/invoke.hpp:63,
from /usr/include/boost/python/detail/caller.hpp:16,
from /usr/include/boost/python/object/function_handle.hpp:8,
from /usr/include/boost/python/converter/arg_to_python.hpp:19,
from /usr/include/boost/python/call.hpp:15,
from /usr/include/boost/python/object_core.hpp:14,
from /usr/include/boost/python/args.hpp:25,
from /usr/include/boost/python.hpp:11,
from Utilities.h:1,
from Utilities.cpp:1:
/usr/include/boost/python/detail/invoke.hpp: In instantiation of ‘PyObject* boost::python::detail::invoke(boost::python::detail::invoke_tag_<false, false>, const RC&, F&, AC0&) [with RC = boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<Address*>; F = Address* (*)(std::pair<Address* const, Address*>&); AC0 = boost::python::arg_from_python<std::pair<Address* const, Address*>&>; PyObject = _object]’:
/usr/include/boost/python/detail/caller.hpp:223:13: required from ‘PyObject* boost::python::detail::caller_arity<1u>::impl<F, Policies, Sig>::operator()(PyObject*, PyObject*) [with F = Address* (*)(std::pair<Address* const, Address*>&); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector2<Address*, std::pair<Address* const, Address*>&>; PyObject = _object]’
/usr/include/boost/python/object/py_function.hpp:38:33: required from ‘PyObject* boost::python::objects::caller_py_function_impl<Caller>::operator()(PyObject*, PyObject*) [with Caller = boost::python::detail::caller<Address* (*)(std::pair<Address* const, Address*>&), boost::python::default_call_policies, boost::mpl::vector2<Address*, std::pair<Address* const, Address*>&> >; PyObject = _object]’
Utilities.cpp:111:1: required from here
/usr/include/boost/python/detail/invoke.hpp:75:82: erreur: no match for call to ‘(const boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<Address*>) (Address*)’
return rc(f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) ));
^
In file included from /usr/include/boost/python/object/function_handle.hpp:8:0,
from /usr/include/boost/python/converter/arg_to_python.hpp:19,
from /usr/include/boost/python/call.hpp:15,
from /usr/include/boost/python/object_core.hpp:14,
from /usr/include/boost/python/args.hpp:25,
from /usr/include/boost/python.hpp:11,
from Utilities.h:1,
from Utilities.cpp:1:
/usr/include/boost/python/detail/caller.hpp: In instantiation of ‘static const PyTypeObject* boost::python::detail::converter_target_type<ResultConverter>::get_pytype() [with ResultConverter = boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<Address*>; PyTypeObject = _typeobject]’:
/usr/include/boost/python/detail/caller.hpp:240:19: required from ‘static boost::python::detail::py_func_sig_info boost::python::detail::caller_arity<1u>::impl<F, Policies, Sig>::signature() [with F = Address* (*)(std::pair<Address* const, Address*>&); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector2<Address*, std::pair<Address* const, Address*>&>]’
/usr/include/boost/python/object/py_function.hpp:48:35: required from ‘boost::python::detail::py_func_sig_info boost::python::objects::caller_py_function_impl<Caller>::signature() const [with Caller = boost::python::detail::caller<Address* (*)(std::pair<Address* const, Address*>&), boost::python::default_call_policies, boost::mpl::vector2<Address*, std::pair<Address* const, Address*>&> >]’
Utilities.cpp:111:1: required from here
/usr/include/boost/python/detail/caller.hpp:102:109: erreur: ‘struct boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<Address*>’ has no member named ‘get_pytype’
return create_result_converter((PyObject*)0, (ResultConverter *)0, (ResultConverter *)0).get_pytype();
^
make: *** [Utilities.o] Erreur 1
Thanks
Aucun commentaire:
Enregistrer un commentaire