[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-cpp-sig
Subject:    [C++-sig] boost::python::iterator throws exception when using std::vector
From:       Andrew Marshall <planetmarshalluk () hotmail ! com>
Date:       2012-11-11 23:40:17
Message-ID: DUB002-W3955FBD3AAEAE3FC5427E3D76E0 () phx ! gbl
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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
 		 	   		  


[Attachment #5 (text/html)]

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><font face="Calibri, sans-serif" size="3">Hi \
there,</font><div style="font-family: Calibri, sans-serif; font-size: \
12pt;"><br></div><div style="font-family: Calibri, sans-serif; font-size: 12pt;">I've \
just started using Boost::Python. I was following the example given in the tutorial \
regarding iterators at</div><div style="font-family: Calibri, sans-serif; font-size: \
12pt;"><br></div><div><font face="Calibri, \
sans-serif">http://www.boost.org/doc/libs/1_52_0/libs/python/doc/tutorial/doc/html/python/iterators.html</font></div><div><font \
face="Calibri, sans-serif"><br></font></div><div style="font-family: Calibri, \
sans-serif; font-size: 12pt;">I am attempting to fill a python::list from an \
std::vector with the following code, based on the snippet in the tutorial \
above:</div><div style="font-family: Calibri, sans-serif; font-size: \
12pt;"><br></div><div style="font-family: Calibri, sans-serif; font-size: \
12pt;">namespace py = boost::python;</div><div style="font-family: Calibri, \
sans-serif; font-size: 12pt;"><br></div><div style="font-family: Calibri, sans-serif; \
font-size: 12pt;">std::vector&lt;int&gt; v;</div><div style="font-family: Calibri, \
sans-serif; font-size: 12pt;">v.push_back(1);</div><div style="font-family: Calibri, \
sans-serif; font-size: 12pt;"><br></div><div><div><font face="Calibri, \
sans-serif">&nbsp;py::object get_iterator = py::iterator&lt;std::vector&lt;int&gt; \
&gt;();</font></div><div><font face="Calibri, sans-serif">&nbsp;py::object iter = \
get_iterator(v);</font></div><div><font face="Calibri, sans-serif">&nbsp;py::list \
l(iter);</font></div><div><font face="Calibri, \
sans-serif">&nbsp;</font></div></div><div><font face="Calibri, sans-serif">However \
the line "py::object iter = get_iter(v);" throws the following exception in python \
:</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font \
face="Calibri, sans-serif">TypeError: No to_python (by-value) converter found for C++ \
type: class std::vector&lt;int,class std::allocator&lt;int&gt; \
&gt;</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font \
face="Calibri, sans-serif">Any help would be appreciated.</font></div><div><font \
face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, \
sans-serif">Thanks,</font></div><div><font face="Calibri, \
sans-serif">Andrew.</font></div><div style="font-family: Calibri, sans-serif; \
font-size: 12pt;"><br>----------------------------- <br>Andrew Marshall
<br>http://www.planetmarshall.co.uk
</div> 		 	   		  </div></body>
</html>



_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic