Boost logo

Boost :

Subject: [boost] How to specify return policy for object returned as part of a tuple in boost python
From: Eddie C. (cao.yiqun+boost_at_[hidden])
Date: 2011-01-31 17:54:11


Hi all,

I have a function that creates a C++ object. Before the refactor, I was
returning a pointer from the C++ function, and in the boost python
wrapper declaration, I would use
boost::python::return_value_policy<boost::python::manage_new_object>.

Now I need to return not only just the object, but also some error
messages, and the refactor basically changes the C++ function to let
it return a tuple:

boost::python::tuple create_object_from_description(std::string&
description)
{
  ...
  return boost::python::make_tuple(myObject, errmsg);
}

How should I specify the return policy with this change?

Thanks,
Eddie


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk