[C++-sig] a question about boost python

Chang Chen Chang_Chen at sonic.com
Wed Oct 17 05:38:23 CEST 2007


I know we need define a wrapper, but our function signature is quite
regular. i.e. only the last parameter is output parameter, so I want to
write a template, so that such wrapper can be easily written.

Our function definition looks like:

    void function1(int  t1, float t2, string& t3) ;

I want to define a template:

template <typename Return, typename T1, typename T2, typename TOUT> 
 struct FunctionConvert< Return (*) ( T1 , T2, TOUT& ) >
{
	typedef functionT	Return (*) ( T1 , T2, TOUT& );
	static TOUT run(functionT P,const T1& t1, const T2& t2)
	{
		TOUT out;
		P(t1,t2,out);
		return out;
	}
}

But I do not know how to integrate it with boost python :(.

- Chang




More information about the Cplusplus-sig mailing list