c++-sig@python.org
[Top] [All Lists]

[C++-sig] Returning std::vector<int*> to python

Subject: [C++-sig] Returning std::vector<int*> to python
From: ""
Date: Sat, 17 Sep 2005 18:09:33 -0700 PDT
Hi,

  I'm having a problem returning a std::vector<int*> to python:

#include <vector>
typedef std::vector<int*> intVec;
class Node
{
public:
  Node() {}
  intVec& getIntVec() {
    return intvec;
  }
  int computeSum(const intVec& intvec) {return 1;}
  intVec intvec;
};

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    class_<Node>("Node", init<>())
      .add_property("intvec"
        , make_getter(&Node::intvec, return_internal_reference<>()))
      .def("getIntVec", (intVec&(Node::*)())&Node::getIntVec,
           return_internal_reference<>())
      .def("computeSum", &Node::computeSum)
    ;
}

>>> import hello
>>> test = hello.Node()
>>> test.computeSum(test.intvec)
TypeError: No Python class registered for C++ class std::vector<int*, 
std::allocator<int*> >
>>> test.computeSum(test.getIntVec())
TypeError: No Python class registered for C++ class std::vector<int*, 
std::allocator<int*> >
>>> 

Can someone please help?

Thank you very much!

Linh
_______________________________________________
C++-sig mailing list
C++-sig@xxxxxxxxxx
http://mail.python.org/mailman/listinfo/c++-sig

<Prev in Thread] Current Thread [Next in Thread>