How to wrap a template function(not a member of a template class) into python?

Dear All, How can I wrap a c++ template function(not a member of any class) by pyste or manually? /**************************************/ for example : template<class T> void push(v_array<T>& v, const T &new_ele) { while(v.index >= v.length) { v.length = 2*v.length + 3; v.elements = (T *)realloc(v.elements,sizeof(T) * v.length); } v[v.index++] = new_ele; } /***************************************/ Here v_array is a class. I know how to wrap a c++ template class into python by pyste. But what should I do if the template function is not a member of a class. (I don't want to put the function"push()" into a class). Any suggestion will be appreciated. Thanks! Javen Research School of Information Sciences and Engineering Australian National University Locked Bag 8001 Canberra ACT 2601

On Sun, 27 Aug 2006, Qinfeng(Javen) Shi wrote:
Dear All,
How can I wrap a c++ template function(not a member of any class) by pyste or manually? /**************************************/ for example : template<class T> void push(v_array<T>& v, const T &new_ele) { while(v.index >= v.length) { v.length = 2*v.length + 3; v.elements = (T *)realloc(v.elements,sizeof(T) * v.length); } v[v.index++] = new_ele; } /***************************************/ Here v_array is a class. I know how to wrap a c++ template class into python by pyste. But what should I do if the template function is not a member of a class. (I don't want to put the function"push()" into a class).
It's similar to template class. You just need to explicit give the template arguments, e.g. boost::python::def( "push" , & push< int > ) ; -- François Duranleau LIGUM, Université de Montréal
participants (2)
-
François Duranleau
-
Qinfeng(Javen) Shi