From svalorzen at gmail.com Sat Feb 11 21:33:45 2017 From: svalorzen at gmail.com (Eugenio Bargiacchi) Date: Sun, 12 Feb 2017 03:33:45 +0100 Subject: [C++-sig] [Boost::Python] vector_indexing_suite fails to recognize type as registered Message-ID: In the below C++ code, even though the type std::tuple is registered, boost::python fails to find that out when the tuple is within an std::vector exposed through the vector_indexing suite. At the same time, it is possible to reference and use the type normally as long as it's not in the vector. For example, this happens: >>> print makeMyTuple() (0,) >>> print makeTuples()[0] Traceback (most recent call last): File "", line 1, in TypeError: No Python class registered for C++ class std::tuple >>> Is there any way to make this work? Best, Eugenio MVE: #include #include #include #include template struct TupleToPython { TupleToPython() { boost::python::to_python_converter>(); } template struct sequence {}; template struct generator : generator { }; template struct generator<0, S...> { using type = sequence; }; template static boost::python::tuple boostConvertImpl(const T& t, sequence) { return boost::python::make_tuple(std::get(t)...); } template static boost::python::tuple boostConvert(const std::tuple & t) { return boostConvertImpl(t, typename generator::type()); } static PyObject* convert(const T& t) { return boost::python::incref(boostConvert(t).ptr()); } }; using MyTuple = std::tuple; using Tuples = std::vector; MyTuple makeMyTuple() { return MyTuple(); } Tuples makeTuples() { return Tuples{MyTuple()}; } BOOST_PYTHON_MODULE(h) { using namespace boost::python; TupleToPython(); def("makeMyTuple", makeMyTuple); class_>{"Tuples"} .def(vector_indexing_suite>()); def("makeTuples", makeTuples); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From lexuscrossover at gmail.com Tue Feb 14 15:55:38 2017 From: lexuscrossover at gmail.com (B Ku) Date: Tue, 14 Feb 2017 15:55:38 -0500 Subject: [C++-sig] where does bjam look for header files Message-ID: Hi Guys, I'm trying to get Boost Python working for a work project. I followed the steps detailed here: http://stackoverflow.com/questions/20093331/cant-run-bjam-to-compile-boost-python-tutorial When I issued the bjam command in the boost_1_63_0\libs\python\example\tutorial directory, I get the following error: hello.cpp(7) : fatal error C1083: Cannot open include file: 'boost/python/module.hpp': No such file or directory Where does bjam look for c++ headers? Thank you for your help in advance! Thanks, B -------------- next part -------------- An HTML attachment was scrubbed... URL: