[C++-sig] boost::python::iterator throws exception when using std::vector

Andrew Marshall planetmarshalluk at hotmail.com
Mon Nov 12 00:40:17 CET 2012


Hi there,
I've just started using Boost::Python. I was following the example given in the tutorial regarding iterators at
http://www.boost.org/doc/libs/1_52_0/libs/python/doc/tutorial/doc/html/python/iterators.html
I am attempting to fill a python::list from an std::vector with the following code, based on the snippet in the tutorial above:
namespace py = boost::python;
std::vector<int> v;v.push_back(1);
 py::object get_iterator = py::iterator<std::vector<int> >(); py::object iter = get_iterator(v); py::list l(iter); However the line "py::object iter = get_iter(v);" throws the following exception in python :
TypeError: No to_python (by-value) converter found for C++ type: class std::vector<int,class std::allocator<int> >
Any help would be appreciated.
Thanks,Andrew.
-----------------------------

Andrew Marshall

http://www.planetmarshall.co.uk
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121111/7fe739ca/attachment.html>


More information about the Cplusplus-sig mailing list