[C++-sig] return_internal_reference or return_value_policy

chencc at csie.nctu.edu.tw chencc at csie.nctu.edu.tw
Thu Mar 24 10:35:29 CET 2005


Hi all:
   I have a small C code, and want to extent it using boost.python. This code return pointer and take pointer as argument.  I try to use return_internal_reference or return_value_policy with manage_new_object. Then compiler can\'t give me a object code. I can\'t read these message, does any people can help me ??? I use the bjam in example/tutorial/Jamfile with modify in unix 

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

typedef unsigned int *Handle;

Handle cr(inti, Handle s) {
  Handle r;
  r = new unsigned int[i];
  for ( int j = 0; j < i; j++)
      r[j] = s[j];
  return r;
}

void dr(Handle s) {
  delete [] s;
}

void set(int i, Handle r) {
  r[i] = (unsigned int) i;
}

int get(int i, Handle r) {
  return r[i];
}

BOOST_PYTHON_MODULE(my) {
  def(\"cr\",cr,return_value_policy< manage_new_object> () );
  // def(\"cr\",cr,return_internal_reference<2> () );
  def(\"dr\",dr);
  def(\"set\",set);
  def(\"get\",get);
}
}




More information about the Cplusplus-sig mailing list