[C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS question

eric andersonT eric.anderson at comcast.net
Wed Sep 10 20:09:38 CEST 2003


Hi everyone, I have a question about the macro in the email subject and
how to specify return_value_policy<manage_new_object>() using it.

Where does it fit into this (untested pseudo-c++):

struct A
{
	int a;
};
struct B
{
	A* foo();
};
struct C
{
	B* bar( int a=0 );
};

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( bar_overloads, C::bar, 0, 1 );

void GlueToPython()
{
	using boost::python;
	class<A>( "A", "class A", init<> )
	;
	class<B>( "B", "class B", init<> )
		.def( "foo", &B::foo, "returns object of class A",
return_value_policy<manage_new_object>() )
	;
	class<C>( "C", "class C", init<> )
		// NEEDED HERE: return_value_policy<manage_new_object>()
		.def( "bar", &C::bar, bar_overloads( args( "a" ),
"returns object of class B" )
	;
}


Thank you,

Eric





More information about the Cplusplus-sig mailing list