Opened 10 years ago
Last modified 9 years ago
#7548 new Bugs
Impossible to query for std::vector<double> converter registration
Reported by: | Owned by: | Ralf W. Grosse-Kunstleve | |
---|---|---|---|
Milestone: | To Be Determined | Component: | python USE GITHUB |
Version: | Boost Release Branch | Severity: | Problem |
Keywords: | Cc: |
Description
I have been hitting this wall for some months now and produced some minimalistic code that shows the problem:
#include <boost/python.hpp> #include <vector> #include <iostream> std::vector<double> list_of_doubles() { std::vector<double> retval; retval.push_back(3); retval.push_back(2); return retval; } // Instantiate the core module. BOOST_PYTHON_MODULE(boost_debug) { //We check if a converter for std::vector has been registered boost::python::type_info info = boost::python::type_id<std::vector<double> >(); const boost::python::converter::registration* reg = boost::python::converter::registry::query(info); //We output to screen the result (should be NULL) std::cout << reg << " "; //We also expose a function that needs such a conversion (to_python) using namespace boost::python; def("list_of_doubles",list_of_doubles); }
in python:
import boost_debug
and the result (which should be zero) is instead an address: 0x7f9bc3c4c600
Even more absurdly, if we comment the line "def("list_of_doubles",list_of_doubles);" things actually go back to normality.
Note:
See TracTickets
for help on using tickets.
See this answer on stackoverflow: http://stackoverflow.com/a/13017303/959926
It worked for me.